Briefly, this error occurs when Elasticsearch cannot find the mapping version for a specific index. Mappings define the types of data in your index and how they are stored and indexed. If they are not found, Elasticsearch may attempt to recreate them. To resolve this issue, you can 1) Ensure that the mappings are correctly defined and saved in your Elasticsearch setup. 2) Check if the index exists and if it’s accessible. 3) If the index was deleted, you may need to recreate it with the correct mappings. 4) Ensure that your Elasticsearch cluster is running and healthy.
In addition we recommend you run the Elasticsearch Template Optimizer to fix problems in your data modeling.
It will analyze your templates to detect issues and improve search performance, reduce indexing bottlenecks and optimize storage utilization. The Template Optimizer is free and requires no installation.
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 }
Log Context
Log “Version of mappings for [{}] not found; recreating” classname is ElasticsearchMappings.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
@SuppressWarnings("unchecked") Mapmeta = (Map ) metadata.sourceAsMap().get("_meta"); if (meta != null) { String versionString = (String) meta.get("version"); if (versionString == null) { logger.info("Version of mappings for [{}] not found; recreating"; index); indicesToUpdate.add(index); continue; } Version mappingVersion = Version.fromString(versionString);