10

I am new to Elasticsearch with a very basic question to ask;

I am planning to use Elasticsearch as a document store and with storing documents, one of the requirements I have is to maintain historical data as well.

So I can post documents to Elasticsearch successfully, but when I post an updated version of the same document - as I've seen - original copy is overwritten. What I need is to have Elasticsearch keep older copies stored as well which I should be able to access via specifying a version number.

I have looked at its native support for document versioning which works great for concurrency control but doesn't look like it keeps a history of previous versions and only the latest version is available.

Could someone guide me in the right direction here please.

Jay
  • 177
  • 2
  • 12
  • http://stackoverflow.com/questions/8218309/can-we-retrieve-previous-source-docs-with-elastic-search-versions – Ashalynd May 12 '14 at 09:22
  • ES increments document version by +1 after each succesfull update or delete. But it does not keep track of document history. This is by design to solve concurrency issues. You need to implement tracking document history yourself in a separate index. https://kb.objectrocket.com/elasticsearch/elasticsearch-version-history-what-it-does-and-doesnt-do-501 – lubosdz Jun 08 '21 at 09:03

1 Answers1

11

As stated in here ES do not store older versions.

Note that Elasticsearch do not store older versions of documents. Only the current version can be retrieved.

You should store the history in a separate index. And insert into the history index on every update to the original document index.

Volkan Vardar
  • 314
  • 3
  • 8