# Doc\_count is not returning for the index in "multi index approach" if no data present in that index

**URL:** <https://discuss.elastic.co/t/doc-count-is-not-returning-for-the-index-in-multi-index-approach-if-no-data-present-in-that-index/247539>\
**Category:** Elasticsearch\
**Created:** [September 4, 2020, 12:56pm UTC](https://discuss.elastic.co/t/doc-count-is-not-returning-for-the-index-in-multi-index-approach-if-no-data-present-in-that-index/247539 "2020-09-04T12:56:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muna](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@Muna](https://discuss.elastic.co/u/Muna)\
**Post date:** [September 4, 2020, 12:56pm UTC](https://discuss.elastic.co/t/doc-count-is-not-returning-for-the-index-in-multi-index-approach-if-no-data-present-in-that-index/247539/1 "2020-09-04T12:56:03Z")

</div>

Hi,

In case of multi Index approach, if the data for the specific index is not present in the Elastic [index is empty]. while doing the aggregation in multi index it should return at least doc\_count as '0' .

_tried solution_ :- have tried giving "min\_doc\_count": 0 in aggregation . but still it's not returning anything for the index.

_Query for reference_ :-

GET index1,index2,index3/\_search  
{  
"from": 0,  
"size": 39,  
"query": {  
"bool" : {  
"should": [  
{  
"bool": {  
"must": [  
{  
"match": {  
"id1": 0  
}  
}  
],  
"filter": [  
{  
"terms": {  
"\_index": [  
"index1"  
]  
}  
}  
]  
}  
},  
{  
"bool": {  
"filter": [  
{  
"terms": {  
"\_index": [  
"index2"  
]  
}  
}  
]  
}  
},  
{  
"bool": {  
"filter": [  
{  
"terms": {  
"\_index": [  
"index3"  
]  
}  
}  
]  
}  
}  
]  
}  
},  
"sort":{"\_index":{"order":"asc"}},  
"aggs":{"index1,index2,index3":{"terms":{"field": "\_index","min\_doc\_count": 0, "size":6,"order": {"\_key": "asc"}}}}  
}

Issue :-

in above query suppose the data present for all index except " **index1**"  
while returning the data it's returning doc\_count for all except " **index1**"

but we are expecting the index1 should return doc\_count : 0 event though no data present in it .

please advice any solution for this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 2, 2020, 12:56pm UTC](https://discuss.elastic.co/t/doc-count-is-not-returning-for-the-index-in-multi-index-approach-if-no-data-present-in-that-index/247539/2 "2020-10-02T12:56:12Z")

</div>

Closed on October 2, 2020, 12:56pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
