Wrong doc_count values for all buckets when using the 'missing' parameter in terms aggr!

We're trying to use the new 'missing' param in terms aggr in both ES 2.1 and 2.11 clusters and the doc_count values returned (not just for the 'missing' documents) are different compared to the same aggr without the missing param!

I would expect all the buckets to be the same doc_count values and just an additional bucket with the doc_count of those documents without this field... I can't explain why adding this missing param is returning different values for the rest of the buckets...

Any ideas? Seems like a serious bug...

(I tried to create a test index with just 5 documents and it seems to work ok there... but we have the problem with bigger indexes even an index with 3,000 docs)

{
"size": 0,
"aggs": {
"2": {
"terms": {
"field": "fieldname",
"size": 100,
"missing": "Test"
}
}
}
}

1 Like

I think you are seeing one of the bugs that this PR fixes: https://github.com/elastic/elasticsearch/pull/15746

For now you should be able to work around this by adding "execution_mode": "global_ordinals" to your terms aggregation,

Let me know if that workaround fixes your issue.

Hi,

Just tried this and it gave me an error...

    "type": "search_parse_exception",
    "reason": "Unknown key for a VALUE_STRING in [2]: [execution_mode]."

Sorry I got the wrong name for the setting, it should be "execution_hint": "global_ordinals". see here for more details on this setting

Thanks! that seems to work now...