How to fix Elasticsearch mapping errors
Starting with the February 2023 mainnet upgrade new constrains for Elasticsearch indices were added. Therefore, one can notice that the observers that index data in the Elasticsearch will remain stuck with an error similar to:
dataDispatcher.doWork could not index item (will retry) error = { "index": "operations-000001",
"id": "", "statusCode": 400, "errorType": "mapper_parsing_exception", "reason": "failed to parse field [esdtValuesNum] of type [long] in document
If an observer with elastic-indexer
enabled will throw a log.WARN
that contains "errorType": "mapper_parsing_exception"
for an index, then one should follow the next steps:
In the example below we will repair the operations
index.
Stop the observers nodes that index data in the Elasticsearch cluster.
Delete affected index:
operations
Create the index again with the correct mappings:
- in order to do this, clone this repository
- checkout this branch
mappings-for-all-fields
cd elasticreindexer/indices-creator
- open
config/cluster.toml
file and update it with the information about your cluster and at theenabled-indices
section put["operations"]
- build the binary and run it in order to create the index with the correct mappings.
After the index was created you can start again the observers.
Copy all the data from a public Elasticsearch cluster for the index with problems.
- in order to do this follow the steps from this documentation (only for the index/indices with problems)