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?
Internal versioning is the default version that starts with 1 and increments with each update, deletes included.
You use GET to retrieve a document and its source or stored fields from a particular index. Use HEAD to verify that a document exists. You can use the _source resource retrieve just the document source or verify that it exists.
Version control is the process by which different drafts and versions of a document or record are managed. It is a tool which tracks a series of draft documents, culminating in a final version. It provides an audit trail for the revision and update of these finalised versions.
A document version represents the structure of the document and its contents at a specific point in its history. A content version is an artifact that represents a record of the content item at a specific point in its history.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With