--- title: "请在之前指定序列by而不是之后 - 如何解决此Elasticsearch异常" date: 2026-03-31 lastmod: 2026-03-31 description: "此错误发生在Elasticsearch查询中的命令顺序不正确时,具体来说[by]命令应该在[with]命令之前指定,而不是之后。" tags: ["Elasticsearch异常", "序列查询", "语法错误", "查询优化"] summary: " 版本: 7.8-8.9 简而言之,当Elasticsearch查询中的命令顺序不正确时,就会发生此错误。具体来说,[by]命令应该在[with]命令之前指定,而不是之后。要解决此问题,您应该重新排列查询,使[by]命令位于[with]命令之前。此外,确保您的查询语法正确并遵循Elasticsearch指南。如果错误仍然存在,请考虑检查查询中是否存在其他潜在的语法或逻辑错误。 日志上下文 # 日志"Please specify sequence [by] before [with] not after"的类名是 LogicalPlanBuilder.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: @Override public Sequence visitSequence(SequenceContext ctx) { Source source = source(ctx); if (ctx.disallowed != null && ctx.sequenceParams() != null) { throw new ParsingException(source; "Please specify sequence [by] before [with] not after"); } ListparentJoinKeys = visitJoinKeys(ctx.by); TimeValue maxSpan = visitSequenceParams(ctx.sequenceParams()); " --- > **版本:** 7.8-8.9 简而言之,当Elasticsearch查询中的命令顺序不正确时,就会发生此错误。具体来说,[by]命令应该在[with]命令之前指定,而不是之后。要解决此问题,您应该重新排列查询,使[by]命令位于[with]命令之前。此外,确保您的查询语法正确并遵循Elasticsearch指南。如果错误仍然存在,请考虑检查查询中是否存在其他潜在的语法或逻辑错误。 日志上下文 ----------- 日志"Please specify sequence [by] before [with] not after"的类名是[LogicalPlanBuilder.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java @Override public Sequence visitSequence(SequenceContext ctx) { Source source = source(ctx); if (ctx.disallowed != null && ctx.sequenceParams() != null) { throw new ParsingException(source; "Please specify sequence [by] before [with] not after"); } ListparentJoinKeys = visitJoinKeys(ctx.by); TimeValue maxSpan = visitSequenceParams(ctx.sequenceParams()); ```