The documentation says that using a field_value_factor value of:
"field_value_factor": {
"field": "popularity",
"factor": 1.2,
"modifier": "sqrt",
"missing": 1
}
"Which will translate into the following formula for scoring:
sqrt(1.2 * doc['popularity'].value)
"
But what I do not understand is what is done with sqrt(1.2 * doc['popularity'].value)
? Is it multiplied by the original score of each hit to create a new score? Is it added? Can I change whether it is multiplied or added?
Is that what is defined in function_score["boost_mode"]?
The default scoring algorithm used by Elasticsearch is BM25. There are three main factors that determine a document's score: Term frequency (TF) — The more times that a search term appears in the field we are searching in a document, the more relevant that document is.
Lucene/Elasticsearch uses the Boolean model to find matching documents, and a formula called the practical scoring function to calculate the score.
The basic mechanics are as follows: ElasticSearch Score is normalized between 0..1 ( score/max(score) ), we add our ranking score ( also normalized between 0..1 ) and divide by 2.
The _score in Elasticsearch is a way of determining how relevant a match is to the query. The default scoring function used by Elasticsearch is actually the default built in to Lucene which is what Elasticsearch runs under the hood.
yeah you are in the right direction. Two properties control the overall combination of individual scores and the score for the function score and naturally evaluated score. They are
score_mode - This variable control how the computed scores are combined:
boost_mode - This variable control how query score and computed score are combined
Reference
Take a look at the following query
{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [{
"field_value_factor": {
"field": "popularity",
"factor": 1.2,
"modifier": "sqrt",
"missing": 1
}
}, {
"linear": {
"distance": {
"origin": "0",
"scale": "0.4"
}
}
}, {
"gauss": {
"price": {
"origin": "0",
"scale": ".08"
}
}
}],
"score_mode": "multiply",
"boost_mode": "sum"
}
}
}
Since score_mode is multiply, as you can see there are three functions in my function score query, so this will multiply the score of each fucntion
function_score = score_linear * score_gauss * score_field_value_factor
Again - boost_mode is sum, so my final score will the summations of overall score evaluated by function score and the query score.
document_score = function_score + query_score.
Thanks
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