--- title: "无法更新索引映射中路径类型的属性 – 如何解决此Elasticsearch异常" date: 2026-02-07 lastmod: 2026-02-07 description: "当尝试在索引创建后更新索引映射中某个类型的属性时,会出现此错误。Elasticsearch不允许对现有字段进行某些更改,例如更改数据类型或为文本字段启用'fielddata'选项。" tags: ["索引映射", "字段更新", "映射异常", "数据类型", "重索引"] summary: " 版本: 6.8-7.7 简而言之,当您在索引创建后尝试更新索引映射中某个类型的属性时,会出现此错误。Elasticsearch不允许对现有字段进行某些更改,例如更改数据类型或为文本字段启用"fielddata"选项。要解决此问题,您可以使用正确的映射重新索引数据,或者创建一个具有正确映射的新索引并将数据重新索引到新索引中。另外,您可以使用多字段(multi-field)来添加字段的分析版本。 日志上下文 # 日志"Can’t update attribute for type [" + path + “] in index mapping"的类名是 ObjectMapper.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: final ObjectMapper mergeIntoObjectMapper = (ObjectMapper) mergeIntoMapper; final ObjectMapper mergeWithObjectMapper = (ObjectMapper) mergeWithMapper; if (mergeIntoObjectMapper.isEnabled() != mergeWithObjectMapper.isEnabled()) { final String path = mergeWith.fullPath() + "." + mergeWithObjectMapper.simpleName() + ".enabled"; throw new MapperException("Can't update attribute for type [" + path + "] in index mapping"); } } } @Override " --- > **版本:** 6.8-7.7 简而言之,当您在索引创建后尝试更新索引映射中某个类型的属性时,会出现此错误。Elasticsearch不允许对现有字段进行某些更改,例如更改数据类型或为文本字段启用"fielddata"选项。要解决此问题,您可以使用正确的映射重新索引数据,或者创建一个具有正确映射的新索引并将数据重新索引到新索引中。另外,您可以使用多字段(multi-field)来添加字段的分析版本。 ## 日志上下文 日志"Can't update attribute for type [" + path + "] in index mapping"的类名是[ObjectMapper.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: ```java final ObjectMapper mergeIntoObjectMapper = (ObjectMapper) mergeIntoMapper; final ObjectMapper mergeWithObjectMapper = (ObjectMapper) mergeWithMapper; if (mergeIntoObjectMapper.isEnabled() != mergeWithObjectMapper.isEnabled()) { final String path = mergeWith.fullPath() + "." + mergeWithObjectMapper.simpleName() + ".enabled"; throw new MapperException("Can't update attribute for type [" + path + "] in index mapping"); } } } @Override ```