版本: 7.6-8.9
简而言之,当 Elasticsearch 无法在集群状态中定位到指定的索引时,就会出现此错误。这可能是由于索引被删除、重命名或尚未创建造成的。要解决此问题,您可以检查索引名称是否存在拼写错误,使用 ‘GET /_cat/indices?v’ 命令验证索引是否存在,或者在索引已被删除的情况下重新创建索引。同时,请确保 Elasticsearch 集群状态健康且为最新状态。
日志上下文 #
日志 “Unable to find index in cluster state” 的类名是 RemoveCorruptedShardDataCommand.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:
shardId = Objects.requireNonNull(shardIdOption.value(options), "Shard ID is required");
indexMetadata = clusterState.metadata().index(indexName);
} if (indexMetadata == null) {
throw new ElasticsearchException("Unable to find index in cluster state");
} final IndexSettings indexSettings = new IndexSettings(indexMetadata, settings);
final Index index = indexMetadata.getIndex();
final ShardId shId = new ShardId(index, shardId);





