# Aggregation on terms with Nested Property

**URL:** https://discuss.elastic.co/t/aggregation-on-terms-with-nested-property/116063
**Category:** Elasticsearch
**Created:** [January 18, 2018, 1:30pm UTC](https://discuss.elastic.co/t/aggregation-on-terms-with-nested-property/116063 "2018-01-18T13:30:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mongesh\_madhavan](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mongesh\_madhavan](https://discuss.elastic.co/u/mongesh_madhavan)
#### Post date: [January 18, 2018, 1:30pm UTC](https://discuss.elastic.co/t/aggregation-on-terms-with-nested-property/116063/1 "2018-01-18T13:30:32Z")

</div>

i have below json  
attrib is nested property  
{

attrib{  
color:blue,  
categoryId: 1  
},  
attrib{  
color:red,  
categoryid: 2}  
}  
When querying around categoryId : 1 or 2 and get correct result  
but while Aggregating on term, I want it to be restricted on categoryId.  
How to do that. I tried Nested Aggregation with filter but no luck there.

---

<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: [February 15, 2018, 1:30pm UTC](https://discuss.elastic.co/t/aggregation-on-terms-with-nested-property/116063/2 "2018-02-15T13:30:39Z")

</div>

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