--- title: "include_in_root 参数不能在嵌套对象映射上更新 - 如何解决此 Elasticsearch 异常" date: 2026-01-14 lastmod: 2026-01-14 description: "当尝试在 Elasticsearch 的嵌套对象映射上更新 include_in_root 参数时会发生此错误。该参数一旦设置就不可更改。可以通过重建索引或创建新索引并重新索引数据来解决问题。" tags: ["映射错误", "嵌套对象", "参数更新", "索引管理"] summary: "版本: 7.9-8.9 简要来说,当您尝试在 Elasticsearch 的嵌套对象映射上更新 [include_in_root] 参数时会发生此错误。该参数一旦设置就不可更改。要解决此问题,您可以使用正确的设置重新创建索引,或者创建具有所需设置的新索引,并将数据从旧索引重新索引到新索引。始终确保仔细规划索引结构以避免此类问题。 日志上下文 # 日志 “the [include_in_root] parameter can’t be updated on a nested object mapping” 的类名是 NestedObjectMapper.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: } else { if (includeInParent.value() != mergeWithObject.includeInParent.value()) { throw new MapperException("the [include_in_parent] parameter can't be updated on a nested object mapping"); } if (includeInRoot.value() != mergeWithObject.includeInRoot.value()) { throw new MapperException("the [include_in_root] parameter can't be updated on a nested object mapping"); } } if (parentBuilderContext instanceof NestedMapperBuilderContext nc) { if (nc." --- > **版本:** 7.9-8.9 简要来说,当您尝试在 Elasticsearch 的嵌套对象映射上更新 [include_in_root] 参数时会发生此错误。该参数一旦设置就不可更改。要解决此问题,您可以使用正确的设置重新创建索引,或者创建具有所需设置的新索引,并将数据从旧索引重新索引到新索引。始终确保仔细规划索引结构以避免此类问题。 日志上下文 ----------- 日志 "the [include\_in\_root] parameter can't be updated on a nested object mapping" 的类名是 [NestedObjectMapper.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: ```java } else { if (includeInParent.value() != mergeWithObject.includeInParent.value()) { throw new MapperException("the [include_in_parent] parameter can't be updated on a nested object mapping"); } if (includeInRoot.value() != mergeWithObject.includeInRoot.value()) { throw new MapperException("the [include_in_root] parameter can't be updated on a nested object mapping"); } } if (parentBuilderContext instanceof NestedMapperBuilderContext nc) { if (nc.parentIncludedInRoot && toMerge.includeInParent.value()) { toMerge.includeInRoot = Explicit.IMPLICIT_FALSE; ```