Skip to main content

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

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.

Back to the full Elasticsearch roadmap