# Count number for nested array objects

**URL:** https://discuss.elastic.co/t/count-number-for-nested-array-objects/19663
**Category:** Elasticsearch
**Created:** [September 8, 2014, 4:10pm UTC](https://discuss.elastic.co/t/count-number-for-nested-array-objects/19663 "2014-09-08T16:10:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aiayumi](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@aiayumi](https://discuss.elastic.co/u/aiayumi)
#### Post date: [September 8, 2014, 4:10pm UTC](https://discuss.elastic.co/t/count-number-for-nested-array-objects/19663/1 "2014-09-08T16:10:06Z")

</div>

Hi,

I was wondering if there's a way return count based on the number of 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

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/794e544a-f494-4c3e-b2ba-10069bce9a26%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/794e544a-f494-4c3e-b2ba-10069bce9a26%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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-number-for-nested-array-objects/19663/2 "2017-07-06T01:03:53Z")

</div>


