vchord_bm25 & pg_tokenizer
vchord_bm25 & pg_tokenizer).vchord_bm25 (maintained by Pigsty at pgsty/vchord_bm25) is a native PostgreSQL extension built in Rust (pgrx) that implements the Okapi BM25 ranking algorithm and the Block-WeakAnd (Block-Max WAND) Top-K index scan access method inside PostgreSQL.
Paired with pg_tokenizer (maintained by Pigsty at pgsty/pg_tokenizer for customizable multilingual tokenization and vocabulary models) or PostgreSQL’s built-in tsvector analyzer, vchord_bm25 brings Elasticsearch/Lucene-class lexical full-text ranking directly into your relational database—and combines seamlessly with vchord for hybrid semantic + lexical search.
Understand why BM25 matters, install vchord_bm25 and pg_tokenizer, and run your first ranked full-text query.
Build bm25 indexes, run Top-K queries, apply WHERE prefilters, and fuse BM25 with VectorChord dense vectors.
Configure text analyzers, stemmers, stopwords, synonyms, HuggingFace models, Chinese Jieba, and Japanese Lindera.
Complete SQL types, operators, functions, GUC parameters, version evolution, and BEIR benchmark results.
Highlights
- True Okapi BM25 Scoring: Supports inverse document frequency (IDF), term frequency saturation (), and quantized 1-byte document length normalization ( and average document length )—solving fundamental relevance limitations of PostgreSQL’s native
ts_rank. - Block-WeakAnd Index Acceleration: Stores compressed posting lists with per-block maximum score upper bounds using delta-bitpacking, skipping non-competitive document blocks during Top-K queries without scanning entire inverted lists.
- Multilingual Tokenization: Works with
pg_tokenizer(llmlingua2,bert_base_uncased,wiki_tocken,gemma2b, custom corpus-trained models, Chinesejieba, Japaneselindera) inv0.1–v0.3, and supports PostgreSQL’s nativetsvectordirectly in the next-generationmainarchitecture. - Native Hybrid Search with VectorChord: Run lexical BM25 (
vchord_bm25) and dense vector search (vchordrq) inside a single SQL query using Reciprocal Rank Fusion (RRF) or ColBERT MaxSim reranking.
Overview, installation, and quick start guide for vchord_bm25 and pg_tokenizer.
Index management, Top-K querying, prefiltering, hybrid search with vchord, and Block-WeakAnd internals.
Complete guide to pg_tokenizer: text analyzers, character/token filters, pretrained and custom models, and multilingual tokenization.
Complete SQL reference, GUC parameters, benchmarks, and version history for vchord_bm25 and pg_tokenizer.