# Unable to update the elasticsearch document properly

**URL:** <https://discuss.elastic.co/t/unable-to-update-the-elasticsearch-document-properly/175897>\
**Category:** Logstash\
**Created:** [April 8, 2019, 5:41pm UTC](https://discuss.elastic.co/t/unable-to-update-the-elasticsearch-document-properly/175897 "2019-04-08T17:41:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijaykumar\_Gundavara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijaykumar_gundavara/32/43693_2.png) [@Vijaykumar\_Gundavara](https://discuss.elastic.co/u/Vijaykumar_Gundavara)\
**Post date:** [April 8, 2019, 5:41pm UTC](https://discuss.elastic.co/t/unable-to-update-the-elasticsearch-document-properly/175897/1 "2019-04-08T17:41:48Z")

</div>

Hello,

I have this config file where I am trying to update an existing document with matching UUID only if the new document has greater timestamp than previous document. However, the field previoustime never seems to be populated properly or it is empty most of the times. When it does get populated, it gets populated from completely different document.

'input {beats{port =\> 5044}} filter{json{source =\> "message"}elasticsearch{hosts =\> ["172.17.0.2:9200"] query =\> "\_id={[uuid]}" index =\> "uuid39" fields =\> {"publishedtime" =\> "previoustime"}}} output {if[key] == "elasticsearch" and [previoustime] {if[previoustime] \< [publishedtime]{ elasticsearch { hosts =\> ["172.17.0.2:9200"] index =\> "uuid39" document\_id =\> "%{[uuid]}" }}}else if[key] == "elasticsearch"{elasticsearch {hosts =\> ["172.17.0.2:9200"] document\_id =\> "%{[uuid]}" index =\> "uuid39" }}else{}}'

---

<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:** [May 6, 2019, 5:43pm UTC](https://discuss.elastic.co/t/unable-to-update-the-elasticsearch-document-properly/175897/2 "2019-05-06T17:43:18Z")

</div>

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