# Nested aggregation with filter on bucket level

**URL:** <https://discuss.elastic.co/t/nested-aggregation-with-filter-on-bucket-level/20989>\
**Category:** Elasticsearch\
**Created:** [November 29, 2014, 7:45pm UTC](https://discuss.elastic.co/t/nested-aggregation-with-filter-on-bucket-level/20989 "2014-11-29T19:45:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kresimir\_Slugan](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@Kresimir\_Slugan](https://discuss.elastic.co/u/Kresimir_Slugan)\
**Post date:** [November 29, 2014, 7:45pm UTC](https://discuss.elastic.co/t/nested-aggregation-with-filter-on-bucket-level/20989/1 "2014-11-29T19:45:26Z")

</div>

Hi,

Taking the basic example from official  
documentation [http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/nested-aggregation.html](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/nested-aggregation.html)

How would you write a query that gets you average number of stars for  
specific month (not for all months). I guess month filter needs to be  
applied for one of the aggs there. I have tried to add filters to  
"by\_month" and "comments" parts but both didn't work.

Cheers.

--  
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/6cd318a8-cbdb-45b8-9859-c4c79fc60566%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6cd318a8-cbdb-45b8-9859-c4c79fc60566%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:47am UTC](https://discuss.elastic.co/t/nested-aggregation-with-filter-on-bucket-level/20989/2 "2017-07-06T00:47:03Z")

</div>


