Is it possible to make a query for Elastic Search that returns a score as a percentage of the maximum score? Until now it returns a value like "_score": 0.00786336, and also a maximum score like max_score": 0.13435546, so I could try to convert my result but I want the result to be already in percentages, so I could use a minimum score, for example of 40 percent.
In short: Is there a way to get the _score in percentages of the max score, or is there another way of setting a minimum score? (seems to be hard because the max_score seems random)
The score represents how relevant a given document is for a specific query. The default scoring algorithm used by Elasticsearch is BM25.
Just add a "boost" field or similar with a numerical value and order by that first in your query (and by score second).
max_score is not random, it's simply the max of all the scores of the result set from your query.
The
max_scorevalue is the highest_scoreof any document that matches our query.
For example, if your _score values are: [0.00786336, 0.0123, 0.0813523, 0.13435546], then your max_score is 0.13435546.
There is also no limit to how high the _score may be based on the relevance of your matches (i.e. it can be in excess of 1)
If you're trying to represent a "percentage match" using a ratio of _score from a hit to a max_score, you're going to get unreliable results, especially if you have a lot of low-score hits with little to no relevance, yet the max_score is close to those low scores.
If you're trying to filter out by a minimum score, you should use min_score
Also see "What is Relevance?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With