# Nested has\_child query error

**URL:** https://discuss.elastic.co/t/nested-has-child-query-error/7313
**Category:** Elasticsearch
**Created:** [April 12, 2012, 7:11pm UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7313 "2012-04-12T19:11:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![domizio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/domizio/32/2530_2.png) [@domizio](https://discuss.elastic.co/u/domizio)
#### Post date: [April 12, 2012, 7:11pm UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7313/1 "2012-04-12T19:11:11Z")

</div>

I am trying to use has\_child on another has\_child query and I get a failure.  
As you can see in the mapping below, the 'product' type is the parent of the  
'review' type, which is the parent of 'review\_comment' type.

The relevant mapping of that index is:

{  
"emp\_ddb": {  
"product": {  
"properties": {  
"created": {  
"type": "date",  
"format": "dateOptionalTime"  
},  
"description": {  
"type": "string"  
},  
"manufacturer": {  
"type": "string"  
},  
"model": {  
"type": "string"  
},  
"owns\_count": {  
"type": "long"  
},  
"reviews\_count": {  
"type": "long"  
},  
"tags": {  
"type": "string"  
},  
"tags\_slug": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"title": {  
"type": "string"  
},  
"updated": {  
"type": "date",  
"format": "dateOptionalTime"  
},  
"user\_id": {  
"type": "long"  
},  
"wants\_count": {  
"type": "long"  
},  
"watches\_count": {  
"type": "long"  
}  
}  
},  
"review\_comment": {  
"\_parent": {  
"type": "review"  
},  
"\_routing": {  
"required": true  
},  
"properties": {  
"content": {  
"type": "string"  
},  
"created": {  
"type": "date",  
"format": "dateOptionalTime"  
},  
"published": {  
"type": "boolean"  
},  
"user\_id": {  
"type": "long"  
}  
}  
},  
"review": {  
"\_parent": {  
"type": "product"  
},  
"\_routing": {  
"required": true  
},  
"properties": {  
"created": {  
"type": "date",  
"format": "dateOptionalTime"  
},  
"description": {  
"type": "string"  
},  
"title": {  
"type": "string"  
},  
"updated": {  
"type": "date",  
"format": "dateOptionalTime"  
},  
"user\_id": {  
"type": "long"  
}  
}  
}  
}  
}

Here is the query:

curl -XGET "[http://localhost:9200/emp\_ddb/product/\_search?pretty=1](http://localhost:9200/emp_ddb/product/_search?pretty=1)" -d '  
{  
"query": {  
"has\_child": {  
"type": "review",  
"query": {  
"has\_child": {  
"type": "review\_comment",  
"query": {  
"match\_all": {

```
        }
      }
    }
  }
}

```

}  
}  
'

and here is the result, when the query hits something, it gives an error,  
while it is fine when the query doesn't hit anything:

{  
"took" : 3372,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 4,  
"failed" : 1,  
"failures" : [ {  
"index" : "emp\_ddb",  
"shard" : 2,  
"status" : 500,  
"reason" : "QueryPhaseExecutionException[[emp\_ddb][2]:  
query[filtered(ConstantScore(child\_filter[review/product](filtered(ConstantScore(child\_filter[review\_comment/review](filtered(ConstantScore(NotDeleted(_:_)))-\>cache(\_type:review\_comment))))-\>cache(\_type:review))))-\>cache(\_type:product)],from[0],size[10]:  
Query Failed [Failed to execute child query  
[filtered(ConstantScore(NotDeleted(_:_)))-\>cache(\_type:review\_comment)]]];  
nested: "  
} ]  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

What am I doing wrong?

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Nested-has-child-query-error-tp3906204p3906204.html](http://elasticsearch-users.115913.n3.nabble.com/Nested-has-child-query-error-tp3906204p3906204.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:32am UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7313/2 "2017-07-06T03:32:48Z")

</div>


