# 快照恢复异常：[repo:snapshot/xxxxx]无法恢复索引[my_index]，因为同名索引已存在且处于打开状态

- **ID:** `elasticsearch/snapshot-restore-index-already-exists`
- **领域:** elasticsearch
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

恢复操作失败，因为目标集群已存在与快照中同名的打开索引。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.17.0 | active | — | — |
| 8.11.0 | active | — | — |
| 8.12.0 | active | — | — |

## 解决方案

1. ```
   Close the existing index before restoring: `POST /my_index/_close`, then restore the snapshot with the same name, and after restore, optionally open the original index or delete it.
   ```
2. ```
   Use the `rename_pattern` and `rename_replacement` options in the restore request to restore to a different index name: `POST /_snapshot/repo/snapshot/_restore {"indices": "my_index", "rename_pattern": "my_(.+)", "rename_replacement": "restored_$1"}`.
   ```
3. ```
   If the existing index is not needed, delete it with `DELETE /my_index` and then restore directly.
   ```

## 无效尝试

- **** — Deleting the index removes all current data; the snapshot may not have the latest updates. (70% 失败率)
- **** — Renaming may break application references or alias configurations. (60% 失败率)
- **** — Incorrect pattern matching may overwrite unrelated indices or create duplicate names. (75% 失败率)
