Skip to content

bm25_native 1.0.0

Latest

Choose a tag to compare

@Xof Xof released this 06 Oct 19:02

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 n returns 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_field for scoring by your own key.
  • Phrase, proximity and snippets: exact phrases, ~n / ~>n proximity, and bm25_snippet() highlighted excerpts.
  • Boolean and wildcard queries: must / should / must_not trees 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 retryable 40001 instead 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 online bm25_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 install
CREATE EXTENSION bm25_native;

See the README for usage, maintenance, and upgrade procedures.

License

PostgreSQL License.