# Aggregation with matched nested objects

**URL:** <https://discuss.elastic.co/t/aggregation-with-matched-nested-objects/120791>\
**Category:** Elasticsearch\
**Created:** [February 21, 2018, 9:03am UTC](https://discuss.elastic.co/t/aggregation-with-matched-nested-objects/120791 "2018-02-21T09:03:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arkkanoid](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@arkkanoid](https://discuss.elastic.co/u/arkkanoid)\
**Post date:** [February 21, 2018, 9:03am UTC](https://discuss.elastic.co/t/aggregation-with-matched-nested-objects/120791/1 "2018-02-21T09:03:16Z")

</div>

Hi,  
I'm implementing a terms aggregation with a field in a nested object.  
What I expect is that the aggregation only takes the matched nested object, but it takes the whole document.  
I've seen a partial solution using a filter in the aggregation, but it's limited because I can only apply range, match or terms filters.  
There is another approach to get an aggregation with only the matched nested objects?

---

<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:** [March 21, 2018, 9:03am UTC](https://discuss.elastic.co/t/aggregation-with-matched-nested-objects/120791/2 "2018-03-21T09:03:50Z")

</div>

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