pg_search

Full text search for PostgreSQL using BM25

Overview

PackageVersionCategoryLicenseLanguage
pg_search0.21.12FTSAGPL-3.0Rust
IDExtensionBinLibLoadCreateTrustRelocSchema
2100pg_searchNoYesNoYesYesNoparadedb
Relatedpgroonga pgroonga_database pg_bestmatch vchord_bm25 pg_bigm zhparser pg_tokenizer pg_trgm

PG 17+ does not require dynamic loading

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.21.121817161514pg_search-
RPMPIGSTY0.21.121817161514pg_search_$v-
DEBPIGSTY0.21.121817161514postgresql-$v-pg-search-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64PIGSTY MISS
el10.aarch64PIGSTY MISS
d12.x86_64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.7
d12.aarch64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.7
d13.x86_64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
d13.aarch64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.5
u22.x86_64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.7
u22.aarch64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.7
u24.x86_64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.7
u24.aarch64
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.21.12
PIGSTY 0.20.7

Build

You can build the DEB packages for pg_search using pig build:

pig build pkg pg_search         # build DEB packages

Install

You can install pg_search directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_search;          # Install for current active PG version
pig ext install -y pg_search -v 18  # PG 18
pig ext install -y pg_search -v 17  # PG 17
pig ext install -y pg_search -v 16  # PG 16
pig ext install -y pg_search -v 15  # PG 15
dnf install -y pg_search_18       # PG 18
dnf install -y pg_search_17       # PG 17
dnf install -y pg_search_16       # PG 16
dnf install -y pg_search_15       # PG 15
apt install -y postgresql-18-pg-search   # PG 18
apt install -y postgresql-17-pg-search   # PG 17
apt install -y postgresql-16-pg-search   # PG 16
apt install -y postgresql-15-pg-search   # PG 15

Create Extension:

CREATE EXTENSION pg_search;

Usage

https://docs.paradedb.com/documentation/getting-started/quickstart

CREATE EXTENSION pg_search;

ALTER SYSTEM SET paradedb.pg_search_telemetry TO 'off';

CALL paradedb.create_bm25_test_table(
  schema_name => 'public',
  table_name => 'mock_items'
);

SELECT description, rating, category FROM mock_items LIMIT 3;

-- Create a BM25 index (key_field must be UNIQUE, one BM25 index per table)
CREATE INDEX search_idx ON mock_items
USING bm25 (id, description, category, rating, in_stock, created_at, metadata, weight_range)
WITH (key_field='id');

-- Full-text search with @@@ operator
SELECT description, rating, category
FROM mock_items
WHERE description @@@ 'keyboard' AND rating > 2
ORDER BY rating
LIMIT 5;

-- BM25 relevance scoring
SELECT description, paradedb.score(id)
FROM mock_items
WHERE description @@@ 'keyboard'
ORDER BY paradedb.score(id) DESC
LIMIT 5;

-- Highlighting matched terms
SELECT description, paradedb.snippet(description), paradedb.score(id)
FROM mock_items
WHERE description @@@ 'keyboard'
ORDER BY paradedb.score(id) DESC
LIMIT 5;

-- Exact phrase search (use double quotes inside single quotes)
SELECT description, rating, category
FROM mock_items
WHERE description @@@ '"metal keyboard"';

-- Configure text fields with tokenizers (e.g., English stemming)
DROP INDEX search_idx;
CREATE INDEX search_idx ON mock_items
USING bm25 (id, (description::pdb.simple('stemmer=english')), category)
WITH (key_field='id');

Last Modified 2026-03-12: add pg extension catalog (95749bf)