--- title: "ValuesSource type - 如何解决此 Elasticsearch 异常" date: 2026-01-09 lastmod: 2026-01-09 description: "Elasticsearch 异常解决方案" tags: ["Elasticsearch", "异常处理"] summary: " 版本: 7.8-7.15 简而言之,当索引映射中的字段类型与聚合或查询期望的字段类型不匹配时,就会出现此错误。例如,您可能尝试对文本字段执行数值聚合。要解决此问题,请确保查询中的字段类型与索引映射中的字段类型匹配。如有必要,请使用正确的字段类型重新索引数据。或者,您可以在查询或聚合期间使用脚本转换字段类型。 日志上下文 # 日志“ValuesSource type”的类名是 MultiValuesSource.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考: public NumericMultiValuesSource(MapvaluesSourceConfigs) { values = new HashMap<>(valuesSourceConfigs.size()); for (Map.Entryentry : valuesSourceConfigs.entrySet()) { final ValuesSource valuesSource = entry.getValue().getValuesSource(); if (valuesSource instanceof ValuesSource.Numeric == false) { throw new AggregationExecutionException("ValuesSource type " + valuesSource.toString() + "is not supported for multi-valued aggregation"); } values.put(entry.getKey(); (ValuesSource.Numeric) valuesSource); } } " --- > **版本:** 7.8-7.15 简而言之,当索引映射中的字段类型与聚合或查询期望的字段类型不匹配时,就会出现此错误。例如,您可能尝试对文本字段执行数值聚合。要解决此问题,请确保查询中的字段类型与索引映射中的字段类型匹配。如有必要,请使用正确的字段类型重新索引数据。或者,您可以在查询或聚合期间使用脚本转换字段类型。 日志上下文 ----------- 日志“ValuesSource type”的类名是 [MultiValuesSource.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考: ```java public NumericMultiValuesSource(MapvaluesSourceConfigs) { values = new HashMap<>(valuesSourceConfigs.size()); for (Map.Entryentry : valuesSourceConfigs.entrySet()) { final ValuesSource valuesSource = entry.getValue().getValuesSource(); if (valuesSource instanceof ValuesSource.Numeric == false) { throw new AggregationExecutionException("ValuesSource type " + valuesSource.toString() + "is not supported for multi-valued aggregation"); } values.put(entry.getKey(); (ValuesSource.Numeric) valuesSource); } } ```