Skip to content
pg_search

pg_search

pg_search : Full text search for PostgreSQL using BM25

Overview

ID Extension Package Version Category License Language
2100
pg_search
pg_search
0.24.3
FTS
AGPL-3.0
Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
Schemas paradedb
See Also
pgroonga
pgroonga_database
pg_bestmatch
vchord_bm25
pg_bigm
zhparser
pg_tokenizer
pg_trgm

bm25 access method conflicts with pg_textsearch and vchord_bm25; PIGSTY packaging uses pgrx 0.19.1 and the pinned builder Rust toolchain instead of upstream rolling stable.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
0.24.3
18
17
16
15
14
pg_search -
RPM
PIGSTY
0.24.3
18
17
16
15
14
pg_search_$v -
DEB
PIGSTY
0.24.3
18
17
16
15
14
postgresql-$v-pg-search -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
el8.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
el9.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
el9.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
el10.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
el10.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
d12.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.7
d12.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.7
d13.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.5
d13.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.5
u22.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.7
u22.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.7
u24.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.7
u24.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.20.7
u26.x86_64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
u26.aarch64
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
PIGSTY 0.24.3
N/A
Package Version OS ORG SIZE File URL
pg_search_18 0.24.3 el8.x86_64 pigsty 70.9 MiB pg_search_18-0.24.3-1PIGSTY.el8.x86_64.rpm
pg_search_18 0.24.3 el8.aarch64 pigsty 68.2 MiB pg_search_18-0.24.3-1PIGSTY.el8.aarch64.rpm
pg_search_18 0.24.3 el9.x86_64 pigsty 69.2 MiB pg_search_18-0.24.3-1PIGSTY.el9.x86_64.rpm
pg_search_18 0.24.3 el9.aarch64 pigsty 68.1 MiB pg_search_18-0.24.3-1PIGSTY.el9.aarch64.rpm
pg_search_18 0.24.3 el10.x86_64 pigsty 69.1 MiB pg_search_18-0.24.3-1PIGSTY.el10.x86_64.rpm
pg_search_18 0.24.3 el10.aarch64 pigsty 68.0 MiB pg_search_18-0.24.3-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-search 0.24.3 d12.x86_64 pigsty 65.2 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-search 0.24.3 d12.aarch64 pigsty 62.3 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-search 0.24.3 d13.x86_64 pigsty 65.2 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-search 0.24.3 d13.aarch64 pigsty 62.3 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-search 0.24.3 u22.x86_64 pigsty 67.3 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-search 0.24.3 u22.aarch64 pigsty 65.7 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-search 0.24.3 u24.x86_64 pigsty 67.2 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~noble_amd64.deb
postgresql-18-pg-search 0.24.3 u24.aarch64 pigsty 65.5 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~noble_arm64.deb
postgresql-18-pg-search 0.24.3 u26.x86_64 pigsty 67.0 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-search 0.24.3 u26.aarch64 pigsty 65.4 MiB postgresql-18-pg-search_0.24.3-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_search;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

pig install pg_search;		# install via package name, for the active PG version

pig install pg_search -v 18;   # install for PG 18
pig install pg_search -v 17;   # install for PG 17
pig install pg_search -v 16;   # install for PG 16
pig install pg_search -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_search';

Create this extension with:

CREATE EXTENSION pg_search;

Usage

Sources:

pg_search adds ParadeDB’s BM25 access method and query operators to PostgreSQL for ranked full-text, structured, and hybrid search. Use it when search must remain transactional with PostgreSQL data and must support BM25 scoring, highlighting, filters, aggregates, and joins.

Create the Extension

CREATE EXTENSION pg_search;

Upstream v0.24.3 supports PostgreSQL 15 and later. Use a build packaged for the exact PostgreSQL major version. The extension participates in planner and executor paths, so test query plans and resource use before production upgrades.

Build a BM25 Index

Create a BM25 index with a stable unique key field:

CREATE INDEX products_search_idx
ON products
USING bm25 (
  id,
  title,
  description,
  category,
  rating
)
WITH (key_field = 'id');

Keep the key field unique and non-null. Index only fields used by search or filtering; every indexed field increases build time, disk use, and write amplification.

Query, Rank, and Highlight

The @@@ operator matches a field or indexed row against a ParadeDB query:

SELECT id,
       title,
       paradedb.score(id) AS score,
       paradedb.snippet(description) AS snippet
FROM products
WHERE description @@@ 'wireless keyboard'
  AND category = 'electronics'
ORDER BY score DESC
LIMIT 20;

Use field-qualified query strings or the paradedb query constructors when user input must be constrained. Do not concatenate untrusted input into query syntax without validation.

For boolean queries, paradedb.boolean() can combine must, should, and must_not clauses and can set minimum_should_match. The extension also exposes index_created_at() for inspecting index creation time.

User-Facing Object Index

  • bm25: index access method for text and structured fields.
  • @@@: search-match operator used in WHERE clauses.
  • paradedb.score(key): BM25 relevance score for a matching row.
  • paradedb.snippet(field): highlighted excerpt for the current match.
  • paradedb.parse(…), paradedb.term(…), paradedb.boolean(…): typed query constructors.
  • paradedb.index_info(…): index metadata and field configuration.
  • paradedb.index_created_at(…): index creation timestamp.

Version 0.24.3 Operational Changes

The 0.24.x line enables more aggregate and join scan paths and adds time and timetz support. Version 0.24.3 also bounds sequential-scan buffering, caps index-build worker memory, checks available disk space earlier, fixes GROUP BY cardinality routing, and raises an error when Tantivy would truncate a value.

These safeguards reduce runaway resource use but do not eliminate capacity planning. Monitor temporary space, index size, build duration, and query memory. Re-run representative EXPLAIN ANALYZE plans after upgrading because planner behavior can change.

Compatibility and Caveats

  • pg_search uses its own BM25 index implementation. Do not assume an index created by another extension is interchangeable.
  • Local catalog metadata reports a bm25 access-method conflict with pg_textsearch and vchord_bm25; avoid loading competing implementations in the same database unless their documentation explicitly supports coexistence.
  • Search indexes must be maintained with the table and can materially increase update cost.
  • Ranking is query- and corpus-dependent. Benchmark with production-like text and filters rather than treating example scores as portable.
Last updated on