# How can I see if there is an exception in the delete operation?

**URL:** <https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414>\
**Category:** Elasticsearch\
**Created:** [October 6, 2010, 3:15pm UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414 "2010-10-06T15:15:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shelly](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Shelly](https://discuss.elastic.co/u/Shelly)\
**Post date:** [October 6, 2010, 3:15pm UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/1 "2010-10-06T15:15:20Z")

</div>

Is there a way to know when the deletion operation is failed? I don't see that the client delete operation throws any exception.  
Does it make this operation via a REST call? cause it says in the documentation that there is no indication for a failure on that: The delete operation will always return the the above result, even if the document did not exists. This is done for performance reasons.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 6, 2010, 3:17pm UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/2 "2010-10-06T15:17:10Z")

</div>

If the delete itself failed, then an error code will be returned and the  
body of the response will include the failure. A delete on non existent  
document will simply return and not throw an error.

-shay.banon

On Wed, Oct 6, 2010 at 5:15 PM, Shelly [shelly.mahlab@hp.com](mailto:shelly.mahlab@hp.com) wrote:

> Is there a way to know when the deletion operation is failed? I don't see  
> that the client delete operation throws any exception.  
> Does it make this operation via a REST call? cause it says in the  
> documentation that there is no indication for a failure on that: The delete  
> operation will always return the the above result, even if the document did  
> not exists. This is done for performance reasons.
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1643144.html](http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1643144.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Shelly](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Shelly](https://discuss.elastic.co/u/Shelly)\
**Post date:** [October 6, 2010, 3:53pm UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/3 "2010-10-06T15:53:37Z")

</div>

What should be the indication in the response in case of a failure? from what I see there are there parameters on that response - id, index and type. Do any of them get a special value if it fails?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 6, 2010, 6:29pm UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/4 "2010-10-06T18:29:37Z")

</div>

The HTTP response code will not be 200. The content of the body will include  
an "error" with a description of the error (no index / type / id).

-shay.banon

On Wed, Oct 6, 2010 at 5:53 PM, Shelly [shelly.mahlab@hp.com](mailto:shelly.mahlab@hp.com) wrote:

> ## What should be the indication in the response in case of a failure? from what I see there are there parameters on that response - id, index and type. Do any of them get a special value if it fails?
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1643426.html](http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1643426.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Shelly](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Shelly](https://discuss.elastic.co/u/Shelly)\
**Post date:** [October 7, 2010, 10:36am UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/5 "2010-10-07T10:36:44Z")

</div>

but I don't see any api on DeleteResponse to get the http message. it on has getId, getIndex and getType api.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 7, 2010, 10:46am UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/6 "2010-10-07T10:46:32Z")

</div>

Are you talking about the Java API? If so, then an exception will be thrown.

On Thu, Oct 7, 2010 at 12:36 PM, Shelly [shelly.mahlab@hp.com](mailto:shelly.mahlab@hp.com) wrote:

> ## but I don't see any api on DeleteResponse to get the http message. it on has getId, getIndex and getType api.
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1647566.html](http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1647566.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Shelly](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Shelly](https://discuss.elastic.co/u/Shelly)\
**Post date:** [October 7, 2010, 11:59am UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/7 "2010-10-07T11:59:28Z")

</div>

Is ther a way to know if the object we wanted to delete was not found? cause it doesn't throw any exception in that case.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 7, 2010, 12:00pm UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/8 "2010-10-07T12:00:51Z")

</div>

No, this is what I was trying to explain in the previous emails. An  
exception will not be thrown if the object is not there. You can try and get  
it before and check if it exists, but be careful of the near real time  
aspect of elasticsearch.

On Thu, Oct 7, 2010 at 1:59 PM, Shelly [shelly.mahlab@hp.com](mailto:shelly.mahlab@hp.com) wrote:

> ## Is ther a way to know if the object we wanted to delete was not found? cause it doesn't throw any exception in that case.
> 
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1647944.html](http://elasticsearch-users.115913.n3.nabble.com/How-can-I-see-if-there-is-an-exception-in-the-delete-operation-tp1643144p1647944.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:** [July 6, 2017, 4:18am UTC](https://discuss.elastic.co/t/how-can-i-see-if-there-is-an-exception-in-the-delete-operation/3414/9 "2017-07-06T04:18:16Z")

</div>


