Query_string with wildcard does not return an explanation (explain=true)

Hello,
The following query_string does not return the explanation of the matching (explain=true)

GET myindex/_search?explain=true
{
  "query": {
    "nested": {
            "path": "entity",
            "query": {
                "bool": {
                    "must": [
                      { 
                        "query_string": {
                          "query": "entity.metadata.tags.tagName:football*"
                        }
                      }
                    ],
                    "filter": {
                        "term": {
                            "entity.contentType.keyword": "blog"
                        }
                    }
                }
            },
            "score_mode": "max"
        }
  } 
}

This query returns a score of 1.0 with the following explanation

"_explanation" : {
          "value" : 1.0,
          "description" : "Score based on 1 child docs in range from 36 to 36, best match:",
          "details" : [
            {
              "value" : 1.0,
              "description" : "sum of:",
              "details" : [
                {
                  "value" : 1.0,
                  "description" : "entity.metadata.tags.tagName:football*",
                  "details" : [ ]
                },
                {
                  "value" : 0.0,
                  "description" : "match on required clause, product of:",
                  "details" : [
                    {
                      "value" : 0.0,
                      "description" : "# clause",
                      "details" : [ ]
                    },
                    {
                      "value" : 1.0,
                      "description" : "entity.contentType.keyword:blog",
                      "details" : [ ]
                    }
                  ]
                }
              ]
            }
          ]
        }

while the same query without the wildcard does not return a score of 1.0 and in this case we get an explanation
Query without wildcard:

GET myindex/_search?explain=true
{
  "query": {
    "nested": {
            "path": "entity",
            "query": {
                "bool": {
                    "must": [
                      { 
                        "query_string": {
                          "query": "entity.metadata.tags.tagName:football"
                        }
                      }
                    ],
                    "filter": {
                        "term": {
                            "entity.contentType.keyword": "blog"
                        }
                    }
                }
            },
            "score_mode": "max"
        }
  } 
}

Explanation response:

"_explanation" : {
          "value" : 0.10536051,
          "description" : "Score based on 1 child docs in range from 36 to 36, best match:",
          "details" : [
            {
              "value" : 0.10536051,
              "description" : "sum of:",
              "details" : [
                {
                  "value" : 0.10536051,
                  "description" : "weight(entity.metadata.tags.tagName:football in 36) [PerFieldSimilarity], result of:",
                  "details" : [
                    {
                      "value" : 0.10536051,
                      "description" : "score(freq=1.0), computed as boost * idf * tf from:",
                      "details" : [
                        {
                          "value" : 2.2,
                          "description" : "boost",
                          "details" : [ ]
                        },
                        {
                          "value" : 0.105360515,
                          "description" : "idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
                          "details" : [
                            {
                              "value" : 4,
                              "description" : "n, number of documents containing term",
                              "details" : [ ]
                            },
                            {
                              "value" : 4,
                              "description" : "N, total number of documents with field",
                              "details" : [ ]
                            }
                          ]
                        },
                        {
                          "value" : 0.45454544,
                          "description" : "tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:",
                          "details" : [
                            {
                              "value" : 1.0,
                              "description" : "freq, occurrences of term within document",
                              "details" : [ ]
                            },
                            {
                              "value" : 1.2,
                              "description" : "k1, term saturation parameter",
                              "details" : [ ]
                            },
                            {
                              "value" : 0.75,
                              "description" : "b, length normalization parameter",
                              "details" : [ ]
                            },
                            {
                              "value" : 1.0,
                              "description" : "dl, length of field",
                              "details" : [ ]
                            },
                            {
                              "value" : 1.0,
                              "description" : "avgdl, average length of field",
                              "details" : [ ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "value" : 0.0,
                  "description" : "match on required clause, product of:",
                  "details" : [
                    {
                      "value" : 0.0,
                      "description" : "# clause",
                      "details" : [ ]
                    },
                    {
                      "value" : 1.0,
                      "description" : "entity.contentType.keyword:blog",
                      "details" : [ ]
                    }
                  ]
                }
              ]
            }
          ]
        }

Which is the difference between both queries? I think both responses should be the same with the same score. Apart from that, when I add the '*' to the value, I don't get a real explanation of the response.

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