# Delete an nonexistent document

**URL:** https://discuss.elastic.co/t/delete-an-nonexistent-document/232073
**Category:** Elasticsearch
**Created:** [May 11, 2020, 4:16pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073 "2020-05-11T16:16:37Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ekrx](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@ekrx](https://discuss.elastic.co/u/ekrx)
#### Post date: [May 11, 2020, 4:16pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/1 "2020-05-11T16:16:37Z")

</div>

I would like to understand what are the implications of sending a delete by id for a document that does not exist. We have such case where we are sending delete operations for a big number of documents where almost 90% of those have been deleted previously or they dont exist.  
The other alternative is to only send deletes for the document that do exists but that would require doing a get before delete, which I dont think is better.  
Thank you

---

<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: [May 11, 2020, 4:38pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/2 "2020-05-11T16:38:01Z")

</div>

Welcome!

There is no consequence for the data.  
It's just a useless HTTP rest request which is sent to the cluster.

---

<div class="post-metadata">

### Author: ![ekrx](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@ekrx](https://discuss.elastic.co/u/ekrx)
#### Post date: [May 11, 2020, 4:46pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/3 "2020-05-11T16:46:42Z")

</div>

yes, for the data nothing will happen, but in terms of resources and operations. which would cost more to the cluster ?

---

<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: [May 11, 2020, 5:11pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/4 "2020-05-11T17:11:40Z")

</div>

Yes. A request is a request that needs to be processed by the cluster.  
If you are sending 1m of DELETE requests per second for example, you can easily imagine that there is a cost of answering all those requests.

So in a sense, it has a cost.

But it should not be hard to test your scenario against a cluster to see what is the actual cost with your real use case.

---

<div class="post-metadata">

### Author: ![ekrx](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@ekrx](https://discuss.elastic.co/u/ekrx)
#### Post date: [May 11, 2020, 7:33pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/5 "2020-05-11T19:33:55Z")

</div>

Deletes are expensive. How is it different from a delete of a nonexistent document ?  
How is a delete of nonexistent compared to a get?

---

<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: [May 11, 2020, 7:40pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/6 "2020-05-11T19:40:59Z")

</div>

A delete causes Elasticsearch to first check if the document exists and then writing a tombstone record if it is. I don't think the document need to be retrieved from disk though, so I would expect this should be more efficient that first performing a get followed by a delete if the document exists.

---

<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: [June 8, 2020, 7:40pm UTC](https://discuss.elastic.co/t/delete-an-nonexistent-document/232073/7 "2020-06-08T19:40:59Z")

</div>

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