# How to suppress DocumentMissingException?

**URL:** <https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921>\
**Category:** Elasticsearch\
**Created:** [February 27, 2016, 2:39pm UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921 "2016-02-27T14:39:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)\
**Post date:** [February 27, 2016, 2:39pm UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921/1 "2016-02-27T14:39:14Z")

</div>

Hi,

I have the following workflow in an application

1. update the doc with fresh data, if it succeeds, work is done
2. if the doc was missing, do some local work and when that succeeds, index the data

In step 2 it's important that the doc must only appear in ES when the local work is successfully done.

This works nicely, my only problem is every update on a -yet- nonexistent doc yields about 1.7 kiBs of stack trace into the ES log (and to that matter, onto its stdout by default), which is absolutely wasted, both CPU and IO/storage wise.

This is it:  
[2016-02-27 15:31:54,266][INFO][rest.suppressed] /idx1/object/954003.84.t/\_update Params: {index=idx1, id=954003.84.t, type=object, retry\_on\_conflict=8}  
RemoteTransportException[[dev00][192.168.0.170:9301][indices:data/write/update[s]]]; nested: DocumentMissingException[[object][954003.84.t]: document missing];  
Caused by: [idx1][[idx1][2]] DocumentMissingException[[object][954003.84.t]: document missing]  
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:90)  
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:79)  
at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:170)  
at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:164)  
at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:65)  
at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler.messageReceived(TransportInstanceSingleOperationAction.java:249)  
at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler.messageReceived(TransportInstanceSingleOperationAction.java:245)  
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:350)  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at java.lang.Thread.run(Thread.java:745)

How do I silence this?

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [February 29, 2016, 7:20pm UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921/2 "2016-02-29T19:20:24Z")

</div>

Use upsert:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#upserts](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#upserts)

Or you can try to change the log level:

[https://www.elastic.co/guide/en/elasticsearch/guide/current/logging.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/logging.html)

---

<div class="post-metadata">

**Author:** ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)\
**Post date:** [March 2, 2016, 12:27pm UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921/3 "2016-03-02T12:27:15Z")

</div>

Upsert is not good for me, because of #2 (I have work to do before indexing data).  
I want to disable only this exception, because it's excess and hurts performance badly. If I change the loglevel, it affects many other events.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [March 2, 2016, 4:35pm UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921/4 "2016-03-02T16:35:26Z")

</div>

So first, check that the doc exists or not in ES, then update or insert.

Note: you can use [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html) to bulk operations.

---

<div class="post-metadata">

**Author:** ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)\
**Post date:** [March 3, 2016, 9:07am UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921/5 "2016-03-03T09:07:44Z")

</div>

That's what I do now, but I feel it totally unecessary, when a simple update should do the job, without the overhead of that extra get.

---

<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 5, 2017, 11:11pm UTC](https://discuss.elastic.co/t/how-to-suppress-documentmissingexception/42921/6 "2017-07-05T23:11:43Z")

</div>


