pg_search
Full text search for PostgreSQL using BM25
Repository
dev/pg_search
https://github.com/paradedb/paradedb/tree/dev/pg_search
Source
pg_search-0.21.8.tar.gz
pg_search-0.21.8.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_search | 0.21.12 | FTS | AGPL-3.0 | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2100 | pg_search | No | Yes | No | Yes | Yes | No | paradedb |
| Related | pgroonga pgroonga_database pg_bestmatch vchord_bm25 pg_bigm zhparser pg_tokenizer pg_trgm |
|---|
PG 17+ does not require dynamic loading
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.21.12 | 1817161514 | pg_search | - |
| RPM | PIGSTY | 0.21.12 | 1817161514 | pg_search_$v | - |
| DEB | PIGSTY | 0.21.12 | 1817161514 | postgresql-$v-pg-search | - |
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;
THIS EXTENSION is built by ParadeDB team and delivered by the PIGSTY repo
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');
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.