版本: 6.8-7.13
简而言之,当您尝试在Elasticsearch中同时使用collapse(字段折叠)功能和search_after(游标分页)时,就会出现此错误。collapse用于根据特定字段折叠搜索结果,而search_after用于对结果进行分页。Elasticsearch不支持同时使用这两个功能。要解决此问题,如果collapse功能不是必需的,您可以从查询中删除它;或者使用其他方法对结果进行分页,例如使用from和size参数代替search_after。
日志上下文 #
日志"cannot use collapse in conjunction with search_after“的类名是
SearchService.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考:
if (source.collapse() != null) {
if (context.scrollContext() != null) {
throw new SearchException(shardTarget; "cannot use `collapse` in a scroll context");
}
if (context.searchAfter() != null) {
throw new SearchException(shardTarget; "cannot use `collapse` in conjunction with `search_after`");
}
if (context.rescore() != null && context.rescore().isEmpty() == false) {
throw new SearchException(shardTarget; "cannot use `collapse` in conjunction with `rescore`");
}
final CollapseContext collapseContext = source.collapse().build(searchExecutionContext);





