# Logstash "doc\_as\_upsert" --\> Error 404

**URL:** <https://discuss.elastic.co/t/logstash-doc-as-upsert-error-404/36146>\
**Category:** Logstash\
**Created:** [December 2, 2015, 10:39am UTC](https://discuss.elastic.co/t/logstash-doc-as-upsert-error-404/36146 "2015-12-02T10:39:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcelHallmann](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MarcelHallmann](https://discuss.elastic.co/u/MarcelHallmann)\
**Post date:** [December 2, 2015, 10:39am UTC](https://discuss.elastic.co/t/logstash-doc-as-upsert-error-404/36146/1 "2015-12-02T10:39:56Z")

</div>

Hi,

I'm trying to upgrade to logstash 2.x and can't figure out how to use the "upsert" correctly.  
In my config I have:

```
output {
  elasticsearch {
        action => "update"
        doc_as_upsert => true
        document_id => "%{[myId]}"
        hosts => "localhost:9200"
        index => "myindex"
        document_type => "%{[_type]}"
        template_name => "mytemplate"
        template => "C:\\local\\repos\\logstash\\mytemplate.json"
        template_overwrite => "true"
        idle_flush_time => 0.3
    }
}

```

But when I try start logstash I get this error:

> "Failed action. ", :status=\>404, :action=\>["update // content of the message // "status"=\>404, "error"=\>"DocumentMissingException[[myIndex][-1] [MESSAGE][f85c9ea2-3b13-47a1-9f33-5eb54f3a0e58]: document missing]"}}, :level=\>:warn}

I thought that the document would be inserted if it does not exist yet?

---

<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, 5:20am UTC](https://discuss.elastic.co/t/logstash-doc-as-upsert-error-404/36146/2 "2017-07-06T05:20:25Z")

</div>


