# Field value should not be updated if document already exists

**URL:** https://discuss.elastic.co/t/field-value-should-not-be-updated-if-document-already-exists/87349
**Category:** Logstash
**Created:** [May 27, 2017, 8:49pm UTC](https://discuss.elastic.co/t/field-value-should-not-be-updated-if-document-already-exists/87349 "2017-05-27T20:49:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![skairam](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@skairam](https://discuss.elastic.co/u/skairam)
#### Post date: [May 27, 2017, 8:49pm UTC](https://discuss.elastic.co/t/field-value-should-not-be-updated-if-document-already-exists/87349/1 "2017-05-27T20:49:38Z")

</div>

HI,

I have fields CRTE\_TMS, UPDATE\_TMS. In my logstash configuration, i have the following mutate, which adds fields with current time stamps value and i have doc\_as\_upsert =\> true. This script is updating the existing documents as expected. However, only problem is, CRTE\_TMS is always coming as current timestamp. How can i not update the CRTE\_TMS if the document is already existing? any inputs on this will be appreciated. thanks

```
mutate {
	add_field => {
		"UPDATE_TMS" => "%{[@timestamp]}"
     "CRTE_TMS" => "%{[@timestamp]}"

	}
}

```

output {  
elasticsearch{  
hosts =\> ["localhost:9200"]  
index =\> "index1"  
document\_type =\> "type1"  
document\_id =\> "%{LOG\_ID}"  
doc\_as\_upsert =\> true  
}

---

<div class="post-metadata">

### Author: ![skairam](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@skairam](https://discuss.elastic.co/u/skairam)
#### Post date: [May 30, 2017, 5:59pm UTC](https://discuss.elastic.co/t/field-value-should-not-be-updated-if-document-already-exists/87349/2 "2017-05-30T17:59:12Z")

</div>

Hi, i tried upsert, script and scripted\_upsert. nothing works. can anybody throw some inputs on this. appreciate it

---

<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: [June 27, 2017, 5:59pm UTC](https://discuss.elastic.co/t/field-value-should-not-be-updated-if-document-already-exists/87349/3 "2017-06-27T17:59:15Z")

</div>

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