# Has\_child get child IDs

**URL:** https://discuss.elastic.co/t/has-child-get-child-ids/11789
**Category:** Elasticsearch
**Created:** [May 3, 2013, 2:32am UTC](https://discuss.elastic.co/t/has-child-get-child-ids/11789 "2013-05-03T02:32:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![George\_Karpenkov](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@George\_Karpenkov](https://discuss.elastic.co/u/George_Karpenkov)
#### Post date: [May 3, 2013, 2:32am UTC](https://discuss.elastic.co/t/has-child-get-child-ids/11789/1 "2013-05-03T02:32:55Z")

</div>

Hi All,

Is there any particular reason why has\_child filter does not return  
children IDs, possibly behind an option? I mean, surely it must find those  
in order to return a matching parent...  
I saw this github issue -  
[https://github.com/elasticsearch/elasticsearch/issues/2744](https://github.com/elasticsearch/elasticsearch/issues/2744) - where  
(apparently?) it used to return children ids and then stopped.

I'm currently looking into patching my ES installation in order to return  
children IDs (yes, I can get them by individually asking for all children  
of all returned parent documents and then querying those, but it turns one  
query (returning a batch of, say, 20) into 21 queries.

Regards,  
George

--  
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: ![q42jaap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/q42jaap/32/2241_2.png) [@q42jaap](https://discuss.elastic.co/u/q42jaap)
#### Post date: [May 3, 2013, 6:57am UTC](https://discuss.elastic.co/t/has-child-get-child-ids/11789/2 "2013-05-03T06:57:51Z")

</div>

Hi George,

The issue you referred to is actually saying that child ids shouldn't be  
collected. It makes sense for has\_child to remember only the \_parent field.  
It only needs those to filter the parent query.

If you really want to know the child IDs , you might be able to use a  
scoped facet.  
You might run in to OOM exceptions if you have a lot of child IDs.

Jaap  
On May 3, 2013 4:33 AM, "George Karpenkov" [true.cheshire@gmail.com](mailto:true.cheshire@gmail.com) wrote:

> Hi All,
> 
> Is there any particular reason why has\_child filter does not return  
> children IDs, possibly behind an option? I mean, surely it must find those  
> in order to return a matching parent...  
> I saw this github issue -  
> [has\_child returns parent and child · Issue #2744 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2744) - where  
> (apparently?) it used to return children ids and then stopped.
> 
> I'm currently looking into patching my ES installation in order to return  
> children IDs (yes, I can get them by individually asking for all children  
> of all returned parent documents and then querying those, but it turns one  
> query (returning a batch of, say, 20) into 21 queries.
> 
> Regards,  
> George
> 
> --  
> 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).

--  
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: ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)
#### Post date: [May 6, 2013, 4:41pm UTC](https://discuss.elastic.co/t/has-child-get-child-ids/11789/3 "2013-05-06T16:41:35Z")

</div>

On 5/2/2013 7:32 PM, George Karpenkov wrote:

> I'm currently looking into patching my ES installation in order to  
> return children IDs (yes, I can get them by individually asking for  
> all children of all returned parent documents and then querying those,  
> but it turns one query (returning a batch of, say, 20) into 21 queries.  
> Why can't combine the results of the 1st query (returning 1) to generate  
> 1 larger 2nd query (returning 20)?

-Paul

--  
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: ![George\_Karpenkov\_2](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@George\_Karpenkov\_2](https://discuss.elastic.co/u/George_Karpenkov_2)
#### Post date: [May 8, 2013, 3:12am UTC](https://discuss.elastic.co/t/has-child-get-child-ids/11789/4 "2013-05-08T03:12:39Z")

</div>

Hi All,

@Japp:

1. I'm new in the search field, but to be honest that behaviour does not  
make sense to me.  
I've referred to the issue because to me it seemed like after the patch ES  
stopped returning (potentially needed) information, without any flag to ask  
for it.  
I'll try to explain myself: ES has to know that parent P has the child C.  
Therefore, it has to find a child C first. Therefore, it should know the  
child ID at the time of query (with cold cache, but child ID could be  
cached as well).  
So to me it seems like it throws away the information which is potentially  
needed by the callee even though it has it.  
Please correct me if I'm wrong.

2. Could you please elaborate on the scoped facet approach? I've seen the  
passing mention in the documentation, but could not figure out how to use  
it to solve my problem.

@Paul:  
I've tried doing that, yet I haven't found the way.  
Suppose ES gives me 10 ids. I can query ES to return me all documents which  
have those parent ID: just do an analogue of "WHERE parent\_id IN (...)  
LIMIT 10" query.  
Yet that does not guarantee to give me one child per each parent document  
--- it could give me 10 child documents for the first parent I have.  
Is there a better way?

Regards,  
George

On Tue, May 7, 2013 at 2:44 AM, Paul Hill [parehill1@gmail.com](mailto:parehill1@gmail.com) wrote:

> On 5/2/2013 7:32 PM, George Karpenkov wrote:
> 
> > I'm currently looking into patching my ES installation in order to return  
> > children IDs (yes, I can get them by individually asking for all children  
> > of all returned parent documents and then querying those, but it turns one  
> > query (returning a batch of, say, 20) into 21 queries.
> 
> Why can't combine the results of the 1st query (returning 1) to generate 1  
> larger 2nd query (returning 20)?
> 
> -Paul
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)\*\*  
> topic/elasticsearch/\*\*JQXVrhzVmV8/unsubscribe?hl=en-\*\*US[https://groups.google.com/d/topic/elasticsearch/JQXVrhzVmV8/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/JQXVrhzVmV8/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> elasticsearch+unsubscribe@\*\*[googlegroups.com](http://googlegroups.com)[elasticsearch%2Bunsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> .

--  
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:37am UTC](https://discuss.elastic.co/t/has-child-get-child-ids/11789/5 "2017-07-06T02:37:47Z")

</div>


