I have the following schema in elasticsearch.
parent = {
name: "Name",
id: "parentID"
}
child = {
name:"Name here",
id: "childID"
}
When adding a child, I add it as a child of the parent in elasticsearch by
referencing the parentID.
I can search for all children of a certain parent by running the following
command,
curl -XGET 'http://localhost:9200/index/child/_search' -d
"{"query":{"has_parent":{"parent_type":"parent","query":{"term":{"name":"Name"}}}}}"
{"took":48,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":214,"max_score":1.0,"hits":[{"_index":"index","_type":"child","_id":"512e48350a57150000000018","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a57150000000019","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a5715000000001a","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a5715000000001d","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a5715000000001e","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a5715000000001f","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a57150000000020","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a57150000000021","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a57150000000022","_score":1.0},{"_index":"index","_type":"child","_id":"512e48350a57150000000023","_score":1.0}]}}
So that works fine. When I want to delete these documents though, because I
am also going to delete the parent, I get the following,
curl -XDELETE 'http://localhost:9200/index/child/_query' -d
"{"has_parent":{"parent_type":"parent","query":{"term":{"name":"Name"}}}}"
{"ok":true,"_indices":{"index":{"_shards":{"total":5,"successful":0,"failed":5}}}}
In the elasticsearch log I see,
[2013-02-27 14:19:02,281][DEBUG][action.deletebyquery ] [Briquette]
[index][2], node[VsFgl8kKRz2e4yhjsANFvg], [P], s[STARTED]: Failed to
execute [delete_by_query {[index][child], query
[{"has_parent":{"parent_type":"parent","query":{"term":{"name":"Name"}}}}]}]
org.elasticsearch.index.query.QueryParsingException: [index] Failed to parse
at
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:220)
at
org.elasticsearch.index.shard.service.InternalIndexShard.prepareDeleteByQuery(InternalIndexShard.java:370)
at
org.elasticsearch.action.deletebyquery.TransportShardDeleteByQueryAction.shardOperationOnPrimary(TransportShardDeleteByQueryAction.java:95)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
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:680)
Caused by: java.lang.NullPointerException
at
org.elasticsearch.index.query.HasParentQueryParser.parse(HasParentQueryParser.java:153)
at
org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:188)
at
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:268)
at
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:216)
... 7 more
Does anyone have any idea why deleting by a query isn't working with
has_parent for me?
Thanks,
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.