psql_bm25s
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
psql_bm25s | 0.4.13 | FTS | Apache-2.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2210 | psql_bm25s | No | Yes | No | Yes | No | No | - |
| Related | pg_search pgroonga pg_textsearch pg_fts vchord_bm25 pg_bestmatch pg_tokenizer pg_rrf pgcontext vectorize |
|---|
Supports PostgreSQL 17-18; optional shared_preload_libraries arena is not required for normal use.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.4.13 | 1817161514 | psql_bm25s | - |
| RPM | PIGSTY | 0.4.13 | 1817161514 | psql_bm25s_$v | - |
| DEB | PIGSTY | 0.4.13 | 1817161514 | postgresql-$v-psql-bm25s | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.4.13 el8.x86_64.pg18 : psql_bm25s_18 psql_bm25s_18-0.4.13-1PIGSTY.el8.x86_64.rpm
| PIGSTY 0.4.13 el8.x86_64.pg17 : psql_bm25s_17 psql_bm25s_17-0.4.13-1PIGSTY.el8.x86_64.rpm
| N/A | N/A | N/A |
| el8.aarch64 | PIGSTY 0.4.13 el8.aarch64.pg18 : psql_bm25s_18 psql_bm25s_18-0.4.13-1PIGSTY.el8.aarch64.rpm
| PIGSTY 0.4.13 el8.aarch64.pg17 : psql_bm25s_17 psql_bm25s_17-0.4.13-1PIGSTY.el8.aarch64.rpm
| N/A | N/A | N/A |
| el9.x86_64 | PIGSTY 0.4.13 el9.x86_64.pg18 : psql_bm25s_18 psql_bm25s_18-0.4.13-1PIGSTY.el9.x86_64.rpm
| PIGSTY 0.4.13 el9.x86_64.pg17 : psql_bm25s_17 psql_bm25s_17-0.4.13-1PIGSTY.el9.x86_64.rpm
| N/A | N/A | N/A |
| el9.aarch64 | PIGSTY 0.4.13 el9.aarch64.pg18 : psql_bm25s_18 psql_bm25s_18-0.4.13-1PIGSTY.el9.aarch64.rpm
| PIGSTY 0.4.13 el9.aarch64.pg17 : psql_bm25s_17 psql_bm25s_17-0.4.13-1PIGSTY.el9.aarch64.rpm
| N/A | N/A | N/A |
| el10.x86_64 | PIGSTY 0.4.13 el10.x86_64.pg18 : psql_bm25s_18 psql_bm25s_18-0.4.13-1PIGSTY.el10.x86_64.rpm
| PIGSTY 0.4.13 el10.x86_64.pg17 : psql_bm25s_17 psql_bm25s_17-0.4.13-1PIGSTY.el10.x86_64.rpm
| N/A | N/A | N/A |
| el10.aarch64 | PIGSTY 0.4.13 el10.aarch64.pg18 : psql_bm25s_18 psql_bm25s_18-0.4.13-1PIGSTY.el10.aarch64.rpm
| PIGSTY 0.4.13 el10.aarch64.pg17 : psql_bm25s_17 psql_bm25s_17-0.4.13-1PIGSTY.el10.aarch64.rpm
| N/A | N/A | N/A |
| d12.x86_64 | PIGSTY 0.4.13 d12.x86_64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~bookworm_amd64.deb
| PIGSTY 0.4.13 d12.x86_64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~bookworm_amd64.deb
| N/A | N/A | N/A |
| d12.aarch64 | PIGSTY 0.4.13 d12.aarch64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~bookworm_arm64.deb
| PIGSTY 0.4.13 d12.aarch64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~bookworm_arm64.deb
| N/A | N/A | N/A |
| d13.x86_64 | PIGSTY 0.4.13 d13.x86_64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~trixie_amd64.deb
| PIGSTY 0.4.13 d13.x86_64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~trixie_amd64.deb
| N/A | N/A | N/A |
| d13.aarch64 | PIGSTY 0.4.13 d13.aarch64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~trixie_arm64.deb
| PIGSTY 0.4.13 d13.aarch64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~trixie_arm64.deb
| N/A | N/A | N/A |
| u22.x86_64 | PIGSTY 0.4.13 u22.x86_64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~jammy_amd64.deb
| PIGSTY 0.4.13 u22.x86_64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~jammy_amd64.deb
| N/A | N/A | N/A |
| u22.aarch64 | PIGSTY 0.4.13 u22.aarch64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~jammy_arm64.deb
| PIGSTY 0.4.13 u22.aarch64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~jammy_arm64.deb
| N/A | N/A | N/A |
| u24.x86_64 | PIGSTY 0.4.13 u24.x86_64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~noble_amd64.deb
| PIGSTY 0.4.13 u24.x86_64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~noble_amd64.deb
| N/A | N/A | N/A |
| u24.aarch64 | PIGSTY 0.4.13 u24.aarch64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~noble_arm64.deb
| PIGSTY 0.4.13 u24.aarch64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~noble_arm64.deb
| N/A | N/A | N/A |
| u26.x86_64 | PIGSTY 0.4.13 u26.x86_64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~resolute_amd64.deb
| PIGSTY 0.4.13 u26.x86_64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~resolute_amd64.deb
| N/A | N/A | N/A |
| u26.aarch64 | PIGSTY 0.4.13 u26.aarch64.pg18 : postgresql-18-psql-bm25s postgresql-18-psql-bm25s_0.4.13-1PIGSTY~resolute_arm64.deb
| PIGSTY 0.4.13 u26.aarch64.pg17 : postgresql-17-psql-bm25s postgresql-17-psql-bm25s_0.4.13-1PIGSTY~resolute_arm64.deb
| N/A | N/A | N/A |
Build
You can build the RPM / DEB packages for psql_bm25s using pig build:
Install
You can install psql_bm25s directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources: README v0.4.13, API reference, query semantics, input types, index parameters, index policy
psql_bm25s is a PostgreSQL-native index access method for BM25-family lexical retrieval. It keeps the BM25 contract explicit through corpus-statistics-driven ranking, exact top-k retrieval APIs, and PostgreSQL storage/maintenance behavior for mutable tables.
Version 0.4.13 is packaged for PostgreSQL 17 and 18 in this catalog.
Basic Search
With no WITH (...) options, the index uses Lucene-style BM25 and IDF defaults with the realtime consistency policy.
Indexed Inputs
psql_bm25s supports five indexed source-column types:
textandvarcharfor direct indexing of ordinary scalar text columns.text[]andvarchar[]for application-owned token streams.int4[]for applications that manage token IDs externally.
Scalar text and varchar columns are tokenized at the index boundary. Pretokenized arrays avoid scalar retokenization and are the preferred shape when the application already owns tokenization.
Retrieval APIs
The canonical exact BM25 APIs are:
psql_bm25s_query_tokens(regclass, text[], k, weight_mask)for token-text indexes.psql_bm25s_query_ids(regclass, int4[], k, weight_mask)for token-ID indexes.
The main SQL convenience APIs are:
psql_bm25s_query(regclass, query_text, k, weight_mask, ...)psql_bm25s_prepared_query(regclass, query_text, ...)psql_bm25s_query_prepared(prepared_query, k, weight_mask)
These rowset APIs return psql_bm25s_result_hit rows with ctid, doc_id, and score. Join hits back to application rows with ctid when the query needs both row data and the query-time score.
Operators
The operator surface is useful for SQL-native filtering and ordering:
tokens @@ 'query text'is a boolean document-match predicate.tokens @@@ psql_bm25s_prepared_query(...)is an index-bound prepared predicate.ORDER BY tokens <=> psql_bm25s_order_tokens(...) ASC LIMIT kis the ordered retrieval form.
@@ is not a ranking API. <=> aligns with true BM25 ordering only when PostgreSQL chooses a real psql_bm25s index scan; use the rowset retrieval APIs when you need the clearest exact top-k contract.
Index Options
Scoring reloptions include:
methodandidf_method, defaulting tolucene; supported variants arerobertson,lucene,atire,bm25l, andbm25+.k1, default1.5.b, default0.75.delta, default0.5, used by BM25L and BM25+.
Scalar text processing reloptions include:
text_lowercase, defaulttrue.text_stopwords, defaultNULL.text_stem_english, defaultfalse.text_fold_diacritics, defaultfalse.
Multi-Field and Hybrid Search
For separate title, abstract, and body indexes, use late fusion helpers so each field produces query-scoped hits before scores are combined:
Hybrid vector/BM25 search is also a late-fusion layer. BM25 and vector indexes produce candidates independently, and psql_bm25s_hybrid_fuse_candidates(...) combines them using rrf by default. The core extension does not require pgvector, VectorChord, or any vector type to be installed.
Maintenance and Cache
The public maintenance switch is the consistency reloption:
realtime, the default, keeps committed writes searchable immediately.eventualfavors foreground read/write latency and allows short-term stale BM25 results while maintenance converges.manualleaves refresh under explicit operator or scheduler control.
Operational helpers include:
psql_bm25s_index_details(regclass)psql_bm25s_index_policy_recommend(regclass, profile)psql_bm25s_index_refresh(regclass)psql_bm25s_index_maintain(regclass)psql_bm25s_index_try_maintain(regclass)psql_bm25s_index_maintain_due(max_indexes)
Large immutable index payloads can use a shared generation cache. The zero-configuration DSM cache does not require shared_preload_libraries. For large connection-pool deployments, an optional shared-preload arena can be enabled with shared_preload_libraries = 'psql_bm25s' and psql_bm25s.shared_generation_cache_size, but that arena is not required for normal use.
Related global GUCs include:
psql_bm25s.maintenance_worker_limitpsql_bm25s.preload_timer_interval_mspsql_bm25s.maintenance_timer_interval_mspsql_bm25s.maintenance_rebuild_memory_budget
Caveats
- The extension is not relocatable after creation; choose a non-
publicschema atCREATE EXTENSIONtime if needed. eventualandmanualconsistency deliberately trade immediate freshness for lower foreground cost or explicit refresh control.- Logical replication follows PostgreSQL behavior: table rows replicate, but index relations do not replicate as logical data objects, so indexes should be created or rebuilt on subscribers.
- The optional shared-preload cache requires PostgreSQL configuration and a restart because the shared arena is allocated at server start.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)