<p dir="auto"><strong>Elasticsearch version</strong>: <code class="notranslate">Elasticsearch 2.3</code></p>
<p dir="auto"><strong>JVM version</strong>: <code class="notranslate">Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)</code></p>
<p dir="auto"><strong>OS version</strong>: Any</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:</p>
<p dir="auto">This only happens when <code class="notranslate">search_type=dfs_query_then_fetch</code>! Looks like the score that the explain object is returning is different than the actual score that it is being returned in the hit.</p>
<p dir="auto">First, start elasticsearch 1.7 to verify that the <code class="notranslate">explain</code> was working fine. Do the following bulk operation:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="POST /_bulk
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }
{ &quot;index&quot;: { &quot;_index&quot;: &quot;trial&quot;, &quot;_type&quot;: &quot;type&quot; } }
{ &quot;city&quot;: &quot;montevideo&quot;, &quot;cityAliases&quot;: &quot;mvd&quot; }"><pre class="notranslate"><code class="notranslate">POST /_bulk
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
{ "index": { "_index": "trial", "_type": "type" } }
{ "city": "montevideo", "cityAliases": "mvd" }
</code></pre></div>
<p dir="auto">Then, execute the following search operation:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="POST /trial/_search?search_type=dfs_query_and_fetch&amp;explain&amp;size=1
{&quot;query&quot;:{&quot;multi_match&quot;:{&quot;query&quot;:&quot;mvd&quot;,&quot;fields&quot;:[&quot;city&quot;,&quot;cityAliases&quot;]}}}"><pre class="notranslate"><code class="notranslate">POST /trial/_search?search_type=dfs_query_and_fetch&amp;explain&amp;size=1
{"query":{"multi_match":{"query":"mvd","fields":["city","cityAliases"]}}}
</code></pre></div>
<p dir="auto">Verify that the score under explain is the same as the main score:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Result - Main Score:  0.24285339, _explanation Score: 0.24285339
{
  &quot;_shard&quot;: 0,
  &quot;_node&quot;: &quot;bPFH3L1nT9-BTOKWyd-i0Q&quot;,
  &quot;_index&quot;: &quot;trial&quot;,
  &quot;_type&quot;: &quot;type&quot;,
  &quot;_id&quot;: &quot;AVSGJuxrGCZTdIeL7K4h&quot;,
  &quot;_score&quot;: 0.24285339,
  &quot;_source&quot;: {
    &quot;city&quot;: &quot;montevideo&quot;,
    &quot;cityAliases&quot;: &quot;mvd&quot;
  },
  &quot;_explanation&quot;: {
    &quot;value&quot;: 0.24285339,
    &quot;description&quot;: &quot;max of:&quot;,
    &quot;details&quot;: [
      {
        &quot;value&quot;: 0.24285339,
        &quot;description&quot;: &quot;weight(cityAliases:mvd in 0) [PerFieldSimilarity], result of:&quot;,
        &quot;details&quot;: [
          {
            &quot;value&quot;: 0.24285339,
            &quot;description&quot;: &quot;score(doc=0,freq=1.0), product of:&quot;,
            &quot;details&quot;: [
              {
                &quot;value&quot;: 0.26398334,
                &quot;description&quot;: &quot;queryWeight, product of:&quot;,
                &quot;details&quot;: [
                  {
                    &quot;value&quot;: 0.9199573,
                    &quot;description&quot;: &quot;idf(docFreq=12, maxDocs=12)&quot;
                  },
                  {
                    &quot;value&quot;: 0.28695172,
                    &quot;description&quot;: &quot;queryNorm&quot;
                  }
                ]
              },
              {
                &quot;value&quot;: 0.9199573,
                &quot;description&quot;: &quot;fieldWeight in 0, product of:&quot;,
                &quot;details&quot;: [
                  {
                    &quot;value&quot;: 1,
                    &quot;description&quot;: &quot;tf(freq=1.0), with freq of:&quot;,
                    &quot;details&quot;: [
                      {
                        &quot;value&quot;: 1,
                        &quot;description&quot;: &quot;termFreq=1.0&quot;
                      }
                    ]
                  },
                  {
                    &quot;value&quot;: 0.9199573,
                    &quot;description&quot;: &quot;idf(docFreq=12, maxDocs=12)&quot;
                  },
                  {
                    &quot;value&quot;: 1,
                    &quot;description&quot;: &quot;fieldNorm(doc=0)&quot;
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}"><pre class="notranslate"><code class="notranslate"># Result - Main Score:  0.24285339, _explanation Score: 0.24285339
{
  "_shard": 0,
  "_node": "bPFH3L1nT9-BTOKWyd-i0Q",
  "_index": "trial",
  "_type": "type",
  "_id": "AVSGJuxrGCZTdIeL7K4h",
  "_score": 0.24285339,
  "_source": {
    "city": "montevideo",
    "cityAliases": "mvd"
  },
  "_explanation": {
    "value": 0.24285339,
    "description": "max of:",
    "details": [
      {
        "value": 0.24285339,
        "description": "weight(cityAliases:mvd in 0) [PerFieldSimilarity], result of:",
        "details": [
          {
            "value": 0.24285339,
            "description": "score(doc=0,freq=1.0), product of:",
            "details": [
              {
                "value": 0.26398334,
                "description": "queryWeight, product of:",
                "details": [
                  {
                    "value": 0.9199573,
                    "description": "idf(docFreq=12, maxDocs=12)"
                  },
                  {
                    "value": 0.28695172,
                    "description": "queryNorm"
                  }
                ]
              },
              {
                "value": 0.9199573,
                "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.9199573,
                    "description": "idf(docFreq=12, maxDocs=12)"
                  },
                  {
                    "value": 1,
                    "description": "fieldNorm(doc=0)"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}
</code></pre></div>
<p dir="auto">Now, do the same in Elasticsearch 2.3.  Use the same bulk operation and query!</p>
<p dir="auto">Verify that the score under explain is <strong>DIFFERENT</strong> as the main score. The score is <code class="notranslate">0.24285339</code> but the explain is giving <code class="notranslate">0.2417773</code>. With larger datasets the difference between explain and the score can be bigger.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Result - Main Score:  0.24285339, _explanation Score: 0.2417773
{
  &quot;_shard&quot;: 1,
  &quot;_node&quot;: &quot;CY8y3EdDQyWmUkB9oB3MgQ&quot;,
  &quot;_index&quot;: &quot;trial&quot;,
  &quot;_type&quot;: &quot;type&quot;,
  &quot;_id&quot;: &quot;AVSGKy64GyfPh09elcKQ&quot;,
  &quot;_score&quot;: 0.24285339,
  &quot;_source&quot;: {
    &quot;city&quot;: &quot;montevideo&quot;,
    &quot;cityAliases&quot;: &quot;mvd&quot;
  },
  &quot;_explanation&quot;: {
    &quot;value&quot;: 0.2417773,
    &quot;description&quot;: &quot;max of:&quot;,
    &quot;details&quot;: [
      {
        &quot;value&quot;: 0.2417773,
        &quot;description&quot;: &quot;weight(cityAliases:mvd in 0) [PerFieldSimilarity], result of:&quot;,
        &quot;details&quot;: [
          {
            &quot;value&quot;: 0.2417773,
            &quot;description&quot;: &quot;score(doc=0,freq=1.0), product of:&quot;,
            &quot;details&quot;: [
              {
                &quot;value&quot;: 0.3394233,
                &quot;description&quot;: &quot;queryWeight, product of:&quot;,
                &quot;details&quot;: [
                  {
                    &quot;value&quot;: 0.71231794,
                    &quot;description&quot;: &quot;idf(docFreq=3, maxDocs=3)&quot;,
                    &quot;details&quot;: []
                  },
                  {
                    &quot;value&quot;: 0.47650534,
                    &quot;description&quot;: &quot;queryNorm&quot;,
                    &quot;details&quot;: []
                  }
                ]
              },
              {
                &quot;value&quot;: 0.71231794,
                &quot;description&quot;: &quot;fieldWeight in 0, product of:&quot;,
                &quot;details&quot;: [
                  {
                    &quot;value&quot;: 1,
                    &quot;description&quot;: &quot;tf(freq=1.0), with freq of:&quot;,
                    &quot;details&quot;: [
                      {
                        &quot;value&quot;: 1,
                        &quot;description&quot;: &quot;termFreq=1.0&quot;,
                        &quot;details&quot;: []
                      }
                    ]
                  },
                  {
                    &quot;value&quot;: 0.71231794,
                    &quot;description&quot;: &quot;idf(docFreq=3, maxDocs=3)&quot;,
                    &quot;details&quot;: []
                  },
                  {
                    &quot;value&quot;: 1,
                    &quot;description&quot;: &quot;fieldNorm(doc=0)&quot;,
                    &quot;details&quot;: []
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}"><pre class="notranslate"><code class="notranslate"># Result - Main Score:  0.24285339, _explanation Score: 0.2417773
{
  "_shard": 1,
  "_node": "CY8y3EdDQyWmUkB9oB3MgQ",
  "_index": "trial",
  "_type": "type",
  "_id": "AVSGKy64GyfPh09elcKQ",
  "_score": 0.24285339,
  "_source": {
    "city": "montevideo",
    "cityAliases": "mvd"
  },
  "_explanation": {
    "value": 0.2417773,
    "description": "max of:",
    "details": [
      {
        "value": 0.2417773,
        "description": "weight(cityAliases:mvd in 0) [PerFieldSimilarity], result of:",
        "details": [
          {
            "value": 0.2417773,
            "description": "score(doc=0,freq=1.0), product of:",
            "details": [
              {
                "value": 0.3394233,
                "description": "queryWeight, product of:",
                "details": [
                  {
                    "value": 0.71231794,
                    "description": "idf(docFreq=3, maxDocs=3)",
                    "details": []
                  },
                  {
                    "value": 0.47650534,
                    "description": "queryNorm",
                    "details": []
                  }
                ]
              },
              {
                "value": 0.71231794,
                "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.71231794,
                    "description": "idf(docFreq=3, maxDocs=3)",
                    "details": []
                  },
                  {
                    "value": 1,
                    "description": "fieldNorm(doc=0)",
                    "details": []
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}
</code></pre></div>
<p dir="auto">provide a separate jar to permit to use java rest client with jest project (<a href="https://github.com/searchbox-io/Jest">https://github.com/searchbox-io/Jest</a>) and java api without include all elesticsearch and lucene as dependency</p>