# Top\_children explain

**URL:** https://discuss.elastic.co/t/top-children-explain/7431
**Category:** Elasticsearch
**Created:** [April 21, 2012, 7:48pm UTC](https://discuss.elastic.co/t/top-children-explain/7431 "2012-04-21T19:48:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![slushi](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@slushi](https://discuss.elastic.co/u/slushi)
#### Post date: [April 21, 2012, 7:48pm UTC](https://discuss.elastic.co/t/top-children-explain/7431/1 "2012-04-21T19:48:13Z")

</div>

I am using the top\_children query and noticed that the explain is just "not  
implemented yet...". I had a look at the TopChildrenQuery.java file, it  
seems implementing explain would be something like keeping track of the  
child doc id's in the ParentDoc nested class and then in the explain()  
method have the child query explain each hit. would this be the right  
approach and acceptable? If so, I could take a shot at implementing it.  
Having explain information would be very useful for me.

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [April 25, 2012, 3:32pm UTC](https://discuss.elastic.co/t/top-children-explain/7431/2 "2012-04-25T15:32:29Z")

</div>

Yea, its possible, though for top children, it might make sense to also  
somehow get the explain of the other query as well, which might prove  
tricky...

On Sat, Apr 21, 2012 at 10:48 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:

> I am using the top\_children query and noticed that the explain is just  
> "not implemented yet...". I had a look at the TopChildrenQuery.java file,  
> it seems implementing explain would be something like keeping track of the  
> child doc id's in the ParentDoc nested class and then in the explain()  
> method have the child query explain each hit. would this be the right  
> approach and acceptable? If so, I could take a shot at implementing it.  
> Having explain information would be very useful for me.

---

<div class="post-metadata">

### Author: ![slushi](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@slushi](https://discuss.elastic.co/u/slushi)
#### Post date: [April 25, 2012, 3:57pm UTC](https://discuss.elastic.co/t/top-children-explain/7431/3 "2012-04-25T15:57:56Z")

</div>

Yeah, that's where I got stuck. I thought because parent/child routing  
defaults to be the same, I could use the subDoc variable from  
processResults() to call explain on the child query/documents in  
ParentWeight.explain(), but that didn't work. Is there a way to get the  
correct reader for the child doc?

On Wednesday, April 25, 2012 11:32:29 AM UTC-4, kimchy wrote:

> Yea, its possible, though for top children, it might make sense to also  
> somehow get the explain of the other query as well, which might prove  
> tricky...
> 
> On Sat, Apr 21, 2012 at 10:48 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:
> 
> > I am using the top\_children query and noticed that the explain is just  
> > "not implemented yet...". I had a look at the TopChildrenQuery.java file,  
> > it seems implementing explain would be something like keeping track of the  
> > child doc id's in the ParentDoc nested class and then in the explain()  
> > method have the child query explain each hit. would this be the right  
> > approach and acceptable? If so, I could take a shot at implementing it.  
> > Having explain information would be very useful for me.

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [April 27, 2012, 9:04am UTC](https://discuss.elastic.co/t/top-children-explain/7431/4 "2012-04-27T09:04:40Z")

</div>

It should be possible, just need a bit work to look into it. Open an issue  
so we can track it there?

On Wed, Apr 25, 2012 at 6:57 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:

> Yeah, that's where I got stuck. I thought because parent/child routing  
> defaults to be the same, I could use the subDoc variable from  
> processResults() to call explain on the child query/documents in  
> ParentWeight.explain(), but that didn't work. Is there a way to get the  
> correct reader for the child doc?
> 
> On Wednesday, April 25, 2012 11:32:29 AM UTC-4, kimchy wrote:
> 
> > Yea, its possible, though for top children, it might make sense to also  
> > somehow get the explain of the other query as well, which might prove  
> > tricky...
> > 
> > On Sat, Apr 21, 2012 at 10:48 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:
> > 
> > > I am using the top\_children query and noticed that the explain is just  
> > > "not implemented yet...". I had a look at the TopChildrenQuery.java file,  
> > > it seems implementing explain would be something like keeping track of the  
> > > child doc id's in the ParentDoc nested class and then in the explain()  
> > > method have the child query explain each hit. would this be the right  
> > > approach and acceptable? If so, I could take a shot at implementing it.  
> > > Having explain information would be very useful for me.

---

<div class="post-metadata">

### Author: ![slushi](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@slushi](https://discuss.elastic.co/u/slushi)
#### Post date: [April 27, 2012, 6:20pm UTC](https://discuss.elastic.co/t/top-children-explain/7431/5 "2012-04-27T18:20:16Z")

</div>

I opened issue 1889, thanks.

On Apr 27, 2012, at 5:04 AM, Shay Banon wrote:

> It should be possible, just need a bit work to look into it. Open an issue so we can track it there?
> 
> On Wed, Apr 25, 2012 at 6:57 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:  
> Yeah, that's where I got stuck. I thought because parent/child routing defaults to be the same, I could use the subDoc variable from processResults() to call explain on the child query/documents in ParentWeight.explain(), but that didn't work. Is there a way to get the correct reader for the child doc?
> 
> On Wednesday, April 25, 2012 11:32:29 AM UTC-4, kimchy wrote:  
> Yea, its possible, though for top children, it might make sense to also somehow get the explain of the other query as well, which might prove tricky...
> 
> On Sat, Apr 21, 2012 at 10:48 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:  
> I am using the top\_children query and noticed that the explain is just "not implemented yet...". I had a look at the TopChildrenQuery.java file, it seems implementing explain would be something like keeping track of the child doc id's in the ParentDoc nested class and then in the explain() method have the child query explain each hit. would this be the right approach and acceptable? If so, I could take a shot at implementing it. Having explain information would be very useful for me.

---

<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, 3:30am UTC](https://discuss.elastic.co/t/top-children-explain/7431/6 "2017-07-06T03:30:49Z")

</div>


