# Do Count Aggregation on Missing Fiels

**URL:** <https://discuss.elastic.co/t/do-count-aggregation-on-missing-fiels/69628>\
**Category:** Elasticsearch\
**Created:** [December 21, 2016, 3:19am UTC](https://discuss.elastic.co/t/do-count-aggregation-on-missing-fiels/69628 "2016-12-21T03:19:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krmathieu](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@krmathieu](https://discuss.elastic.co/u/krmathieu)\
**Post date:** [December 21, 2016, 3:19am UTC](https://discuss.elastic.co/t/do-count-aggregation-on-missing-fiels/69628/1 "2016-12-21T03:19:37Z")

</div>

I have a requirement to generate a report of the counts of documents in my index that do not have values for a list of specific fields and here is what I have so far:

[http://my.host.name:9200/myIndex/myType/\_count?pretty=true](http://my.host.name:9200/myIndex/myType/_count?pretty=true)  
{  
"query": {  
"bool": {  
"must\_not": {  
"exists": {  
"field": "event\_name"  
}  
}  
}  
}  
}

This works as expected and I just get the count for those documents that are missing the event\_name. The problem is I have like 25 fields that I am interested in and I am not sure how to wire up an aggregation to do the same thing for all 25 fields with a single query. Is it possible to do that with the \_count end point and an aggregation? If so, can someone provide a sample to get me started? Right now I am executing 25 separate queries in succession and that is taking about 45 seconds to run given the number of documents I am running against (70+ million) and I would like to speed that up since I want to spit out the results on a Web page. Thanks.

Kevin

---

<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:** [January 18, 2017, 3:20am UTC](https://discuss.elastic.co/t/do-count-aggregation-on-missing-fiels/69628/2 "2017-01-18T03:20:01Z")

</div>

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