--- title: "多字段中不允许使用include_in_all - 如何解决此Elasticsearch异常" date: 2026-02-25 lastmod: 2026-02-25 description: "在Elasticsearch中,当在多字段(multi-fields)中使用include_in_all选项时会导致此错误。本文介绍该异常的原因及解决方案。" tags: ["字段映射", "多字段", "include_in_all", "映射异常", "copy_to"] summary: "版本: 6.8-6.8 简而言之,当在Elasticsearch的多字段中使用"include_in_all"选项时,会发生此错误。此选项在多字段中是不允许使用的,使用它会导致此错误。要解决此问题,您可以从多字段定义中删除"include_in_all"选项。或者,您可以使用"copy_to"参数将多个字段的值复制到一个组字段中,然后可以将该组字段作为单个字段进行搜索。这可以作为"include_in_all"功能的一种替代方案。 日志上下文 # 日志"include_in_all in multi fields is not allowed. Found the include_in_all in field [“的类名是 TypeParsers.java。 我们从Elasticsearch源代码中提取了以下内容,以便为那些寻求深入上下文的人提供参考: name; builder.fieldType.typeName()); } iterator.remove(); } else if (propName.equals("include_in_all")) { if (parserContext.isWithinMultiField()) { throw new MapperParsingException("include_in_all in multi fields is not allowed. Found the include_in_all in field [" + name + "] which is within a multi field."); } else if (parserContext.indexVersionCreated().onOrAfter(Version.V_6_0_0_alpha1)) { throw new MapperParsingException("[include_in_all] is not allowed for indices created on or after version 6." --- > **版本:** 6.8-6.8 简而言之,当在Elasticsearch的多字段中使用"include_in_all"选项时,会发生此错误。此选项在多字段中是不允许使用的,使用它会导致此错误。要解决此问题,您可以从多字段定义中删除"include_in_all"选项。或者,您可以使用"copy_to"参数将多个字段的值复制到一个组字段中,然后可以将该组字段作为单个字段进行搜索。这可以作为"include_in_all"功能的一种替代方案。 日志上下文 ----------- 日志"include\_in\_all in multi fields is not allowed. Found the include\_in\_all in field ["的类名是[TypeParsers.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从Elasticsearch源代码中提取了以下内容,以便为那些寻求深入上下文的人提供参考: ```java name; builder.fieldType.typeName()); } iterator.remove(); } else if (propName.equals("include_in_all")) { if (parserContext.isWithinMultiField()) { throw new MapperParsingException("include_in_all in multi fields is not allowed. Found the include_in_all in field [" + name + "] which is within a multi field."); } else if (parserContext.indexVersionCreated().onOrAfter(Version.V_6_0_0_alpha1)) { throw new MapperParsingException("[include_in_all] is not allowed for indices created on or after version 6.0.0 as " + "[_all] is deprecated. As a replacement; you can use an [copy_to] on mapping fields to create your " + "own catch all field."); ```