# Has\_child query doesn't return all results

**URL:** https://discuss.elastic.co/t/has-child-query-doesnt-return-all-results/6997
**Category:** Elasticsearch
**Created:** [March 14, 2012, 1:55pm UTC](https://discuss.elastic.co/t/has-child-query-doesnt-return-all-results/6997 "2012-03-14T13:55:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Christian](https://discuss.elastic.co/u/Christian)
#### Post date: [March 14, 2012, 1:55pm UTC](https://discuss.elastic.co/t/has-child-query-doesnt-return-all-results/6997/1 "2012-03-14T13:55:04Z")

</div>

Hello,

I'm pretty new to ElasticSearch, so I suspect I'm doing something wrong  
here. My index contains a record type and a field type (with \_parent ==  
record). I can search for fields and get results back correctly. I can  
also ask for the \_parent of the field and see that it correctly maps to a  
record. However, when I search for a record with a has\_child query that is  
exactly the same as my field query that works correctly, it sometimes will  
not return any results. It's not a constant thing either. A has\_child  
query for some fields works just fine but for other fields returns nothing.  
Here is a gist with a really simplified version of my index:

[https://gist.github.com/2036598](https://gist.github.com/2036598)

Christian

---

<div class="post-metadata">

### Author: ![Christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Christian](https://discuss.elastic.co/u/Christian)
#### Post date: [March 14, 2012, 5:27pm UTC](https://discuss.elastic.co/t/has-child-query-doesnt-return-all-results/6997/2 "2012-03-14T17:27:24Z")

</div>

Ah forget it. I changed the child objects to nested objects and now I can  
query it like I want. Thanks.

On Wednesday, March 14, 2012 9:55:04 AM UTC-4, Christian wrote:

> Hello,
> 
> I'm pretty new to Elasticsearch, so I suspect I'm doing something wrong  
> here. My index contains a record type and a field type (with \_parent ==  
> record). I can search for fields and get results back correctly. I can  
> also ask for the \_parent of the field and see that it correctly maps to a  
> record. However, when I search for a record with a has\_child query that is  
> exactly the same as my field query that works correctly, it sometimes will  
> not return any results. It's not a constant thing either. A has\_child  
> query for some fields works just fine but for other fields returns nothing.  
> Here is a gist with a really simplified version of my index:
> 
> [https://gist.github.com/2036598](https://gist.github.com/2036598)
> 
> Christian

---

<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:36am UTC](https://discuss.elastic.co/t/has-child-query-doesnt-return-all-results/6997/3 "2017-07-06T03:36:06Z")

</div>


