Document Versioning Elasticsearch: How do I compare different document versions?

17,948

elasticsearch keeps by default track of the version of the indexed documents within the _version field. That means that the first time you index a document it'll get the version 1, and every time you update it its version will be incremented.

It doesn't mean that elasticsearch keeps all the versions of the document.

The version is handy especially if you need to perform optimistic locking. Let's say you get a document and you want to update it, you can make sure you are updating that same version of the document and not other versions that could have been generated by concurrent updates (which might have happened between your get and your update).

You can have a look at this blog to know more and see it in practice.

Share:
17,948

Related videos on Youtube

Jabb
Author by

Jabb

Updated on September 16, 2022

Comments

  • Jabb
    Jabb over 1 year

    Just discovered that Elasticsearch features versioning of documents. Awesome! Truly.

    But what is the right approach to compare different versions of a document and have all differences extracted. Is there a query for that available or would I have to do that in the business logic?

  • DrTech
    DrTech about 11 years
  • javanna
    javanna about 11 years
    @DrTech Nice one Clinton! Thanks for the link!