Elasticsearch Version

By Opster Team

Updated: Jan 28, 2024

| 1 min read

Overview

A version corresponds to the Elasticsearch built-in tracking system that tracks the changes in each document’s update. When a document is indexed for the first time, it is assigned a version 1 using _version key. When the same document gets a subsequent update, the _version is incremented by 1 with every index, update or delete API call.

What it is used for

A version is used to handle the concurrency issues in Elasticsearch which come into play during simultaneous accessing of an index by multiple users. Elasticsearch handles this issue with an optimistic locking concept using the _version parameter to avoid letting multiple users edit the same document at the same time and protects users from generating incorrect data.

Notes

You cannot see the history of the document using _version. That means Elasticsearch does not use _version to keep a track of original changes that had been performed on the document. For example, if a document has been updated 10 times, it’s _version would be marked by Elasticsearch as 11, but you cannot go back and see what version 5 of the document looked like. This has to be implemented independently.

Common problems

If optimistic locking is not implemented while making updates to a document, Elasticsearch may return a conflict error with the 409 status code, which means that multiple users are trying to update the same version of the document at the same time.

POST /ratings/123?version=50
{
    "name": "Joker",
    "rating": 50
}

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?


Related log errors to this ES concept


Failure when trying to load missing version information from snapshot metadata
Oldest index version recorded in NodeMetadata
Failed to retrieve mapping version for index recreating
JobId Could not retrieve destination index version
Updating existing license to the new version n nOld license n n n New license n
Could not retrieve destination index version
Failed verifying snapshot version
Remote node is build of version but this node is build of version
Upgrading legacy template for from version to version
Upgrading component template for from version to version
Upgrading composable template for from version to version
The security index mapping is for version but API Key metadata requires

< Page: 2 of 5 >