pgx-bm25 1.0 Brings Okapi BM25 Ranked Full-Text Search to PostgreSQL as a Native Index

PostgreSQL · 7 Oct 2026 · 2 min read

#postgresql

PGX Inc. has released pgx-bm25 1.0, an extension that adds Okapi BM25 ranked full-text search directly into PostgreSQL as a native index access method. It supports PostgreSQL 17 and 18 and installs under the name bm25_native. Instead of bolting on an external engine, it turns ranked search into something the database itself maintains and queries.

The concrete changes developers get:

  • A new index access method: CREATE EXTENSION bm25_native; followed by CREATE INDEX docs_bm25 ON docs USING bm25_native (body);.
  • Ranking operators: @@@ selects matching rows, while &@@ orders them by relevance. A query like SELECT id, bm25_score(ctid) AS score FROM docs WHERE body @@@ 'quick fox' ORDER BY body &@@ 'quick fox' LIMIT 10; runs as an ordered index scan with no Sort node.
  • The whole index lives in the index relation's own pages, so it inherits WAL logging, crash recovery, and physical replication from core, with VACUUM maintaining it.
  • It is written in C against stock server headers and builds with PGXS; a C compiler and pg_config are the entire toolchain.
  • Text is analyzed with PostgreSQL's own Snowball dictionaries, with the language set per index, so a search for negligent finds negligence.
  • Ranked top-N queries use block-max WAND, so a typical LIMIT 10 search does not have to score every matching document.

For developers, the appeal is operational simplicity. There is no external search engine and no separate runtime to deploy, monitor, or keep synchronized with the database. Relevance ranking becomes another index the server manages, backed by the same durability and replication guarantees as the rest of your data. That lowers the barrier to adding BM25-style search to existing PostgreSQL applications, though it also means index builds and search now compete for the same server resources as transactional workloads.

Source: https://www.postgresql.org/about/news/pgx-bm25-10-bm25-ranked-full-text-search-as-a-native-postgresql-index-3396/

Related

auto-curated · source linked above ← all news