# Elasticsearch Version Conflicts When Deleting Data

**URL:** <https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413>\
**Category:** Elasticsearch\
**Created:** [July 17, 2018, 11:53pm UTC](https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413 "2018-07-17T23:53:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanwang](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@yanwang](https://discuss.elastic.co/u/yanwang)\
**Post date:** [July 17, 2018, 11:53pm UTC](https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413/1 "2018-07-17T23:53:17Z")

</div>

Hi,

We are now using DeleteByQueryRequestBuilder to do the batch deletion of data. But in the process I see the VersionConflictEngineException **[type][id]: version conflict, current version [-1] is different than the one provided [1]**. When I query that id I can see it is existing in the index.

The version we are using is 5.1.1. Could it be a bug? Version -1 means the doc does not exist, right?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 18, 2018, 7:09am UTC](https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413/2 "2018-07-18T07:09:36Z")

</div>

May be the document has been removed by another process while the DeleteByQuery was running?

See [Delete by query API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html)

> `_delete_by_query` gets a snapshot of the index when it starts and deletes what it finds using `internal` versioning. That means that you’ll get a version conflict if the document changes between the time when the snapshot was taken and when the delete request is processed. When the versions match the document is deleted.

> The version we are using is 5.1.1

You should upgrade to latest 5.x version or better think about 6.3... 🙂

---

<div class="post-metadata">

**Author:** ![yanwang](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@yanwang](https://discuss.elastic.co/u/yanwang)\
**Post date:** [July 19, 2018, 8:54pm UTC](https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413/3 "2018-07-19T20:54:32Z")

</div>

Thanks for you reply David. I doubt another process deleted it because I tried to flush the index and re-delete it again but I still got the conflicts and if I search it is still there..But yes we are upgrading our es version to es6 to see if that can be gone. I just want to find the root cause of it..

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 19, 2018, 9:30pm UTC](https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413/4 "2018-07-19T21:30:31Z")

</div>

I don't remember exactly but I think that Delete By Query API has got some fixes. That's why I recommend using 5.6.10 at least.

---

<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:** [August 16, 2018, 9:30pm UTC](https://discuss.elastic.co/t/elasticsearch-version-conflicts-when-deleting-data/140413/5 "2018-08-16T21:30:36Z")

</div>

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