Track_scores not working with suggestors and sort in v7.17.18

I am upgrading Elasticsearch from v6 to v7. There is one query which is not working for me with track_scores. Same query giving result in v6 but in v7 getting this error "Can't compute score on document as it doesn't match the query"
I checked mapping everything is same. If i pass the same query without track_scores i am getting result

curl --location 'http://localhost:9200/autosuggest/_search' \
--header 'Content-Type: application/json' \
--data '{
    "track_scores": true,
    "query": {
        "bool": {
            "should": [
                {
                    "match": {
                        "all_display_name_variations": {
                            "query": "benga",
                            "boost": 1
                        }
                    }
                },
                {
                    "match_phrase": {
                        "all_display_name_variations": {
                            "query": "benga",
                            "boost": 100
                        }
                    }
                }
            ]
        }
    },
    "sort": [
        {
            "_score": {
                "order": "desc"
            },
            "doc_weight": {
                "order": "desc"
            },
            "_id": {
                "order": "asc"
            }
        }
    ],
    "size": 10,
    "suggest": {
        "name_suggest": {
            "text": "benga",
            "completion": {
                "field": "name_suggest",
                "size": 10
            }
        },
        "fuzzy_suggest": {
            "text": "benga",
            "completion": {
                "field": "name_suggest",
                "size": 10,
                "fuzzy": {
                    "fuzziness": 1,
                    "min_length": 3,
                    "prefix_length": 1,
                    "transpositions": true
                }
            }
        }
    },
    "_source": [
        "id",
        "name",
        "district",
        "state",
        "is_enabled",
        "is_approved",
        "is_multi_district",
        "is_multi_state",
        "is_popular",
        "is_capital",
        "display_name",
        "doc_weight",
        "alias_type",
        "city_id",
        "city_name",
        "all_display_name_variations",
        "location",
        "language"
    ]
}'

Welcome!

What is the full response from Elasticsearch?

Response of above query

{
            "error":
            {
                "root_cause":
                [
                    {
                        "type": "illegal_state_exception",
                        "reason": "Can't compute score on document as it doesn't match the query"
                    }
                ],
                "type": "search_phase_execution_exception",
                "reason": "all shards failed",
                "phase": "fetch",
                "grouped": true,
                "failed_shards":
                [
                    {
                        "shard": 0,
                        "index": "autosuggest--2024-02-28--21-04-35",
                        "node": "dxjnynMMR4iJYBcxUc9FIg",
                        "reason":
                        {
                            "type": "illegal_state_exception",
                            "reason": "Can't compute score on document as it doesn't match the query"
                        }
                    }
                ],
                "caused_by":
                {
                    "type": "illegal_state_exception",
                    "reason": "Can't compute score on document as it doesn't match the query",
                    "caused_by":
                    {
                        "type": "illegal_state_exception",
                        "reason": "Can't compute score on document as it doesn't match the query"
                    }
                }
            },
            "status": 500
        }

It looks like a bug to me.
Could you reproduce it with a minimalist script and test it on latest 8.x?

Just have more small query, if i remove track_scores will this give same result because i am using _score field in sort?

I don't know.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.