# Find parents with most number of children

**URL:** <https://discuss.elastic.co/t/find-parents-with-most-number-of-children/16951>\
**Category:** Elasticsearch\
**Created:** [April 11, 2014, 9:34am UTC](https://discuss.elastic.co/t/find-parents-with-most-number-of-children/16951 "2014-04-11T09:34:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ludwig\_Magnusson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ludwig_magnusson/32/1594_2.png) [@Ludwig\_Magnusson](https://discuss.elastic.co/u/Ludwig_Magnusson)\
**Post date:** [April 11, 2014, 9:34am UTC](https://discuss.elastic.co/t/find-parents-with-most-number-of-children/16951/1 "2014-04-11T09:34:22Z")

</div>

I have an index where the type evens are mapped to have the parent type  
user. I want to find out what users have the most number of event children.  
I have basically done this by searching the children using a terms facet  
with the term "\_parent". This tells me which user id have generated the  
most events and how many. The problem is that I want the full user  
document, not just the id. Is this possible to do in one query?

--  
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/cf63e0d6-1cbf-4a1f-8dd3-ebb85d946cb8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cf63e0d6-1cbf-4a1f-8dd3-ebb85d946cb8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 21, 2014, 12:06pm UTC](https://discuss.elastic.co/t/find-parents-with-most-number-of-children/16951/2 "2014-04-21T12:06:42Z")

</div>

Hey,

you would execute the facet query first and then execute a query to get all  
the documents, as you need the output of the first query as input for the  
second.

--Alex

On Fri, Apr 11, 2014 at 11:34 AM, Ludwig Magnusson \<  
[ludwig.magnusson@gmail.com](mailto:ludwig.magnusson@gmail.com)\> wrote:

> I have an index where the type evens are mapped to have the parent type  
> user. I want to find out what users have the most number of event children.  
> I have basically done this by searching the children using a terms facet  
> with the term "\_parent". This tells me which user id have generated the  
> most events and how many. The problem is that I want the full user  
> document, not just the id. Is this possible to do in one query?
> 
> --  
> 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/cf63e0d6-1cbf-4a1f-8dd3-ebb85d946cb8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cf63e0d6-1cbf-4a1f-8dd3-ebb85d946cb8%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/cf63e0d6-1cbf-4a1f-8dd3-ebb85d946cb8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/cf63e0d6-1cbf-4a1f-8dd3-ebb85d946cb8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGCwEM9Bi2W828n3w4jGTs0bqcVMi\_gbj6AXZpRvA2mexc%2B80g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9Bi2W828n3w4jGTs0bqcVMi_gbj6AXZpRvA2mexc%2B80g%40mail.gmail.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:34am UTC](https://discuss.elastic.co/t/find-parents-with-most-number-of-children/16951/3 "2017-07-06T01:34:37Z")

</div>


