# Document id upsert update fields in new object and keep others

**URL:** <https://discuss.elastic.co/t/document-id-upsert-update-fields-in-new-object-and-keep-others/92285>\
**Category:** Logstash\
**Created:** [July 7, 2017, 2:32pm UTC](https://discuss.elastic.co/t/document-id-upsert-update-fields-in-new-object-and-keep-others/92285 "2017-07-07T14:32:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Cross](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_cross/32/104500_2.png) [@Justin\_Cross](https://discuss.elastic.co/u/Justin_Cross)\
**Post date:** [July 7, 2017, 2:32pm UTC](https://discuss.elastic.co/t/document-id-upsert-update-fields-in-new-object-and-keep-others/92285/1 "2017-07-07T14:32:10Z")

</div>

Hi,  
I am using Elasticsearch/logstash and have an issue when updating an existing index through logstash

imagine the \_source object the first time is:

```
    "_source": {
            "id": "1234",
            "msg_receive_ts": "2017-07-07T14:08:50.115Z",
            "event_status": "SUCCESS",
            "code": "ABCD"
        },

```

Then another row/object comes in on that same document id (1234)

```
    "_source": {
            "id": "1234",
            "msg_receive_ts": "2017-07-07T16:08:50.115Z",
            "event_status": "FAILED"
        },

```

It seems like the whole object is getting replaced. Before I had a 'code' field but now it's gone with this update/upsert through logstash to elasticsearch.

What I want to happen is only the fields that are in the new object get replaced and the other old ones stay.  
So what I would like to see is:

```
    "_source": {
            "id": "1234",
            "msg_receive_ts": "2017-07-07T16:08:50.115Z",
            "event_status": "FAILED",
            "code": "ABCD"
        },

```

Is this easily achievable? Please help.

My output is something like:

```
  output {
       elasticsearch{
           hosts=> ["x.x.x.x:9200"]
           index => "test"
           document_id => "%{id}"
       }
  }
```

---

<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:** [August 4, 2017, 2:39pm UTC](https://discuss.elastic.co/t/document-id-upsert-update-fields-in-new-object-and-keep-others/92285/3 "2017-08-04T14:39:35Z")

</div>

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