What makes you think that only the local maxDoc is taken into account for scoring? I tried to build a quick recreation using Sense and things seem to work just fine:
DELETE test
PUT test/test/1
{
"foo": "bar"
}
PUT test/test/2
{
"foo": "bar"
}
PUT test/test/3
{
}
GET test/_search?search_type=dfs_query_then_fetch
{
"explain": true,
"query": {
"term": {
"foo": {
"value": "bar"
}
}
}
}
returns
{
"took": 11,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_shard": 2,
"_node": "ws4GOXSzRPy0Jg6-Yb0C6g",
"_index": "test",
"_type": "test",
"_id": "2",
"_score": 1,
"_source": {
"foo": "bar"
},
"_explanation": {
"value": 1,
"description": "weight(foo:bar in 0) [PerFieldSimilarity], result of:",
"details": [
{
"value": 1,
"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": 1,
"description": "idf(docFreq=2, maxDocs=3)",
"details": []
},
{
"value": 1,
"description": "fieldNorm(doc=0)",
"details": []
}
]
}
]
}
},
{
"_shard": 3,
"_node": "ws4GOXSzRPy0Jg6-Yb0C6g",
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 1,
"_source": {
"foo": "bar"
},
"_explanation": {
"value": 1,
"description": "weight(foo:bar in 0) [PerFieldSimilarity], result of:",
"details": [
{
"value": 1,
"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": 1,
"description": "idf(docFreq=2, maxDocs=3)",
"details": []
},
{
"value": 1,
"description": "fieldNorm(doc=0)",
"details": []
}
]
}
]
}
}
]
}
}
The interesting part is that the idf calculation reports maxDoc=3 even though my documents are on different shards.
The only limitation I'm aware of is if you have more than 2B documents in your index, elasticsearch will use maxDoc=2B since Lucene stores maxDoc on an integer.