# ES DeleteByQuery fails to delete records sometimes

**URL:** https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639
**Category:** Elasticsearch
**Created:** [February 2, 2017, 7:14am UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639 "2017-02-02T07:14:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dipathak](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@dipathak](https://discuss.elastic.co/u/dipathak)
#### Post date: [February 2, 2017, 7:14am UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/1 "2017-02-02T07:14:27Z")

</div>

Hi, We are using ES 2.0, on a 3 node cluster, with deleteByQuery plugin. The query sometimes fails to delete some or all of the documents. This behavior is not consistent. Sometimes, all docs are deleted, sometimes few and sometimes none. We also retry 3 times, if expected number of docs are not deleted. Below is the response of deleteByQuery API, but it does not have much information. There is no information related to this in ES logs. Please let us know what more things can we try.

Response: {  
"\_indices" : {  
"\_all" : {  
"deleted" : 2140,  
"failed" : 71,  
"found" : 2211,  
"missing" : 0  
},  
"cfileindex" : {  
"deleted" : 2140,  
"failed" : 71,  
"found" : 2211,  
"missing" : 0  
}  
},  
"failures" : [],  
"timed\_out" : false,  
"took" : 491  
}

---

<div class="post-metadata">

### Author: ![dipathak](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@dipathak](https://discuss.elastic.co/u/dipathak)
#### Post date: [February 4, 2017, 1:57pm UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/2 "2017-02-04T13:57:03Z")

</div>

Hi, Can someone please take a look at this.

---

<div class="post-metadata">

### Author: ![wenthywang](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wenthywang](https://discuss.elastic.co/u/wenthywang)
#### Post date: [February 5, 2017, 5:43am UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/3 "2017-02-05T05:43:17Z")

</div>

do you use java Client?  
if you ,please post your code here

---

<div class="post-metadata">

### Author: ![dipathak](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@dipathak](https://discuss.elastic.co/u/dipathak)
#### Post date: [February 5, 2017, 7:10am UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/4 "2017-02-05T07:10:36Z")

</div>

No, we are using our own http client written in cpp. This sends the http request as mentioned in docs.  
[https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/delete-by-query-usage.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/delete-by-query-usage.html)

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [February 5, 2017, 8:19am UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/5 "2017-02-05T08:19:33Z")

</div>

Are you by any chance continuously updating documents in the index through some process?

---

<div class="post-metadata">

### Author: ![dipathak](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@dipathak](https://discuss.elastic.co/u/dipathak)
#### Post date: [February 13, 2017, 4:54pm UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/6 "2017-02-13T16:54:34Z")

</div>

We are doing insertion (not update) and deletion in a very short interval, like 5-10 secs, but we are not doing both at the same time. Can that result in partial deletion of documents. If yes, what is the correct way to delete all the desired records?

---

<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: [March 13, 2017, 4:54pm UTC](https://discuss.elastic.co/t/es-deletebyquery-fails-to-delete-records-sometimes/73639/7 "2017-03-13T16:54:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
