WARNING: Version 0.90 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Custom Score Query
editCustom Score Query
editDeprecated in 0.90.4.
Replaced by Function Score Query
custom_score
query allows to wrap another query and customize the
scoring of it optionally with a computation derived from other field
values in the doc (numeric ones) using
script expression. Here is
a simple sample:
"custom_score" : { "query" : { .... }, "script" : "_score * doc['my_numeric_field'].value" }
On top of the different scripting field values and expression, the
_score
script parameter can be used to retrieve the score based on the
wrapped query.
Script Parameters
editScripts are cached for faster execution. If the script has parameters that it needs to take into account, it is preferable to use the same script, and provide parameters to it:
"custom_score" : { "query" : { .... }, "params" : { "param1" : 2, "param2" : 3.1 }, "script" : "_score * doc['my_numeric_field'].value / pow(param1, param2)" }