# Split child query to query and filter?

**URL:** <https://discuss.elastic.co/t/split-child-query-to-query-and-filter/18009>\
**Category:** Elasticsearch\
**Created:** [June 10, 2014, 9:05am UTC](https://discuss.elastic.co/t/split-child-query-to-query-and-filter/18009 "2014-06-10T09:05:20Z")\
**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:** [June 10, 2014, 9:05am UTC](https://discuss.elastic.co/t/split-child-query-to-query-and-filter/18009/1 "2014-06-10T09:05:20Z")

</div>

Hi,

I need to perform a query + filter on child documents. For the query, I'm  
using TopChildren.  
Now I wonder what would be more efficient regarding query on _date/numeric  
(no score needed) fields_ of this child -  
should I query on these fields using a HasChild filter in a bool query  
with the TopChildren query,  
or should I just combine those date/numeric fields within a single  
TopChildren query?

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/78636d82-808f-4149-84e5-6a8f18ee048f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/78636d82-808f-4149-84e5-6a8f18ee048f%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:40pm UTC](https://discuss.elastic.co/t/split-child-query-to-query-and-filter/18009/2 "2014-08-14T12:40:08Z")

</div>

I will answer myself:  
Any queried type (the parent or any one of its children), if there should  
be a filter on it, should be queried using a _filtered query_ clause. Any  
filtered field should come under the filtered-query \*filter \*clause, and  
any analyzed or score-affecting field should come under the filtered-query \*query  
\*clause.

בתאריך יום שלישי, 10 ביוני 2014 12:05:20 UTC+3, מאת Adam Porat:

> Hi,
> 
> I need to perform a query + filter on child documents. For the query,  
> I'm using TopChildren.  
> Now I wonder what would be more efficient regarding query on _date/numeric  
> (no score needed) fields_ of this child -  
> should I query on these fields using a HasChild filter in a bool query  
> with the TopChildren query,  
> or should I just combine those date/numeric fields within a single  
> TopChildren query?
> 
> 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/ecc523ba-4a55-4470-beaf-0fd2ff9f58aa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ecc523ba-4a55-4470-beaf-0fd2ff9f58aa%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/split-child-query-to-query-and-filter/18009/3 "2017-07-06T01:08:35Z")

</div>


