# Count for Nested array objects

**URL:** https://discuss.elastic.co/t/count-for-nested-array-objects/19653
**Category:** Elasticsearch
**Created:** [September 6, 2014, 7:16pm UTC](https://discuss.elastic.co/t/count-for-nested-array-objects/19653 "2014-09-06T19:16:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xfzhang15](https://avatars.discourse-cdn.com/v4/letter/x/dec6dc/32.png) [@xfzhang15](https://discuss.elastic.co/u/xfzhang15)
#### Post date: [September 6, 2014, 7:16pm UTC](https://discuss.elastic.co/t/count-for-nested-array-objects/19653/1 "2014-09-06T19:16:28Z")

</div>

Hi,

I was wondering if there's a way return count based on nested array items, instead of Document count.

e.g:

So if I have something like this:

obj : {  
array : [{  
id: 1,  
group: A  
},  
{  
id: 2,  
group: A  
},  
{  
id: 3,  
group: B  
}]  
}

And I want to count number of items with group=A, it should return 2, instead of 1 (the Doc count)

Is there a way of doing this?

Thanks

---

<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, 1:03am UTC](https://discuss.elastic.co/t/count-for-nested-array-objects/19653/2 "2017-07-06T01:03:58Z")

</div>


