I want to get bucket for all my required values along with their count. I am doing that via terms aggregations. But somehow, the query only returns buckets that match some documents even though I set min_doc_count
to 0. See the query below:
POST myindex/_search
{
"size": 0,
"aggs":{
"matching_values_field1": {
"filter": {
"terms" : { "myfield" : ["1", "2", "3","100"]}
},
"aggs": {
"myfield" : {
"terms" : {
"field" : "myfield",
"min_doc_count": 0
}
}
}
}
}
}
Following is the response, where there is no bucket for value 100
. Any ideas?
"aggregations": {
"matching_values_1": {
"doc_count": 11,
"myfield": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 2,
"doc_count": 6
},
{
"key": 1,
"doc_count": 3
},
{
"key": 3,
"doc_count": 2
},
{
"key": 0,
"doc_count": 0
},
{
"key": 0.5,
"doc_count": 0
},
{
"key": 4,
"doc_count": 0
},
{
"key": 5,
"doc_count": 0
},
{
"key": 6,
"doc_count": 0
},
{
"key": 14,
"doc_count": 0
}
]
}
}
}