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 [email protected].
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.

Reply via email to