# Update documents

**URL:** <https://discuss.elastic.co/t/update-documents/140234>\
**Category:** Elasticsearch\
**Created:** [July 17, 2018, 12:39am UTC](https://discuss.elastic.co/t/update-documents/140234 "2018-07-17T00:39:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pri](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@pri](https://discuss.elastic.co/u/pri)\
**Post date:** [July 17, 2018, 12:39am UTC](https://discuss.elastic.co/t/update-documents/140234/1 "2018-07-17T00:39:34Z")

</div>

I have a generic question on updating existing documents. From almost a year of using Elasticsearch, I have come to believe that updating an elasticseach document is not the same as updating a record in an RDBMS. We are building a data centric solution that indexes documents based on "events" and "transactions". The events have already occurred by the time they are indexed into ES and hence will never be "updated". On the other hand we are also using ES to store defects. Defects change state(because of transactions). They go from "open" to "submitted" and then to "fixed" and "closed". If we were to index these defects data into ES, how do we handle state changes? Do we update the same defects record to show the latest state or do we create a new defect document every time we pull this data from the source?  
I want to know what will be the right approach here with respect to ES. We have been obviously updating the record in our old RDBMS based system.  
This important design consideration also means that our ES queries could be simple or complex. For example, if we indexed a new document every time when we pull from the source, I am having a hard time using Kibana to report on aggregated metrics.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 17, 2018, 12:46am UTC](https://discuss.elastic.co/t/update-documents/140234/2 "2018-07-17T00:46:38Z")

</div>

> [@pri](#):
>
> If we were to index these defects data into ES, how do we handle state changes? Do we update the same defects record to show the latest state or do we create a new defect document every time we pull this data from the source?

There's two patterns here.

The first is to store the changes in state to the defect as events/transactions and then display the latest to the user. This way you get a history of these changes you can go back on and analyse.  
The other is to just keep one document per defect and then update that when things change. Which means you always have the latest state, but no history (unless you expand that one defect to include it).

---

<div class="post-metadata">

**Author:** ![pri](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@pri](https://discuss.elastic.co/u/pri)\
**Post date:** [July 17, 2018, 1:32am UTC](https://discuss.elastic.co/t/update-documents/140234/3 "2018-07-17T01:32:30Z")

</div>

Thanks for the quick answer. If we were to choose the second approach where we update the same document every time the state changes, do we have to be aware any potential differences between an RDBMS update vs ES update. If there is any documentation regarding this that you would recommend, please share. I am specifically interested in concurrency, consistency, latency related information in update operations.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 17, 2018, 1:37am UTC](https://discuss.elastic.co/t/update-documents/140234/4 "2018-07-17T01:37:29Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/guide/2.x/partial-updates.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/partial-updates.html) is a little old, but the core concepts still apply.

---

<div class="post-metadata">

**Author:** ![pri](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@pri](https://discuss.elastic.co/u/pri)\
**Post date:** [July 17, 2018, 1:41am UTC](https://discuss.elastic.co/t/update-documents/140234/5 "2018-07-17T01:41:22Z")

</div>

Thank you. Will read

---

<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 14, 2018, 1:41am UTC](https://discuss.elastic.co/t/update-documents/140234/6 "2018-08-14T01:41:28Z")

</div>

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