# Delete by query , refresh=wait\_for support?

**URL:** <https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118>\
**Category:** Elasticsearch\
**Created:** [October 26, 2018, 7:05am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118 "2018-10-26T07:05:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grievoushead](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grievoushead/32/36950_2.png) [@Grievoushead](https://discuss.elastic.co/u/Grievoushead)\
**Post date:** [October 26, 2018, 7:05am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/1 "2018-10-26T07:05:36Z")

</div>

When I call delete\_by\_query with ?refresh=wait\_for, got this warning:

\_delete\_by\_query/?refresh=wait\_for] returned 1 warnings: [299 Elasticsearch-5.4.1-2cfe0df "Expected a boolean [true/false] for request parameter [refresh] but got [wait\_for]

Is it supported?, doc's says it is.

And when I call delete\_by\_query with ?retry\_on\_conflict=3  
It fails - invalid parameter.

I wanted to use these since when I delete records I got them rejected b/c of version conflicts. I read about ?conflicts=proceed but I am not sure if it will cause deleted records to remain. That's why I wanted to add retry first and then wait for.

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 26, 2018, 7:42am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/2 "2018-10-26T07:42:52Z")

</div>

Hi,

What version are you running

Doc : [https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docs-delete-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docs-delete-by-query.html)

---

<div class="post-metadata">

**Author:** ![Grievoushead](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grievoushead/32/36950_2.png) [@Grievoushead](https://discuss.elastic.co/u/Grievoushead)\
**Post date:** [October 26, 2018, 8:47am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/3 "2018-10-26T08:47:57Z")

</div>

> [@Grievoushead](#):
>
> Elasticsearch-5.4.1

Elasticsearch-5.4.1

Here it says that delete support refresh param:

> **[?refresh | Elasticsearch Reference \[5.4\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html)**

Does it mean that ?refresh=wait\_for supported in update but not in delete?

And why delete doesn't support ?retry\_on\_conflict=3 ?

I see when it fails with version conflict it has:

retries: {bulk: 0, search: 0} meaning it failed on first try, but in doc's from your link it says it should try up to 10 times.

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 26, 2018, 9:30am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/4 "2018-10-26T09:30:51Z")

</div>

I think that there is a misunderstanding with the doc:

[https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-delete-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-delete-by-query.html)

```
In addition to the standard parameters like `pretty` , the Delete By Query API also supports `refresh` ,  
`wait_for_completion` , `wait_for_active_shards` , and `timeout` .

```

For me, the 3 first parameters are boolean : &refresh=true&wait\_for\_completion=true...

---

<div class="post-metadata">

**Author:** ![Grievoushead](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grievoushead/32/36950_2.png) [@Grievoushead](https://discuss.elastic.co/u/Grievoushead)\
**Post date:** [October 26, 2018, 11:28am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/5 "2018-10-26T11:28:25Z")

</div>

I see, it looks strange that in [this part](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html) doc says `?refresh` has 3 values (true, false, wait\_for)  
And for delete it has specific param - `?wait_for_completion=true` which I believe same as  
`?refresh=wait_for`.

Anyhow, I have another questions: `?retry_on_conflict=3` param which doesn't work for delete\_by\_query but works for update.

Also it's not clear why it doesn't do re-try by default as it says in docs for `delete_by_query`:

> `_delete_by_query` relies on a default policy to retry rejected requests (up to 10 times, with exponential back off)

--Thanks.

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 26, 2018, 12:10pm UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/6 "2018-10-26T12:10:21Z")

</div>

> [@Grievoushead](#):
>
> Anyhow, I have another questions: `?retry_on_conflict=3` param which doesn't work for delete\_by\_query but works for update.

IMO retry\_on\_conflict is only used when updating a document, in this case, a conflict of version may occure. When you delete a doc, there is no conflic _"possible"_, the doc is deleted.

In the response, "retries" is when the initial request failed (cluster error, timeout, etc..), this is not a _version conflict_.

bye,  
Xavier

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 26, 2018, 2:10pm UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/7 "2018-10-26T14:10:25Z")

</div>

I can answer this because most of it is my fault!

`retry_on_conflicts` isn't supported by delete-by-query and update-by-query because we don't have a mechanism to re-check that the document matches the query after the conflict. It may not. Your only option is to `ignore_conflicts` and redo the entire request if there are any conflicts. Delete-by-query at least will be much smaller the second time around.

Not supporting `wait_for` is my fault on both counts. I made `wait_for` and I made the `reindex` infrastructure that powers delete-by-query and I didn't link them because it is hard. `wait_for` hooks pretty deep into the shard to know when a refresh occurs. But delete-by-query functions at a much higher level. It _could_ stick use `refresh=wait_for` on every bulk request that it sends but that'd slow down every bulk request while it waits for a refresh for each one. Delete-by-query can't hook into the `wait_for` infrastructure in any other way. So it doesn't. But the docs don't reflect that. I'll fix that.

---

<div class="post-metadata">

**Author:** ![Grievoushead](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grievoushead/32/36950_2.png) [@Grievoushead](https://discuss.elastic.co/u/Grievoushead)\
**Post date:** [October 30, 2018, 11:32am UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/8 "2018-10-30T11:32:24Z")

</div>

Hi Nik,  
Thank you for your answer.

But it still not clear for me, what should I do when version conflict arise during delete\_by  
query?

What I did is that I have added `_delete_by_query/?refresh=wait_for` and it print warnings but version conflicts doesn't occur anymore, so is it actually works ??

Or, it interprets not empty strings as true `refresh=true` ??

What happens if I use `conflicts=proceed` param - will it skip deleting because of conflicts and I will need to re-try manually ?

Thank you.

---

<div class="post-metadata">

**Author:** ![Terry\_Quigley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/terry_quigley/32/80037_2.png) [@Terry\_Quigley](https://discuss.elastic.co/u/Terry_Quigley)\
**Post date:** [November 7, 2018, 12:06pm UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/9 "2018-11-07T12:06:44Z")

</div>

Hi

It isn't clear to me either as I've been having issues with _?refresh=wait\_for_ not doing what I expected from the docs. I have also tried _?refresh=true_ with similar behaviour (i.e. it appears to do nothing). Is there something else I should try ?

Thanks

---

<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:** [December 5, 2018, 12:06pm UTC](https://discuss.elastic.co/t/delete-by-query-refresh-wait-for-support/154118/10 "2018-12-05T12:06:46Z")

</div>

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