--- title: "Span within must include little - 如何解决此Elasticsearch异常" date: 2026-01-17 lastmod: 2026-01-17 description: "当Elasticsearch中的span_within查询缺少little span时出现的错误及解决方法" tags: ["span_within查询", "查询解析异常", "Span查询"] summary: " 版本: 6.8-8.9 简而言之,当Elasticsearch中的"span_within"查询不包含"little" span时,就会发生此错误。“span_within"查询允许您查找被另一个span包围的span。该错误表明缺少"little” span,即应该被包围的span。要解决此问题,请确保您的"span_within"查询同时包含"big"和"little" span。检查查询的语法和结构,确保其正确性。如果错误仍然存在,请考虑重新索引数据或检查数据不一致性。 日志上下文 # 日志"span_within must include [little]“的类名是 SpanWithinQueryBuilder.java。我们从Elasticsearch源代码中提取了以下内容,为那些寻求深入上下文的人提供参考: if (big == null) { throw new ParsingException(parser.getTokenLocation(); "span_within must include [big]"); } if (little == null) { throw new ParsingException(parser.getTokenLocation(); "span_within must include [little]"); } SpanWithinQueryBuilder query = new SpanWithinQueryBuilder(big; little); query.boost(boost).queryName(queryName); return query; " --- > **版本:** 6.8-8.9 简而言之,当Elasticsearch中的"span_within"查询不包含"little" span时,就会发生此错误。"span_within"查询允许您查找被另一个span包围的span。该错误表明缺少"little" span,即应该被包围的span。要解决此问题,请确保您的"span_within"查询同时包含"big"和"little" span。检查查询的语法和结构,确保其正确性。如果错误仍然存在,请考虑重新索引数据或检查数据不一致性。 ## 日志上下文 ----------- 日志"span\_within must include [little]"的类名是[SpanWithinQueryBuilder.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从Elasticsearch源代码中提取了以下内容,为那些寻求深入上下文的人提供参考: ```java if (big == null) { throw new ParsingException(parser.getTokenLocation(); "span_within must include [big]"); } if (little == null) { throw new ParsingException(parser.getTokenLocation(); "span_within must include [little]"); } SpanWithinQueryBuilder query = new SpanWithinQueryBuilder(big; little); query.boost(boost).queryName(queryName); return query; ```