# Elasticsearch delete\_by\_query 409 version conflict

**URL:** <https://discuss.elastic.co/t/elasticsearch-delete-by-query-409-version-conflict/174150>\
**Category:** Elasticsearch\
**Created:** [March 27, 2019, 2:46pm UTC](https://discuss.elastic.co/t/elasticsearch-delete-by-query-409-version-conflict/174150 "2019-03-27T14:46:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [March 28, 2019, 10:05am UTC](https://discuss.elastic.co/t/elasticsearch-delete-by-query-409-version-conflict/174150/2 "2019-03-28T10:05:47Z")

</div>

Hi @Rahul_Kumar3,

I think the missing piece to make this safe is a refresh.

Delete by query basically does a search for the objects to delete and then deletes them with version conflict checking. Without a `_refresh` in between, the search done by `_delete_by_query` might return the old version of the document, leading to a version conflict when the delete is attempted.

To be certain that delete by query sees all operations done, refresh should be called, see: [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html) . Or you can use the refresh parameter on the previous indexing request, see: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html)

Notice that refreshing is not free. The last link above explains some of the trade-offs involved including the impact on indexing and search performance.

The default refresh interval is 1s, see: [https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#dynamic-index-settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#dynamic-index-settings)

---

_[View the full topic](https://discuss.elastic.co/t/elasticsearch-delete-by-query-409-version-conflict/174150)._
