# Aggregation on nested node and stats on parent fields

**URL:** <https://discuss.elastic.co/t/aggregation-on-nested-node-and-stats-on-parent-fields/107298>\
**Category:** Elasticsearch\
**Created:** [November 12, 2017, 11:29am UTC](https://discuss.elastic.co/t/aggregation-on-nested-node-and-stats-on-parent-fields/107298 "2017-11-12T11:29:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chandan\_GB](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@Chandan\_GB](https://discuss.elastic.co/u/Chandan_GB)\
**Post date:** [November 12, 2017, 11:29am UTC](https://discuss.elastic.co/t/aggregation-on-nested-node-and-stats-on-parent-fields/107298/1 "2017-11-12T11:29:33Z")

</div>

I am new to elasticsearch please help me

Please find the mapping so that I can explain what is the out put required.

PUT /myproject/contact/\_mapping  
{  
"contact": {  
"properties": {  
"emailid": {  
"type" :"text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"phonenumber": {  
"type" :"text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"personaladdress":{  
"type":"nested",  
"properties": {  
"city": {  
"type": "text",  
"fields":{  
"keyword": {  
"type": "keyword"  
}  
}  
}  
}  
}  
}  
}  
}

I am looking an aggregation query where it give the out put

City wise (nested doc) how many email / phone number we have

City | Email | Phone number |  
Bangalore | 50 | 30 |  
Another City | 10 | 5 |

---

<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:** [December 10, 2017, 11:29am UTC](https://discuss.elastic.co/t/aggregation-on-nested-node-and-stats-on-parent-fields/107298/2 "2017-12-10T11:29:33Z")

</div>

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