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 byCREATE INDEX docs_bm25 ON docs USING bm25_native (body);. - Ranking operators:
@@@selects matching rows, while&@@orders them by relevance. A query likeSELECT 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 noSortnode. - The whole index lives in the index relation's own pages, so it inherits WAL logging, crash recovery, and physical replication from core, with
VACUUMmaintaining it. - It is written in C against stock server headers and builds with PGXS; a C compiler and
pg_configare the entire toolchain. - Text is analyzed with PostgreSQL's own Snowball dictionaries, with the language set per index, so a search for
negligentfindsnegligence. - Ranked top-N queries use block-max WAND, so a typical
LIMIT 10search 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.