--- title: "include_in_parent 参数无法在嵌套对象映射上更新 – 如何解决此 Elasticsearch 异常" date: 2026-02-15 lastmod: 2026-02-15 description: "当尝试在 Elasticsearch 的嵌套对象映射上更新 include_in_parent 参数时会发生此错误。该参数一旦设置就不可变且无法更改。" tags: ["嵌套对象", "映射更新", "include_in_parent", "索引重建"] summary: " 版本: 7.9-8.9 简而言之,当尝试在 Elasticsearch 的嵌套对象映射上更新 [include_in_parent] 参数时会发生此错误。该参数一旦设置就不可变且无法更改。要解决此问题,您可以使用所需的设置重新创建索引,或者使用正确的设置创建新索引,并将数据从旧索引重新索引到新索引。 日志上下文 # 日志 “the [include_in_parent] parameter can’t be updated on a nested object mapping” 的类名是 NestedObjectMapper.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: if (mergeWithObject.includeInRoot.explicit()) { toMerge.includeInRoot = mergeWithObject.includeInRoot; } } 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"); } } " --- > **版本:** 7.9-8.9 简而言之,当尝试在 Elasticsearch 的嵌套对象映射上更新 [include_in_parent] 参数时会发生此错误。该参数一旦设置就不可变且无法更改。要解决此问题,您可以使用所需的设置重新创建索引,或者使用正确的设置创建新索引,并将数据从旧索引重新索引到新索引。 日志上下文 ----------- 日志 "the [include_in_parent] 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 if (mergeWithObject.includeInRoot.explicit()) { toMerge.includeInRoot = mergeWithObject.includeInRoot; } } 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"); } } ```