# Using facets/aggretagions on parent document, queried by TopChildren

**URL:** <https://discuss.elastic.co/t/using-facets-aggretagions-on-parent-document-queried-by-topchildren/19087>\
**Category:** Elasticsearch\
**Created:** [August 5, 2014, 8:11am UTC](https://discuss.elastic.co/t/using-facets-aggretagions-on-parent-document-queried-by-topchildren/19087 "2014-08-05T08:11:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam\_porat](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@adam\_porat](https://discuss.elastic.co/u/adam_porat)\
**Post date:** [August 5, 2014, 8:11am UTC](https://discuss.elastic.co/t/using-facets-aggretagions-on-parent-document-queried-by-topchildren/19087/1 "2014-08-05T08:11:01Z")

</div>

Hi,

The TopChildren query works with an estimated hit size, and the  
TotalHits might be incorrect if there are more child docs matching the  
required hits.  
How does that affect facets or aggregations defined on the parent  
document? Would their count might be likewise be incorrent? Or would they  
cause the TopChildren to actually expand to look for all possible children?

Thank you.

--  
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/f2a87846-64ab-4786-ad91-305b197152c1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f2a87846-64ab-4786-ad91-305b197152c1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![adam\_porat](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@adam\_porat](https://discuss.elastic.co/u/adam_porat)\
**Post date:** [August 14, 2014, 12:28pm UTC](https://discuss.elastic.co/t/using-facets-aggretagions-on-parent-document-queried-by-topchildren/19087/2 "2014-08-14T12:28:25Z")

</div>

I will answer myself:  
The facets are counted in relation to the total\_hits in the response. This  
is true just as well when using TopChildren.

בתאריך יום שלישי, 5 באוגוסט 2014 11:11:02 UTC+3, מאת Adam Porat:

> Hi,
> 
> The TopChildren query works with an estimated hit size, and the  
> TotalHits might be incorrect if there are more child docs matching the  
> required hits.  
> How does that affect facets or aggregations defined on the parent  
> document? Would their count might be likewise be incorrent? Or would they  
> cause the TopChildren to actually expand to look for all possible children?
> 
> Thank you.

--  
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/0d330bf6-235d-4895-8bfb-75740b96b1e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d330bf6-235d-4895-8bfb-75740b96b1e1%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:08am UTC](https://discuss.elastic.co/t/using-facets-aggretagions-on-parent-document-queried-by-topchildren/19087/3 "2017-07-06T01:08:36Z")

</div>


