Nested has_child query error

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

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

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

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.