--- title: "区间不支持小数值 – 如何解决此Elasticsearch异常" date: 2026-01-26 lastmod: 2026-01-26 description: "当在Elasticsearch中尝试为区间使用小数值时会报此错误。Elasticsearch仅支持整数区间值,可以通过四舍五入或将小数区间转换为更小的单位来解决。" tags: ["Elasticsearch异常", "区间配置", "数据类型错误", "日期直方图"] summary: " 版本: 6.8-8.9 简而言之,当您尝试在Elasticsearch中为区间使用小数值时,会发生此错误。Elasticsearch仅支持整数作为区间值。要解决此问题,您可以将小数值向上或向下舍入为最接近的整数。或者,您可以将小数区间转换为可以表示为整数的更小单位。例如,如果您有小数小时,可以将其转换为分钟或秒。 日志上下文 # 日志 “Fractional values are not supported for intervals” 的类名是 ExpressionBuilder.java。 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: // as the number parsing handles the -; there's no need to look at that Literal value = (Literal) visit(valueNumeric); Number numeric = (Number) value.fold(); if (Math.rint(numeric.doubleValue()) != numeric.longValue()) { throw new ParsingException(source(valueNumeric); "Fractional values are not supported for intervals"); } return Intervals.of(source(valueNumeric); numeric.longValue(); unit); } " --- > **版本:** 6.8-8.9 简而言之,当您尝试在Elasticsearch中为区间使用小数值时,会发生此错误。Elasticsearch仅支持整数作为区间值。要解决此问题,您可以将小数值向上或向下舍入为最接近的整数。或者,您可以将小数区间转换为可以表示为整数的更小单位。例如,如果您有小数小时,可以将其转换为分钟或秒。 日志上下文 ----------- 日志 "Fractional values are not supported for intervals" 的类名是 [ExpressionBuilder.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java // as the number parsing handles the -; there's no need to look at that Literal value = (Literal) visit(valueNumeric); Number numeric = (Number) value.fold(); if (Math.rint(numeric.doubleValue()) != numeric.longValue()) { throw new ParsingException(source(valueNumeric); "Fractional values are not supported for intervals"); } return Intervals.of(source(valueNumeric); numeric.longValue(); unit); } ```