Script in custom_filters_score/function_score

The documentation for custom_filters_score does not provide an example of
how "script" can be used. However, it refers to function_score in later
versions of ES search, and the doc of function_score has the following
example:

"custom_filters_score": {
"filters": [
{
"boost_factor": "3",
"filter": {...}
},
{
"filter": {â.},
"script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"
}
],
"params": {
"param1": 2,
"param2": 3.1
},
"query": {...},
"score_mode": "first"
}

becomes:

"function_score": {
"functions": [
{
"boost_factor": "3",
"filter": {...}
},
{
"filter": {...},
"script_score": {
"params": {
"param1": 2,
"param2": 3.1
},
"script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"
}
}
],
"query": {...},
"score_mode": "first"
}

The script in the example seems to imply that the script will solely
determine the score, but in practice the value evaluated by the script will
be multiplied with the query score. So the script in the example should
have been: "doc['my_numeric_field'].value / pow(param1, param2)"

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0bd7f0ec-8dd1-4200-8d6a-b00fa56b8131%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I guess at least for function_score an alternative is to specify boost_mode
to "replace" instead of the default "multiply". But I don't think there is
an equivalent alternative for custom_filters_score. In any case, I think
the documentation should be updated or made clearer.

Thanks,
Hieu

On Thursday, September 18, 2014 2:32:45 PM UTC-7, Hieu Nguyen wrote:

The documentation for custom_filters_score does not provide an example of
how "script" can be used. However, it refers to function_score in later
versions of ES search, and the doc of function_score has the following
example:

"custom_filters_score": {
"filters": [
{
"boost_factor": "3",
"filter": {...}
},
{
"filter": {â.},
"script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"
}
],
"params": {
"param1": 2,
"param2": 3.1
},
"query": {...},
"score_mode": "first"
}

becomes:

"function_score": {
"functions": [
{
"boost_factor": "3",
"filter": {...}
},
{
"filter": {...},
"script_score": {
"params": {
"param1": 2,
"param2": 3.1
},
"script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"
}
}
],
"query": {...},
"score_mode": "first"
}

The script in the example seems to imply that the script will solely
determine the score, but in practice the value evaluated by the script will
be multiplied with the query score. So the script in the example should
have been: "doc['my_numeric_field'].value / pow(param1, param2)"

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5da25ff7-1162-44ee-8ae0-7b1c2501cd7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.