Skip to content

Apply boost in script_score query to the whole query #48465

@mayya-sharipova

Description

@mayya-sharipova

Current boost parameter in script_score query is wrongly only applied to the subquery.
For example, this query returns 1 without applying boost:

"query": {
    "script_score" : {
        "query" : {
            "match_all": {}
        },
        "script" : {
            "source" : "1"
        },
        "boost": 3
    }
}

While this query returns 3 applying boost to the subquery.

"query": {
    "script_score" : {
        "query" : {
            "match_all": {}
        },
        "script" : {
            "source" : "_score"
        },
        "boost": 3
    }
}

This behaviour was partially copied from function_score query where boost is applied to both subquery and the whole query. For example, this query returns 9 where boost is applied to the subquery and also the whole query (which is quite confusing).

"query": {
    "function_score" : {
        "query" : {
            "match_all": {}
        },
        "script_score" : {
            "script" : {
                "source" : "_score"
            }
        },
        "boost": 3
    }
}

We need to correct boost behaviour in script_score to apply only the whole query, and not subquery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions