版本: 6.8-8.9
简要来说,当您尝试在Elasticsearch查询中同时使用collapse(字段折叠)和rescore(重新评分)功能时,会发生此错误。Elasticsearch不支持同时使用这两个功能。
要解决此问题,您可以从查询中移除collapse或rescore功能。或者,您可以执行两个单独的查询,一个使用collapse,另一个使用rescore,然后手动合并结果。
日志上下文 #
日志"cannot use collapse in conjunction with rescore“的类名是
SearchService.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考:
if (source.collapse() != null) {
if (context.scrollContext() != null) {
throw new SearchException(shardTarget; "cannot use `collapse` in a scroll context");
}
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);
context.collapse(collapseContext);
}





