Relevance for Elasticsearchs
Elasticsearch relevance is how the engine orders matching documents by a score, computed by default with the BM25 algorithm from term frequency, inverse document frequency and field length. Tuning relevance means adjusting that score with boosts, multi-field queries and function scoring.
Stage: Searching · Part of the Elasticsearch roadmap · Last reviewed 19 November 2026
What to learn in Relevance
- Read the _score of a hit and use the explain API to see how it was computed
- Boost a title field above a body field in a multi_match query
- Add popularity or recency to ranking with a function_score query
- Add typo tolerance with fuzziness and compare it with prefix matching
- Use synonyms and analyzers to improve recall without hurting precision
Relevance interview questions
How does BM25 decide which document ranks higher?
It rewards documents where the query terms appear more often, but with diminishing returns, and rewards rare terms more than common ones through inverse document frequency. It also normalises for field length, so a match in a short title counts more than in a long body.
How would you make newer articles rank higher without hiding older ones?
Wrap the text query in a function_score query with a decay function on the date field. It lowers the score smoothly as documents get older rather than filtering them out, and you can combine it with the text score using a chosen boost mode.
Where Relevance fits in the Elasticsearch roadmap
Relevance belongs to the Searching stage (intermediate level), which takes about 15 hours. Queries and relevance.
Other units in this stage
Back to the full Elasticsearch roadmap