📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 6.8-7.5

简要来说,当您尝试在 Elasticsearch 中恢复一个与现有打开索引同名的索引时,就会发生此错误。Elasticsearch 不允许这样做以防止数据丢失。要解决此问题,您可以在恢复之前关闭现有索引,重命名要恢复的索引,或者如果现有索引不再需要则将其删除。在执行这些操作之前,请务必备份您的数据,以防止意外数据丢失。

日志上下文 #

日志 “cannot restore index [” + renamedIndex + “] because an open index " 类名是 RestoreService.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用:

private void validateExistingIndex(IndexMetaData currentIndexMetaData; IndexMetaData snapshotIndexMetaData;
 String renamedIndex; boolean partial) {
 // 索引存在 - 检查它是否已关闭
 if (currentIndexMetaData.getState() != IndexMetaData.State.CLOSE) {
 // TODO: 为打开的索引启用恢复
 throw new SnapshotRestoreException(snapshot; "cannot restore index [" + renamedIndex + "] because an open index " +
 "with same name already exists in the cluster. Either close or delete the existing index or restore the " +
 "index under a different name by providing a rename pattern and replacement name");
 }
 // 索引存在 - 检查是否为部分恢复
 if (partial) {