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

Apply boost in script_score query to the whole query #48465

Closed
mayya-sharipova opened this issue Oct 24, 2019 · 3 comments · Fixed by #52478
Closed

Apply boost in script_score query to the whole query #48465

mayya-sharipova opened this issue Oct 24, 2019 · 3 comments · Fixed by #52478
Labels
>bug :Search Relevance/Ranking Scoring, rescoring, rank evaluation. Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@mayya-sharipova
Copy link
Contributor

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.

@mayya-sharipova mayya-sharipova added the :Search Relevance/Ranking Scoring, rescoring, rank evaluation. label Oct 24, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Ranking)

@mayya-sharipova
Copy link
Contributor Author

mayya-sharipova commented Oct 24, 2019

Adding team-discuss option to understand the current boost behaviour in function_score query.

@mayya-sharipova
Copy link
Contributor Author

mayya-sharipova commented Oct 28, 2019

We have decided to document this behaviour in function_score query. And correct the bug for script_score query.

mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this issue Feb 18, 2020
Before boost in script_score query was wrongly applied only to the subquery.
This commit makes sure that the boost is applied to the whole score
that comes out of script.

Closes elastic#48465
mayya-sharipova added a commit that referenced this issue Feb 24, 2020
Before boost in script_score query was wrongly applied only to the subquery.
This commit makes sure that the boost is applied to the whole score
that comes out of script.

Closes #48465
mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this issue Feb 24, 2020
Before boost in script_score query was wrongly applied only to the subquery.
This commit makes sure that the boost is applied to the whole score
that comes out of script.

Closes elastic#48465
mayya-sharipova added a commit that referenced this issue Feb 24, 2020
Before boost in script_score query was wrongly applied only to the subquery.
This commit makes sure that the boost is applied to the whole score
that comes out of script.

Closes #48465
@javanna javanna added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Relevance/Ranking Scoring, rescoring, rank evaluation. Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants