Is it possible to store document versions in Elastic Search

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

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:

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

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