# Send delete request only when inserted documents have been persisted

**URL:** <https://discuss.elastic.co/t/send-delete-request-only-when-inserted-documents-have-been-persisted/246456>\
**Category:** Elasticsearch\
**Created:** [August 26, 2020, 1:21pm UTC](https://discuss.elastic.co/t/send-delete-request-only-when-inserted-documents-have-been-persisted/246456 "2020-08-26T13:21:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![makons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/makons/32/74314_2.png) [@makons](https://discuss.elastic.co/u/makons)\
**Post date:** [August 26, 2020, 1:21pm UTC](https://discuss.elastic.co/t/send-delete-request-only-when-inserted-documents-have-been-persisted/246456/1 "2020-08-26T13:21:47Z")

</div>

I'm running upsert, and right after that delete by query, however, some of the documents upserted should be picked up by the following delete request. Is there a chance to send/execute the delete request only after the documents have successfully been upserted?

Currently, if I run the commands without any delays, none of the upserted documents are deleted. I did try to add the artificial delay of several seconds, and things work out well then. If it is not possible to know the exact time documents have been persisted, is there an upper bound when can that be expected?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 26, 2020, 10:00pm UTC](https://discuss.elastic.co/t/send-delete-request-only-when-inserted-documents-have-been-persisted/246456/2 "2020-08-26T22:00:41Z")

</div>

> [@makons](#):
>
> Is there a chance to send/execute the delete request only after the documents have successfully been upserted?

Yes, you need to do that in your client though as it's not something Elasticsearch tracks.

> [@makons](#):
>
> If it is not possible to know the exact time documents have been persisted, is there an upper bound when can that be expected?

Take a look at [?refresh | Elasticsearch Guide [7.9] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/docs-refresh.html)

---

<div class="post-metadata">

**Author:** ![makons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/makons/32/74314_2.png) [@makons](https://discuss.elastic.co/u/makons)\
**Post date:** [August 27, 2020, 3:36pm UTC](https://discuss.elastic.co/t/send-delete-request-only-when-inserted-documents-have-been-persisted/246456/3 "2020-08-27T15:36:28Z")

</div>

Thanks, that seems to be what I was looking for.

---

<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:** [September 24, 2020, 3:36pm UTC](https://discuss.elastic.co/t/send-delete-request-only-when-inserted-documents-have-been-persisted/246456/4 "2020-09-24T15:36:45Z")

</div>

Closed on September 24, 2020, 3:36pm UTC

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