# Filtering root documents based on the nested document aggregation

**URL:** <https://discuss.elastic.co/t/filtering-root-documents-based-on-the-nested-document-aggregation/14509>\
**Category:** Elasticsearch\
**Created:** [November 21, 2013, 6:23am UTC](https://discuss.elastic.co/t/filtering-root-documents-based-on-the-nested-document-aggregation/14509 "2013-11-21T06:23:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sticky1\_2](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sticky1\_2](https://discuss.elastic.co/u/sticky1_2)\
**Post date:** [November 21, 2013, 6:23am UTC](https://discuss.elastic.co/t/filtering-root-documents-based-on-the-nested-document-aggregation/14509/1 "2013-11-21T06:23:49Z")

</div>

Elasticsearch with nested structure is really cool in designing complex  
data structures. There are ways I can sort the root document based on  
max,sum,min,average of the values of the nested document using nested  
sorting with different sort mode. However, I could not figure out if there  
are ways to filter root document based on max,sum,min,average of the values  
of nested document. My mapping and data is like this:  
[https://gist.github.com/7576821](https://gist.github.com/7576821) [https://gist.github.com/sticky1/7576821](https://gist.github.com/sticky1/7576821)

I would like to filter members based on aggregated value of amounts someway  
just like I can sort members based on aggregated value of amount. I also  
need to have nested filter to filter some of the amount objects in the  
aggregation.  
It looks like Elasticsearch currently does not support this. Is there any  
issues related to it or any proposed plan to have this in upcoming  
releases?

Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:05am UTC](https://discuss.elastic.co/t/filtering-root-documents-based-on-the-nested-document-aggregation/14509/2 "2017-07-06T02:05:47Z")

</div>


