# Nested Aggregations

**URL:** https://discuss.elastic.co/t/nested-aggregations/21073
**Category:** Elasticsearch
**Created:** [December 4, 2014, 3:13am UTC](https://discuss.elastic.co/t/nested-aggregations/21073 "2014-12-04T03:13:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kazoompa\_3](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kazoompa\_3](https://discuss.elastic.co/u/kazoompa_3)
#### Post date: [December 4, 2014, 3:13am UTC](https://discuss.elastic.co/t/nested-aggregations/21073/1 "2014-12-04T03:13:57Z")

</div>

Hi,

I have two queries with identical nested aggregations using _min\_doc\_count_ _=  
0_ option. The only difference is in the queries, first query is a  
_match\_all()_ and the other a filtered query. The filtered query's  
aggregations miss bucket keys here and there! I was expecting an exact  
number of aggregation buckets with expected different counts. In the  
documentation [http://is.gd/Mvueh1](http://is.gd/Mvueh1) there are notes about possible inaccuracy  
of min\_doc\_count, what I miss to understand is why the _match\_all()_ query  
doesn't have this problem.

Below is an example of my two responses:

This is the reponse for _match\_all()_ query:  
"Sociodemographic\_economic\_characteristics-und" : {  
"buckets" : [ {  
"key" : "Age",  
"doc\_count" : 30  
}, {  
"key" : "Birth\_place",  
"doc\_count" : 4  
}, {  
"key" : "Education",  
"doc\_count" : 5  
}, {  
"key" : "Ethnic\_race\_religion",  
"doc\_count" : 0  
}, {  
"key" : "Family\_hh\_struct",  
"doc\_count" : 22  
}, {  
"key" : "Income",  
"doc\_count" : 5  
}, {  
"key" : "Labour\_retirement",  
"doc\_count" : 9  
}, {  
"key" : "Language",  
"doc\_count" : 2  
}, {  
"key" : "Marital\_status",  
"doc\_count" : 31  
}, {  
"key" : "Other\_sociodemogr\_chars",  
"doc\_count" : 0  
}, {  
"key" : "Residence",  
"doc\_count" : 33  
}, {  
"key" : "Sex",  
"doc\_count" : 11  
} ]  
}

This is the response for the fitlered query:

"attributes-Mlstr\_area\_\_Sociodemographic\_economic\_characteristics-und" : {  
"buckets" : [ {  
"key" : "Age",  
"doc\_count" : 0  
}, {  
"key" : "Birth\_place",  
"doc\_count" : 0  
}, {  
"key" : "Education",  
"doc\_count" : 0  
}, {  
"key" : "Ethnic\_race\_religion",  
"doc\_count" : 0  
}, {  
"key" : "Family\_hh\_struct",  
"doc\_count" : 0  
}, {  
"key" : "Income",  
"doc\_count" : 0  
}, {  
"key" : "Labour\_retirement",  
"doc\_count" : 0  
}, {  
"key" : "Language",  
"doc\_count" : 2  
}, {  
"key" : "Marital\_status",  
"doc\_count" : 0  
}, {  
"key" : "Residence",  
"doc\_count" : 0  
}, {  
"key" : "Sex",  
"doc\_count" : 0  
} ]  
}

The missing bucket is for key _Other\_sociodemogr\_chars_.

Any insight is greatly appreciated.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f5d1f871-1fe2-405f-9ea5-03725a0b6dbd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f5d1f871-1fe2-405f-9ea5-03725a0b6dbd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 12:46am UTC](https://discuss.elastic.co/t/nested-aggregations/21073/2 "2017-07-06T00:46:04Z")

</div>


