I'm using ElasticSearch 2.4.0 . Using the script_score, I'm calculating custom score like
{"script":"return ( ((doc.field_a.value)* 0.5) + (_score * 0.5) );"}
I want something like (some normalisation effect on the field_a value):
max_score = doc.field_a.values.max();
return ( ((doc.field_a.value)* 0.5)/max_score + (_score * 0.5) );
Any help appreciated.
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.
Before scoring documents, Elasticsearch first reduces the set of candidate documents by applying a boolean test that only includes documents that match the query. A score is then calculated for each document in this set, and this score determines how the documents are ordered.
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.
You can achieve it simply by removing the boost_mode parameter, the default boost_mode is to multiply the _score with whatever value comes out of the field_value_factor function.
Please check on the values api you are calling. I think its returning only a single value
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