# Query for nested objects count

**URL:** <https://discuss.elastic.co/t/query-for-nested-objects-count/19126>\
**Category:** Elasticsearch\
**Created:** [August 6, 2014, 8:34pm UTC](https://discuss.elastic.co/t/query-for-nested-objects-count/19126 "2014-08-06T20:34:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Correa](https://avatars.discourse-cdn.com/v4/letter/p/bb73d2/32.png) [@Paulo\_Correa](https://discuss.elastic.co/u/Paulo_Correa)\
**Post date:** [August 6, 2014, 8:34pm UTC](https://discuss.elastic.co/t/query-for-nested-objects-count/19126/1 "2014-08-06T20:34:29Z")

</div>

Hi,

I have a need to retrieve documents (of type "bucket") which have at least  
2 nested objects (of type "products") inside them (details of my mapping  
and documents are on the gist below).

> <https://gist.github.com/anonymous/4f06c9322186ce9d4708>

As far as I've searched, I did not find a way to accomplish this on a  
Elasticsearch (unless perhaps if I'd used parent/child for bucket/products,  
and used a "has child query" with "min\_children=2"), but I'd rather avoid  
changing my mapping if I can.

Does anybody know if it is possible?

_PS_: not really the same situation, but perhaps \*option number 2 \*from  
this answer would be a solution  
[http://stackoverflow.com/questions/19609498/elastic-search-order-by-count-of-nested-object](http://stackoverflow.com/questions/19609498/elastic-search-order-by-count-of-nested-object).  
Does anybody see another alternative?

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/9e3beb3b-7df0-432c-a32e-3317856d4080%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9e3beb3b-7df0-432c-a32e-3317856d4080%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:10am UTC](https://discuss.elastic.co/t/query-for-nested-objects-count/19126/2 "2017-07-06T01:10:20Z")

</div>


