Repository navigation
First public release of bm25_native, a native PostgreSQL index access method (USING bm25_native) for Okapi BM25 ranked full-text search. It is pure C against stock PostgreSQL via PGXS, with no external search engine. The whole index lives in the index relation's own pages, so WAL, crash recovery and physical replication come from core.
Highlights
- Two operators:
@@@matches and&@@ranks.ORDER BY body &@@ 'query' LIMIT nreturns documents in descending BM25 score as an ordered index scan, with no Sort node. Block-max WAND prunes the top-k scan. - Multi-field / BM25F: one index over several columns, with per-field boosts and length normalization, and an optional
key_fieldfor scoring by your own key. - Phrase, proximity and snippets: exact phrases,
~n/~>nproximity, andbm25_snippet()highlighted excerpts. - Boolean and wildcard queries:
must/should/must_nottrees and prefix wildcards, built through jsonb query builders. - Hot standby: queries run on physical replicas. Without
hot_standby_feedback, a long standby query can be cancelled with a retryable40001instead of reading a reused page. - Format compatibility: every index records the oldest format that can read it. Additive format changes need no
REINDEX, and a breaking change ships with an onlinebm25_upgrade(regclass)path.
Requirements
PostgreSQL 17 or 18 with server development headers, a C toolchain, and pg_config. PostgreSQL 19 pre-GA is tested in CI but not yet supported.
Install
make PG_CONFIG=/path/to/pg_config
make PG_CONFIG=/path/to/pg_config installCREATE EXTENSION bm25_native;See the README for usage, maintenance, and upgrade procedures.