Issue 1:
Elasticsearch version: Elasticsearch 2.3

JVM version: Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

OS version: Any

Description of the problem including expected versus actual behavior:

This only happens when search_type=dfs_query_then_fetch! Looks like the score that the explain object is returning is different than the actual score that it is being returned in the hit.

First, start elasticsearch 1.7 to verify that the explain was working fine. Do the following bulk operation:

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" }

Then, execute the following search operation:

POST /trial/_search?search_type=dfs_query_and_fetch&explain&size=1
{"query":{"multi_match":{"query":"mvd","fields":["city","cityAliases"]}}}

Verify that the score under explain is the same as the main score:

# 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)"
}
]
}
]
}
]
}
]
}
}

Now, do the same in Elasticsearch 2.3. Use the same bulk operation and query!

Verify that the score under explain is DIFFERENT as the main score. The score is 0.24285339 but the explain is giving 0.2417773. With larger datasets the difference between explain and the score can be bigger.

# 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": []
}
]
}
]
}
]
}
]
}
}

Issue 2:
provide a separate jar to permit to use java rest client with jest project (https://github.com/searchbox-io/Jest) and java api without include all elesticsearch and lucene as dependency