# What is the Top Children query for?

**URL:** <https://discuss.elastic.co/t/what-is-the-top-children-query-for/12905>\
**Category:** Elasticsearch\
**Created:** [July 23, 2013, 3:57pm UTC](https://discuss.elastic.co/t/what-is-the-top-children-query-for/12905 "2013-07-23T15:57:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [July 23, 2013, 3:57pm UTC](https://discuss.elastic.co/t/what-is-the-top-children-query-for/12905/1 "2013-07-23T15:57:00Z")

</div>

Hi guys. I've read the documentation for the Top Children query[1], but  
don't understand what the query's purpose is. Could anyone shed some light  
on when Top Children is useful?

Thanks!  
Nick

[1]  
[http://www.elasticsearch.org/guide/reference/query-dsl/top-children-query/](http://www.elasticsearch.org/guide/reference/query-dsl/top-children-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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [July 23, 2013, 9:05pm UTC](https://discuss.elastic.co/t/what-is-the-top-children-query-for/12905/2 "2013-07-23T21:05:10Z")

</div>

The top\_children query allows you to return documents based on matches on  
other documents. Lets say you index movies and subtitles  
as separate documents. A movie is a parent and a subtitle is a child  
document. The top\_children will allows you to return the movies based on  
query matches in the associated subtitle documents.

Most of times you want to use the has\_child query. The top\_children doesn't  
take into account all associated child docs, but only the top matching  
ones, it basically tries to match as much as child documents to return  
enough parent hits (based on from and size). The has\_child query takes into  
account all child document irrelevant of how many parent documents are  
requested. So the top\_children query is in most cases faster, but not  
accurate. The has\_child query is accurate, but usually slower then the  
has\_child query.

On 23 July 2013 17:57, Nick Hoffman [nick@deadorange.com](mailto:nick@deadorange.com) wrote:

> Hi guys. I've read the documentation for the Top Children query[1], but  
> don't understand what the query's purpose is. Could anyone shed some light  
> on when Top Children is useful?
> 
> Thanks!  
> Nick
> 
> [1]  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/top-children-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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:24am UTC](https://discuss.elastic.co/t/what-is-the-top-children-query-for/12905/3 "2017-07-06T02:24:56Z")

</div>


