Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query DSL: custom_filters_score #1140

Closed
kimchy opened this issue Jul 21, 2011 · 0 comments
Closed

Query DSL: custom_filters_score #1140

kimchy opened this issue Jul 21, 2011 · 0 comments

Comments

@kimchy
Copy link
Member

kimchy commented Jul 21, 2011

A custom_filters_score query allows to execute a query, and if the hit matches a provided filter (ordered), use the script associated with it to compute the score. Here is an example:

{
    "custom_filters_score" : {
        "query" : {
            "match_all" : {}
        },
        "filters" : [
            {
                "filter" : { "range" : { "age" : {"from" : 0, "to" : 10} } },
                "script" : "_score * 3"
            },
            {
                "filter" : { "range" : { "age" : {"from" : 10, "to" : 20} } },
                "script" : "_score * 2"
            }
        ]
    }
}

This can considerably simplify and increase performance for parameterized based scoring since filters are easily cached for faster performance, and the script is considerably simpler.

The query allows (on the same level as query and filters) to provide boost, and the common scripting elements params and lang.

@kimchy kimchy closed this as completed in ed6a6e3 Jul 21, 2011
ofavre pushed a commit to yakaz/elasticsearch that referenced this issue Jul 21, 2011
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant