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

score and explanation for dfs queries don't match #15369

Closed
brwe opened this Issue Dec 10, 2015 · 7 comments

Comments

Projects
None yet
7 participants
@brwe
Contributor

brwe commented Dec 10, 2015

Tested 1.7 vs 2.1. The following example:

POST test/doc/1
{
  "text": "Score and explanation should match I think?"
}

POST test/doc/2
{
  "text": "Score and explanation did match in 1.7..."
}


GET test/_search?search_type=dfs_query_then_fetch&explain
{
  "query": {
    "match": {
      "text": "score"
    }
  }
}

for 1.7.0 returns:

{
   "took": 48,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 0.22295055,
      "hits": [
         {
            "_shard": 2,
            "_node": "5IoTIXdmROKObfLRmqCQYQ",
            "_index": "test",
            "_type": "doc",
            "_id": "1",
            "_score": 0.22295055,
            "_source": {
               "text": "Score and explanation should match I think?"
            },
            "_explanation": {
               "value": 0.22295056,
               "description": "weight(text:score in 0) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 0.22295056,
                     "description": "score(doc=0,freq=1.0), product of:",
                     "details": ```
         {
            "_shard": 2,
            "_node": "8AbQaexnTwKbvcL1Va4yfw",
            "_index": "test",
            "_type": "doc",
            "_id": "1",
            "_score": 0.22295055,
            "_source": {
               "text": "Score and explanation should match I think?"
            },
            "_explanation": {
               "value": 0.22295056,
               "description": "weight(text:score in 0) [PerFieldSimilarity], result of:",[
                        {
                           "value": 0.99999994,
                           "description": "queryWeight, product of:",
                           "details": [
                              {
                                 "value": 0.5945349,
                                 "description": "idf(docFreq=2, maxDocs=2)"
                              },
                              {
                                 "value": 1.681987,
                                 "description": "queryNorm"
                              }
                           ]
                        },
                        {
                           "value": 0.22295058,
                           "description": "fieldWeight in 0, product of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "tf(freq=1.0), with freq of:",
                                 "details": [
                                    {
                                       "value": 1,
                                       "description": "termFreq=1.0"
                                    }
                                 ]
                              },
                              {
                                 "value": 0.5945349,
                                 "description": "idf(docFreq=2, maxDocs=2)"
                              },
                              {
                                 "value": 0.375,
                                 "description": "fieldNorm(doc=0)"
                              }
                           ]
                        }
                     ]
                  }
               ]
            }
         },
         {
            "_shard": 3,
            "_node": "5IoTIXdmROKObfLRmqCQYQ",
            "_index": "test",
            "_type": "doc",
            "_id": "2",
            "_score": 0.22295055,
            "_source": {
               "text": "Score and explanation did match in 1.7..."
            },
            "_explanation": {
               "value": 0.22295056,
               "description": "weight(text:score in 0) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 0.22295056,
                     "description": "score(doc=0,freq=1.0), product of:",
                     "details": [
                        {
                           "value": 0.99999994,
                           "description": "queryWeight, product of:",
                           "details": [
                              {
                                 "value": 0.5945349,
                                 "description": "idf(docFreq=2, maxDocs=2)"
                              },
                              {
                                 "value": 1.681987,
                                 "description": "queryNorm"
                              }
                           ]
                        },
                        {
                           "value": 0.22295058,
                           "description": "fieldWeight in 0, product of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "tf(freq=1.0), with freq of:",
                                 "details": [
                                    {
                                       "value": 1,
                                       "description": "termFreq=1.0"
                                    }
                                 ]
                              },
                              {
                                 "value": 0.5945349,
                                 "description": "idf(docFreq=2, maxDocs=2)"
                              },
                              {
                                 "value": 0.375,
                                 "description": "fieldNorm(doc=0)"
                              }
                           ]
                        }
                     ]
                  }
               ]
            }
         }
      ]
   }
}

and in 2.1:

{
   "took": 46,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 0.22295055,
      "hits": [
         {
            "_shard": 2,
            "_node": "hcC0CtAfTSSILbEq32T_fw",
            "_index": "test",
            "_type": "doc",
            "_id": "2",
            "_score": 0.22295055,
            "_source": {
               "text": "Score and explanation did match in 1.7..."
            },
            "_explanation": {
               "value": 0.11506981,
               "description": "weight(text:score in 0) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 0.11506981,
                     "description": "fieldWeight in 0, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0",
                                 "details": []
                              }
                           ]
                        },
                        {
                           "value": 0.30685282,
                           "description": "idf(docFreq=1, maxDocs=1)",
                           "details": []
                        },
                        {
                           "value": 0.375,
                           "description": "fieldNorm(doc=0)",
                           "details": []
                        }
                     ]
                  }
               ]
            }
         },
         {
            "_shard": 3,
            "_node": "hcC0CtAfTSSILbEq32T_fw",
            "_index": "test",
            "_type": "doc",
            "_id": "1",
            "_score": 0.22295055,
            "_source": {
               "text": "Score and explanation should match I think?"
            },
            "_explanation": {
               "value": 0.11506981,
               "description": "weight(text:score in 0) [PerFieldSimilarity], result of:",
               "details": [
                  {
                     "value": 0.11506981,
                     "description": "fieldWeight in 0, product of:",
                     "details": [
                        {
                           "value": 1,
                           "description": "tf(freq=1.0), with freq of:",
                           "details": [
                              {
                                 "value": 1,
                                 "description": "termFreq=1.0",
                                 "details": []
                              }
                           ]
                        },
                        {
                           "value": 0.30685282,
                           "description": "idf(docFreq=1, maxDocs=1)",
                           "details": []
                        },
                        {
                           "value": 0.375,
                           "description": "fieldNorm(doc=0)",
                           "details": []
                        }
                     ]
                  }
               ]
            }
         }
      ]
   }
}

@rjernst

This comment has been minimized.

Member

rjernst commented Dec 10, 2015

@brwe Can you explain what "doesn't match"? The explanations and scores look the same to me, but maybe I'm just not seeing it in the page-of-json. :)

@jpountz

This comment has been minimized.

Contributor

jpountz commented Dec 10, 2015

@rjernst I wondered the same but I think I see it now: in the 2.1 output _score is different from _explanation.value.

@clintongormley

This comment has been minimized.

Member

clintongormley commented Dec 11, 2015

Related to #2612?

@sylvinus

This comment has been minimized.

Contributor

sylvinus commented Jan 7, 2016

I have the same issue. Any clue on how to fix or a workaround?

@gmoskovicz

This comment has been minimized.

Contributor

gmoskovicz commented May 6, 2016

I can confirm that this still happens in 2.3.

Looks like when using dfs, the explain ignores the fact that we need to merge the results from the information of the shards. The explain value when using dfs is the same score that you get if you do not use dfs, but instead just query then fetch.

@gmoskovicz

This comment has been minimized.

Contributor

gmoskovicz commented May 6, 2016

        "_score": 0.2202036,     <---------- dfs score
        "_source": {
          "city": "montevideo",
          "cityAliases": "mvd"
        },
        "_explanation": {
          "value": 0.2417773,       <----------- the score for non-dfg
          "description": "max of:",
          "details": [
            {
              "value": 0.2417773,
@gmoskovicz

This comment has been minimized.

Contributor

gmoskovicz commented May 6, 2016

Are there any test cases that verifies that the explanation root value is equals to the hit score?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment