--- title: "Extended bounds min 不能大于 max 值 - 如何解决此 Elasticsearch 异常" date: 2026-02-15 lastmod: 2026-02-15 description: "Elasticsearch 聚合查询中 extended_bounds 参数的 min 值大于 max 值导致的异常及解决方法" tags: ["聚合查询", "直方图聚合", "扩展边界", "查询错误"] summary: "版本: 6.8-7.4 简要来说,当 Elasticsearch 聚合查询中 extended_bounds 参数的 min 值被设置为高于 max 值时,就会发生此错误。这是不正确的,因为 min 值应该始终小于或等于 max 值。 要解决此问题,你应该调整查询以确保 min 值小于或等于 max 值。或者,如果你的查询不需要 extended_bounds 参数,可以将其删除。 日志上下文 # 日志 “[extended_bounds.min][” + min + “] cannot be greater than” 的类名是 ExtendedBounds.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考: if (maxAsStr != null) { // TODO: 我们是否应该传递 roundUp=true? max = format.parseLong(maxAsStr, false, context.getQueryShardContext()::nowInMillis); } if (min != null && max != null && min.compareTo(max) > 0) { throw new SearchParseException(context, "[extended_bounds." --- > **版本:** 6.8-7.4 简要来说,当 Elasticsearch 聚合查询中 `extended_bounds` 参数的 `min` 值被设置为高于 `max` 值时,就会发生此错误。这是不正确的,因为 `min` 值应该始终小于或等于 `max` 值。 要解决此问题,你应该调整查询以确保 `min` 值小于或等于 `max` 值。或者,如果你的查询不需要 `extended_bounds` 参数,可以将其删除。 ## 日志上下文 日志 "[extended\_bounds.min][" + min + "] cannot be greater than" 的类名是 [ExtendedBounds.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考: ```java if (maxAsStr != null) { // TODO: 我们是否应该传递 roundUp=true? max = format.parseLong(maxAsStr, false, context.getQueryShardContext()::nowInMillis); } if (min != null && max != null && min.compareTo(max) > 0) { throw new SearchParseException(context, "[extended_bounds.min][" + min + "] cannot be greater than " + "[extended_bounds.max][" + max + "] for histogram aggregation [" + aggName + "]", null); } return new ExtendedBounds(min, max, minAsStr, maxAsStr); } ```