# How to ignore exceptions when bulk update with pyspark if doc doesn't exist

**URL:** <https://discuss.elastic.co/t/how-to-ignore-exceptions-when-bulk-update-with-pyspark-if-doc-doesnt-exist/90739>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [June 25, 2017, 3:05am UTC](https://discuss.elastic.co/t/how-to-ignore-exceptions-when-bulk-update-with-pyspark-if-doc-doesnt-exist/90739 "2017-06-25T03:05:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tree](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tree](https://discuss.elastic.co/u/tree)\
**Post date:** [June 25, 2017, 3:05am UTC](https://discuss.elastic.co/t/how-to-ignore-exceptions-when-bulk-update-with-pyspark-if-doc-doesnt-exist/90739/1 "2017-06-25T03:05:28Z")

</div>

Hi,

I am trying to do an update operation with elasticsearch hadoop package in pyspark. It says on the documentation that if no data is found, an exception is thrown. What is the best way to handle this exception? Or is it possible to pass something like raise\_on\_exception=False, raise\_on\_error=False provided with python elasticsearch API?

Thanks!

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [June 26, 2017, 9:46pm UTC](https://discuss.elastic.co/t/how-to-ignore-exceptions-when-bulk-update-with-pyspark-if-doc-doesnt-exist/90739/2 "2017-06-26T21:46:04Z")

</div>

@tree currently there is no way to supress the error when it occurs. If a value is missing when an update is executed, there's nothing for the connector to do but fail the task. A different option would be to avoid the update operation and instead try to stick to the upsert operation as it has fewer cases where it might fail.

---

<div class="post-metadata">

**Author:** ![tree](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tree](https://discuss.elastic.co/u/tree)\
**Post date:** [June 27, 2017, 1:17pm UTC](https://discuss.elastic.co/t/how-to-ignore-exceptions-when-bulk-update-with-pyspark-if-doc-doesnt-exist/90739/3 "2017-06-27T13:17:05Z")

</div>

Thank you! @james.baiera

---

<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 25, 2017, 1:17pm UTC](https://discuss.elastic.co/t/how-to-ignore-exceptions-when-bulk-update-with-pyspark-if-doc-doesnt-exist/90739/4 "2017-07-25T13:17:07Z")

</div>

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