--- title: "发现需要正数的 runs 值 – 如何解决此 Elasticsearch 异常" date: 2026-01-21 lastmod: 2026-01-21 description: "当Elasticsearch尝试执行需要正数'runs'值的任务时,如果发现无效或负数值会抛出此异常。本文介绍该错误的原因及解决方法。" tags: ["Elasticsearch异常", "正数值验证", "查询配置错误"] summary: " 版本: 7.16-8.9 简而言之,当 Elasticsearch 尝试执行需要正数 “runs” 值的任务,但发现无效或负数值时,会出现此错误。这可能是由于配置错误或编程错误导致的。要解决此问题,首先应检查设置 “runs” 值的配置或代码。确保将其设置为正整数。如果问题仍然存在,您可能需要调试应用程序以找出其设置无效 “runs” 值的原因。 日志上下文 # 日志 “A positive runs value is required; found [{}]” 的类名是 LogicalPlanBuilder.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的人参考: NumberContext numberCtx = sequenceTermCtx.number(); if (numberCtx instanceof IntegerLiteralContext) { Number number = (Number) visitIntegerLiteral((IntegerLiteralContext) numberCtx).fold(); long value = number.longValue(); if (value < 1) { throw new ParsingException(source(numberCtx); "A positive runs value is required; found [{}]"; value); } if (value > 100) { throw new ParsingException(source(numberCtx); "A query cannot be repeated more than 100 times; found [{}]"; value); } runs = (int) value; " --- > **版本:** 7.16-8.9 简而言之,当 Elasticsearch 尝试执行需要正数 "runs" 值的任务,但发现无效或负数值时,会出现此错误。这可能是由于配置错误或编程错误导致的。要解决此问题,首先应检查设置 "runs" 值的配置或代码。确保将其设置为正整数。如果问题仍然存在,您可能需要调试应用程序以找出其设置无效 "runs" 值的原因。 ## 日志上下文 日志 "A positive runs value is required; found [{}]" 的类名是 [LogicalPlanBuilder.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的人参考: ```java NumberContext numberCtx = sequenceTermCtx.number(); if (numberCtx instanceof IntegerLiteralContext) { Number number = (Number) visitIntegerLiteral((IntegerLiteralContext) numberCtx).fold(); long value = number.longValue(); if (value < 1) { throw new ParsingException(source(numberCtx); "A positive runs value is required; found [{}]"; value); } if (value > 100) { throw new ParsingException(source(numberCtx); "A query cannot be repeated more than 100 times; found [{}]"; value); } runs = (int) value; ```