data-infra

BM25

BM25 (Best Match 25) is the classic lexical ranking function behind most full-text search: it scores a document against a query by combining how often each query term appears in the document (with diminishing returns — twenty repetitions don't score twenty times higher), how rare the term is across the whole corpus, and a normalization that stops long documents from winning by sheer bulk. It powers the defaults in Elasticsearch, OpenSearch, and Lucene. In the RAG era BM25 has aged well as the complement to embeddings: vector search captures paraphrase and meaning but blurs exact identifiers, while BM25 nails the literal strings — error codes, SKUs, function names, legal citations — that embeddings treat as noise. That is why production retrieval is typically hybrid, running BM25 and vector search in parallel and fusing results (often via reciprocal rank fusion) before reranking. It is cheap, fast, interpretable, and requires no training.

Related terms

More Data & Infra terms