Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 645
Jabb Avatar asked Mar 28 '13 17:03

Jabb


People also ask

Which versioning is the default version that starts with 1 and increments with each update deletes included?

Internal versioning is the default version that starts with 1 and increments with each update, deletes included.

How do I view documents in Elasticsearch?

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.

How does versioning a document work?

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.

What are document 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.


1 Answers

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.

like image 62
javanna Avatar answered Oct 18 '22 10:10

javanna