# Is it possible to store document versions in Elastic Search

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-store-document-versions-in-elastic-search/337496>\
**Category:** Elasticsearch\
**Created:** [July 4, 2023, 12:51am UTC](https://discuss.elastic.co/t/is-it-possible-to-store-document-versions-in-elastic-search/337496 "2023-07-04T00:51:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dishatkr](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Dishatkr](https://discuss.elastic.co/u/Dishatkr)\
**Post date:** [July 4, 2023, 12:51am UTC](https://discuss.elastic.co/t/is-it-possible-to-store-document-versions-in-elastic-search/337496/1 "2023-07-04T00:51:43Z")

</div>

I have a question on storing different versions of a document in Elasticsearch, i.e. on document update we have to store the old version. We might not want to store all older versions, but at least multiple active versions of a document.

Is it possible to store versions/revisions in Elastic Search and how ?  
These versions not be integers, They can be 1.0.1,1.0.2 etc

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 4, 2023, 6:22am UTC](https://discuss.elastic.co/t/is-it-possible-to-store-document-versions-in-elastic-search/337496/2 "2023-07-04T06:22:55Z")

</div>

There's no built-in support for this. Which means that you need to manage this by yourself.

It could be by adding a `version_date` field within your document and using another `_id` for the next versions of the document. I'd recommend creating an `_id` using the functional id you want and append the timestamp in ms to it. Something like:

```auto
PUT /index/_doc/1-1688451697762
{
  "id": 1,
  "version": 1,
  "foo": "bar"
}
PUT /index/_doc/1-1688451768431
{
  "id": 1,
  "version": 2,
  "foo": "baz"
}

```

---

<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 1, 2023, 6:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-store-document-versions-in-elastic-search/337496/3 "2023-08-01T06:23:52Z")

</div>

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