We have an aggregation as follows:
{
"from": 0,
"size": 0,
"aggregations": {
"my_aggregation": {
"terms": {
"field": "SOME_FIELD",
"min_doc_count": 2
}
}
}
}
We use such a query to do some processing on the matched terms. We noticed that the aggregation is not returning any results initially:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 519088,
"max_score": 0.0,
"hits": []
},
"aggregations": {
"my_aggregation": {
"doc_count_error_upper_bound": 5,
"sum_other_doc_count": 16124,
"buckets": []
}
}
}
Through some experimentation, we ended up toying with size and setting it to a higher value:
{
"from": 0,
"size": 0,
"aggregations": {
"my_aggregation": {
"terms": {
"field": "SOME_FIELD",
"min_doc_count": 2,
"size": 100
}
}
}
}
Strangely enough, this request started returning some results:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 519088,
"max_score": 0.0,
"hits": []
},
"aggregations": {
"my_aggregation": {
"doc_count_error_upper_bound": 5,
"sum_other_doc_count": 15449,
"buckets": [
{
"key": "<HIDDEN VALUE>",
"doc_count": 3
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
},
{
"key": "<HIDDEN VALUE>",
"doc_count": 2
}
]
}
}
}
I'm struggling to understand the logic of this behaviour (using ES 5.4) so any help here in terms of what we're missing would be greatly appreciated.
Many thanks.
Cos