Skip to content

Instantly share code, notes, and snippets.

@ofavre
Created April 22, 2013 13:38
Show Gist options
  • Save ofavre/5434929 to your computer and use it in GitHub Desktop.
Save ofavre/5434929 to your computer and use it in GitHub Desktop.
NPE while using Delete By Query with Has Parent.
#!/bin/sh
curl -XPOST 'localhost:9200/index' -d '{index:{number_of_shards:1,number_of_replicas:0}}'
curl -XPUT 'localhost:9200/index/parent/_mapping' -d '{parent:{properties:{}}}'
curl -XPUT 'localhost:9200/index/child/_mapping' -d '{child:{"_parent":{type:"parent"}}}'
curl -XPUT 'localhost:9200/index/parent/parent1' -d '{name:"super shay"}'
curl -XPUT 'localhost:9200/index/parent/parent2' -d '{name:"super banon"}'
curl -XPUT 'localhost:9200/index/child/child11?parent=parent1' -d '{name:"shay"}'
curl -XPUT 'localhost:9200/index/child/child21?parent=parent2' -d '{name:"banon"}'
curl -XPOST 'localhost:9200/index/_search?pretty=on' -d '{query:{term:{"parent.name":"shay"}}}' # parent1 ("super shay") only
curl -XPOST 'localhost:9200/index/_search?pretty=on' -d '{query:{bool:{should:[{term:{"parent.name":"shay"}},{has_parent:{parent_type:"parent",query:{term:{name:"shay"}}}}]}}}' # parent1, child11
curl -XDELETE 'localhost:9200/index/_query?pretty=on' -d '{bool:{should:[{term:{"parent.name":"shay"}},{has_parent:{parent_type:"parent",query:{term:{name:"shay"}}}}]}}'
# failed=1!
# Caused by: java.lang.NullPointerException
# at org.elasticsearch.index.query.HasParentQueryParser.parse(HasParentQueryParser.java:154)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment