IMPORTANT: Version 7.0 of Elasticsearch has passed its maintenance date.
This documentation is no longer being updated. For the latest information, see the current release documentation.
Many domains have static signals that are known to be correlated with relevance. For instance PageRank and url length are two commonly used features for web search in order to tune the score of web pages independently of the query.
For instance imagine that you have a
pagerank field that you wish to
combine with the BM25 score so that the final score is equal to
score = bm25_score + pagerank / (10 + pagerank).
script_score query the query would
look like this:
while with the
rank_feature query it would
look like below:
While both options would return similar scores, there are trade-offs:
script_score provides a lot of flexibility,
enabling you to combine the text relevance score with static signals as you
prefer. On the other hand, the
rank_feature query only
exposes a couple ways to incorporate static signails into the score. However,
it relies on the
rank_features fields, which index values in a special way
that allows the
rank_feature query to skip
over non-competitive documents and get the top matches of a query faster.