# Delete by query with has\_parent

**URL:** <https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938>\
**Category:** Elasticsearch\
**Created:** [February 27, 2013, 11:07pm UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938 "2013-02-27T23:07:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![snmaynard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/snmaynard/32/2463_2.png) [@snmaynard](https://discuss.elastic.co/u/snmaynard)\
**Post date:** [February 27, 2013, 11:07pm UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/1 "2013-02-27T23:07:54Z")

</div>

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](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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [February 27, 2013, 11:17pm UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/2 "2013-02-27T23:17:12Z")

</div>

I think this is a bug. What ES version are you using?

On 28 February 2013 00:07, Simon [snmaynard@gmail.com](mailto:snmaynard@gmail.com) wrote:

> 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](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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![snmaynard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/snmaynard/32/2463_2.png) [@snmaynard](https://discuss.elastic.co/u/snmaynard)\
**Post date:** [February 27, 2013, 11:20pm UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/3 "2013-02-27T23:20:49Z")

</div>

I'm currently using 0.20.5

On Wednesday, February 27, 2013 3:17:12 PM UTC-8, Martijn v Groningen wrote:

> I think this is a bug. What ES version are you using?
> 
> On 28 February 2013 00:07, Simon \<[snma...@gmail.com](mailto:snma...@gmail.com) \<javascript:\>\> wrote:
> 
> > 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](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](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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [February 27, 2013, 11:27pm UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/4 "2013-02-27T23:27:08Z")

</div>

After a quick look at the code it seems to me that all parent/child queries  
don't work via delete by query api. I have opened an issue to further  
investigate this issue:

> <https://github.com/elastic/elasticsearch/issues/2705>
>
> Reported via ML:
> https://groups.google.com/forum/?fromgroups=#!topic/elasticsear…ch/Wsv3ziKdeTk

Thanks for bringing this up!

On 28 February 2013 00:20, Simon [snmaynard@gmail.com](mailto:snmaynard@gmail.com) wrote:

> I'm currently using 0.20.5
> 
> On Wednesday, February 27, 2013 3:17:12 PM UTC-8, Martijn v Groningen  
> wrote:
> 
> > I think this is a bug. What ES version are you using?
> > 
> > On 28 February 2013 00:07, Simon [snma...@gmail.com](mailto:snma...@gmail.com) wrote:
> > 
> > > 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](http://localhost:9200/index/**child/_search)[http://localhost:9200/index/child/\_search](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](http://localhost:9200/index/**child/_query)[http://localhost:9200/index/child/\_query](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(  
> > > TransportShardDeleteByQueryAct**ion.java:95)  
> > > at org.elasticsearch.action. **support.replication.**  
> > > TransportShardReplicationOpera_tionAction$AsyncShardOperationAction.  
> > > \*performOnPrimary( **TransportShardReplicationOpera** tionAction.java:532)  
> > > at org.elasticsearch.action. **support.replication.**  
> > > TransportShardReplicationOperationAction$_\*  
> > > AsyncShardOperationAction$1.\*\*run( **TransportShardReplicationOpera**  
> > > tionAction.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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![snmaynard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/snmaynard/32/2463_2.png) [@snmaynard](https://discuss.elastic.co/u/snmaynard)\
**Post date:** [February 28, 2013, 12:13am UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/5 "2013-02-28T00:13:00Z")

</div>

No worries, thanks for the prompt response, I'll keep an eye on the issue!

On Wednesday, February 27, 2013 3:27:08 PM UTC-8, Martijn v Groningen wrote:

> After a quick look at the code it seems to me that all parent/child  
> queries don't work via delete by query api. I have opened an issue to  
> further investigate this issue:  
> [Parent/child queries don't work with via the delete by query api · Issue #2705 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2705)
> 
> Thanks for bringing this up!
> 
> On 28 February 2013 00:20, Simon \<[snma...@gmail.com](mailto:snma...@gmail.com) \<javascript:\>\> wrote:
> 
> > I'm currently using 0.20.5
> > 
> > On Wednesday, February 27, 2013 3:17:12 PM UTC-8, Martijn v Groningen  
> > wrote:
> > 
> > > I think this is a bug. What ES version are you using?
> > > 
> > > On 28 February 2013 00:07, Simon [snma...@gmail.com](mailto:snma...@gmail.com) wrote:
> > > 
> > > > 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](http://localhost:9200/index/**child/_search)[http://localhost:9200/index/child/\_search](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](http://localhost:9200/index/**child/_query)[http://localhost:9200/index/child/\_query](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(  
> > > > TransportShardDeleteByQueryAct**ion.java:95)  
> > > > at org.elasticsearch.action. **support.replication.**  
> > > > TransportShardReplicationOpera\*\*tionAction$**AsyncShardOperationAction.  
> > > > performOnPrimary(TransportShardReplicationOpera  
> > > > tionAction.java:532)  
> > > > at org.elasticsearch.action.support.replication.  
> > > > TransportShardReplicationOperationAction$**  
> > > > AsyncShardOperationAction$1.\*\*run( **TransportShardReplicationOpera**  
> > > > tionAction.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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > Met vriendelijke groet,
> > > 
> > > Martijn van Groningen
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Hanish\_Bansal](https://avatars.discourse-cdn.com/v4/letter/h/e36b37/32.png) [@Hanish\_Bansal](https://discuss.elastic.co/u/Hanish_Bansal)\
**Post date:** [May 28, 2013, 10:30am UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/6 "2013-05-28T10:30:17Z")

</div>

Hi

I am facing same issue of deleting child documents from elasticsearch.

My ElasticSeacrch version is: elasticsearch-0.90.0.RC2

has this issue been resolved ?

On Thursday, February 28, 2013 12:13:00 AM UTC, Simon wrote:

> No worries, thanks for the prompt response, I'll keep an eye on the issue!
> 
> On Wednesday, February 27, 2013 3:27:08 PM UTC-8, Martijn v Groningen  
> wrote:
> 
> > After a quick look at the code it seems to me that all parent/child  
> > queries don't work via delete by query api. I have opened an issue to  
> > further investigate this issue:  
> > [Parent/child queries don't work with via the delete by query api · Issue #2705 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2705)
> > 
> > Thanks for bringing this up!
> > 
> > On 28 February 2013 00:20, Simon [snma...@gmail.com](mailto:snma...@gmail.com) wrote:
> > 
> > > I'm currently using 0.20.5
> > > 
> > > On Wednesday, February 27, 2013 3:17:12 PM UTC-8, Martijn v Groningen  
> > > wrote:
> > > 
> > > > I think this is a bug. What ES version are you using?
> > > > 
> > > > On 28 February 2013 00:07, Simon [snma...@gmail.com](mailto:snma...@gmail.com) wrote:
> > > > 
> > > > > 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](http://localhost:9200/index/**child/_search)[http://localhost:9200/index/child/\_search](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](http://localhost:9200/index/**child/_query)[http://localhost:9200/index/child/\_query](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(  
> > > > > TransportShardDeleteByQueryAct**ion.java:95)  
> > > > > at org.elasticsearch.action. **support.replication.**  
> > > > > TransportShardReplicationOpera **tionAction$**  
> > > > > AsyncShardOperationAction.**performOnPrimary(**  
> > > > > TransportShardReplicationOpera**tionAction.java:532)  
> > > > > at org.elasticsearch.action.support.replication.  
> > > > > TransportShardReplicationOpera**tionAction$\*\*  
> > > > > AsyncShardOperationAction$1.\*\*run( **TransportShardReplicationOpera**  
> > > > > tionAction.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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > > 
> > > > --  
> > > > Met vriendelijke groet,
> > > > 
> > > > Martijn van Groningen
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:34am UTC](https://discuss.elastic.co/t/delete-by-query-with-has-parent/10938/7 "2017-07-06T02:34:26Z")

</div>


