elasticsearch/elasticsearch — Issue #1566: deleteBy queries failing to parse has_child filter.
Author: hlian
Created: 2011-12-22 22:49:23+00:00
State: open

If I run this script:

```sh
curl -XDELETE 'http://localhost:9200/test'
curl -XPUT 'http://localhost:9200/test' -d '
{
"mappings" : {
"child" : {
"_parent" : {
"type" : "parent"
}
}
}
}
'
curl -XPUT 'http://localhost:9200/test/parent/1' -d '{"value" : "1"}'
curl -XPUT 'http://localhost:9200/test/child/1?parent=1' -d '{"value" : "1"}'
curl -XDELETE 'http://localhost:9200/test/parent/_query' -d '
{
"filtered": {
"filter": {
"has_child": {
"query": {
"match_all": {}
},
"type": "child"
}
},
"query": {
"term": {
"value": "1"
}
}
}
}
'
```

this output appears:

```log
[2011-12-22 17:45:04,780][INFO ][cluster.metadata ] [Glorian] [test] deleting index
[2011-12-22 17:45:05,984][INFO ][cluster.metadata ] [Glorian] [test] creating index, cause [api], shards [1]/[0], mappings [child]
[2011-12-22 17:45:07,147][INFO ][cluster.metadata ] [Glorian] [test] update_mapping [parent] (dynamic)
[2011-12-22 17:45:08,326][INFO ][cluster.metadata ] [Glorian] [test] update_mapping [child] (dynamic)
[2011-12-22 17:45:09,430][DEBUG][action.deletebyquery ] [Glorian] [test][0], node[bw5_Dif4Q2-8k1w5VefBSg], [P], s[STARTED]: Failed to execute [delete_by_query {[test][parent], query [
{
"filtered": {
"filter": {
"has_child": {
"query": {
"match_all": {}
},
"type": "child"
}
},
"query": {
"term": {
"value": "1"
}
}
}
}
]}]
org.elasticsearch.index.query.QueryParsingException: [test] Failed to parse
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:186)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:175)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareDeleteByQuery(InternalIndexShard.java:350)
at org.elasticsearch.action.deletebyquery.TransportShardDeleteByQueryAction.shardOperationOnPrimary(TransportShardDeleteByQueryAction.java:80)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:487)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:400)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at org.elasticsearch.index.query.HasChildFilterParser.parse(HasChildFilterParser.java:100)
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:202)
at org.elasticsearch.index.query.FilteredQueryParser.parse(FilteredQueryParser.java:65)
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:176)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:232)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:182)
... 8 more
```

I believe that delete-by query is valid though because the Search API validates and runs it fine. I'm using elasticsearch 0.18.6.