# Nested has\_child query error

**URL:** https://discuss.elastic.co/t/nested-has-child-query-error/7317
**Category:** Elasticsearch
**Created:** [April 12, 2012, 9:39pm UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7317 "2012-04-12T21:39:28Z")
**Posts on this page:** 5
**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, 9:39pm UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7317/1 "2012-04-12T21:39:28Z")

</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?

---

<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 13, 2012, 12:34pm UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7317/2 "2012-04-13T12:34:01Z")

</div>

Which version are you using? A similar problem was fixed in 0.19.

On Fri, Apr 13, 2012 at 12:39 AM, dd [dd.nexus@gmail.com](mailto:dd.nexus@gmail.com) wrote:

> 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\_filterreview/product))-\>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?

---

<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 13, 2012, 1:45pm UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7317/3 "2012-04-13T13:45:46Z")

</div>

Elasticsearch Version: 0.19.0, JVM: 20.4-b02-402

Does 0.19.2 solve it? Thanks.

On Friday, April 13, 2012 8:34:01 AM UTC-4, kimchy wrote:

> Which version are you using? A similar problem was fixed in 0.19.
> 
> On Fri, Apr 13, 2012 at 12:39 AM, dd wrote:
> 
> > 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\_filterreview/product))-\>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?

---

<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 14, 2012, 12:38am UTC](https://discuss.elastic.co/t/nested-has-child-query-error/7317/4 "2012-04-14T00:38:55Z")

</div>

I installed the 0.19.2, and it didn't solved the probelm by itself. However  
I deleted all the old files, re-built the index and everything worked as  
expected. Great! Thank you.

---

<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/7317/5 "2017-07-06T03:32:37Z")

</div>


