# Top\_children trouble with multi-shard index

**URL:** <https://discuss.elastic.co/t/top-children-trouble-with-multi-shard-index/7893>\
**Category:** Elasticsearch\
**Created:** [May 29, 2012, 3:01pm UTC](https://discuss.elastic.co/t/top-children-trouble-with-multi-shard-index/7893 "2012-05-29T15:01:31Z")\
**Posts on this page:** 4\
**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:** [May 29, 2012, 3:01pm UTC](https://discuss.elastic.co/t/top-children-trouble-with-multi-shard-index/7893/1 "2012-05-29T15:01:31Z")

</div>

I am using the top\_children query and it was working fine in my dev  
environment, but I am having trouble getting it to work in our test  
environment. After some debugging I found that the key difference is that  
the test env has multiple shards while my dev env only has 1 shard. This  
leads me to believe there is some issue with routing, but I checked the  
parent/child mapping as well as a problematic child document and they both  
seem ok (parent field is set in both places). I also verified that doing  
the child query returns the correct child documents. Any ideas on what else  
I can do to debug this problem?

---

<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:** [May 30, 2012, 8:44am UTC](https://discuss.elastic.co/t/top-children-trouble-with-multi-shard-index/7893/2 "2012-05-30T08:44:39Z")

</div>

Can you try and create a simple recreation of the problem, and then we can  
have a look at it (see [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)).

On Tue, May 29, 2012 at 5:01 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:

> I am using the top\_children query and it was working fine in my dev  
> environment, but I am having trouble getting it to work in our test  
> environment. After some debugging I found that the key difference is that  
> the test env has multiple shards while my dev env only has 1 shard. This  
> leads me to believe there is some issue with routing, but I checked the  
> parent/child mapping as well as a problematic child document and they both  
> seem ok (parent field is set in both places). I also verified that doing  
> the child query returns the correct child documents. Any ideas on what else  
> I can do to debug this problem?

---

<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:** [May 31, 2012, 7:30pm UTC](https://discuss.elastic.co/t/top-children-trouble-with-multi-shard-index/7893/3 "2012-05-31T19:30:38Z")

</div>

Thanks for the reply. I was actually initially unable to repro using curl,  
the query returned hits as expected. I found that in my java code I create  
the SearchRequestBuilder I had a line like:

builder.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH).

If I comment that line, the java code also returned results. I tried for a  
bit to try to create a simplified test case but I couldn't figure out the  
exact scenario that causes the bug, I never get results with my full data  
set but always get results when trying to produce a small gist.

On Wednesday, May 30, 2012 4:44:39 AM UTC-4, kimchy wrote:

> Can you try and create a simple recreation of the problem, and then we can  
> have a look at it (see [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)).
> 
> On Tue, May 29, 2012 at 5:01 PM, slushi [kireetreddy@gmail.com](mailto:kireetreddy@gmail.com) wrote:
> 
> > I am using the top\_children query and it was working fine in my dev  
> > environment, but I am having trouble getting it to work in our test  
> > environment. After some debugging I found that the key difference is that  
> > the test env has multiple shards while my dev env only has 1 shard. This  
> > leads me to believe there is some issue with routing, but I checked the  
> > parent/child mapping as well as a problematic child document and they both  
> > seem ok (parent field is set in both places). I also verified that doing  
> > the child query returns the correct child documents. Any ideas on what else  
> > I can do to debug this problem?

---

<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:26am UTC](https://discuss.elastic.co/t/top-children-trouble-with-multi-shard-index/7893/4 "2017-07-06T03:26:07Z")

</div>


