# How to do an update-if-exists

**URL:** <https://discuss.elastic.co/t/how-to-do-an-update-if-exists/13116>\
**Category:** Elasticsearch\
**Created:** [August 8, 2013, 1:33am UTC](https://discuss.elastic.co/t/how-to-do-an-update-if-exists/13116 "2013-08-08T01:33:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Bellora](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_bellora/32/74372_2.png) [@Paul\_Bellora](https://discuss.elastic.co/u/Paul_Bellora)\
**Post date:** [August 8, 2013, 1:33am UTC](https://discuss.elastic.co/t/how-to-do-an-update-if-exists/13116/1 "2013-08-08T01:33:10Z")

</div>

I'm using the Java API to execute certain updates, using either scripts or  
partial documents. If a document to be updated isn't found for whatever  
reason, my requirements dictate that the code should fail silently and move  
on. Currently I'm catching DocumentMissingException and logging it. Is  
there a more eloquent way to implement this behavior? Ideally I'd like to  
avoid the exception being thrown and just check the response to see if the  
document exists, like with get.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:22am UTC](https://discuss.elastic.co/t/how-to-do-an-update-if-exists/13116/2 "2017-07-06T02:22:16Z")

</div>


