What is BM25?
BM25 is a ranking method widely used in keyword search. It scores how relevant a document is to a query based on how many times the query terms appear in the document, how common each term is across the whole dataset, and the length of the document. Elasticsearch uses BM25 by default to calculate relevance.
How the score is calculated
BM25 belongs to the TF-IDF family of scoring methods. The more often a query term appears in a document, the higher the score, but each additional occurrence adds less than the one before. The rarer a term is, the more weight it gets. The longer a document is, the less the same number of occurrences counts.
Elasticsearch uses the parameter k1 to control how quickly term frequency saturates and the parameter b to control the effect of document length. The defaults are 1.2 and 0.75 respectively.
How it differs from semantic retrieval
BM25 scores by term and does not understand synonyms on its own. If the system adds no synonym expansion, a user who says "book a table" while a tool's description only says "reservation" may leave no term to match. Semantic retrieval based on embeddings is a different way to build that link. The two can be used together, with the candidates then passed to a reranking model for finer ordering.
Sources and scope
- Elastic: Similarity settings
- Robertson, S., & Zaragoza, H. (2009): The Probabilistic Relevance Framework: BM25 and Beyond
- Elastic: Synonym token filter
Sources as checked for the source-language entry on 2026-11-06; this English edition does not re-check them and adds no new claims.