--- title: "映射更新不允许操作——如何解决此 Elasticsearch 异常" date: 2026-03-27 lastmod: 2026-03-27 description: "当尝试更新设置为只读或已关闭的索引映射时,会出现此错误。Elasticsearch 在这种情况下不允许映射更新。" tags: ["映射", "异常处理", "索引管理"] summary: "版本: 6.8-8.9 简而言之,当尝试更新已设置为只读或已关闭的索引的映射时,会出现此错误。Elasticsearch 在这种情况下不允许映射更新。要解决此问题,您可以使用 Elasticsearch API 将索引设置回读写模式,或重新打开已关闭的索引。此外,请确保在索引变为只读或关闭之前进行映射更改。 日志上下文 # 日志 “mapping updates are not allowed [” + operation + “]” 的类名是 RecoveryTarget.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: */ indexShard().updateRetentionLeasesOnReplica(retentionLeases); for (Translog.Operation operation : operations) { Engine.Result result = indexShard().applyTranslogOperation(operation; Engine.Operation.Origin.PEER_RECOVERY); if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) { throw new MapperException("mapping updates are not allowed [" + operation + "]"); } if (result.getFailure() != null) { if (Assertions.ENABLED && result.getFailure() instanceof MapperException == false) { throw new AssertionError("unexpected failure while replicating translog entry"; result." --- > **版本:** 6.8-8.9 简而言之,当尝试更新已设置为只读或已关闭的索引的映射时,会出现此错误。Elasticsearch 在这种情况下不允许映射更新。要解决此问题,您可以使用 Elasticsearch API 将索引设置回读写模式,或重新打开已关闭的索引。此外,请确保在索引变为只读或关闭之前进行映射更改。 日志上下文 ----------- 日志 "mapping updates are not allowed [" + operation + "]" 的类名是 [RecoveryTarget.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: ```java */ indexShard().updateRetentionLeasesOnReplica(retentionLeases); for (Translog.Operation operation : operations) { Engine.Result result = indexShard().applyTranslogOperation(operation; Engine.Operation.Origin.PEER_RECOVERY); if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) { throw new MapperException("mapping updates are not allowed [" + operation + "]"); } if (result.getFailure() != null) { if (Assertions.ENABLED && result.getFailure() instanceof MapperException == false) { throw new AssertionError("unexpected failure while replicating translog entry"; result.getFailure()); } ```