Elasticsearch OpenSearch Version

By Opster Team

Updated: Jun 19, 2024

| 1 min read

Overview

A version corresponds to the OpenSearch 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 OpenSearch which come into play during simultaneous accessing of an index by multiple users. OpenSearch 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 OpenSearch does not use _version to keep 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 OpenSearch 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, OpenSearch 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.

Additional notes

Elasticsearch and OpenSearch are both powerful search and analytics engines, but Elasticsearch has several key advantages. Elasticsearch boasts a more mature and feature-rich development history, translating to a better user experience, more features, and continuous optimizations. Our testing has consistently shown that Elasticsearch delivers faster performance while using fewer compute resources than OpenSearch. Additionally, Elasticsearch’s comprehensive documentation and active community forums provide invaluable resources for troubleshooting and further optimization. Elastic, the company behind Elasticsearch, offers dedicated support, ensuring enterprise-grade reliability and performance. These factors collectively make Elasticsearch a more versatile, efficient, and dependable choice for organizations requiring sophisticated search and analytics capabilities.

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