📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 6.8-8.9

简而言之,当 _count API 未正确放置在 Elasticsearch 请求路径的末尾时,会出现此错误。_count API 用于获取匹配特定查询的文档数量,它必须是路径中的最后一个元素。要解决此问题,请确保 _count 放置在请求路径的末尾。例如,不要使用 /index/type/_count/_search,而应使用 /index/type/_search/_count。同时,确保 _count 之后没有尾部斜杠或参数。

日志上下文 #

日志 _count must be the last element in the path 的类名是 InternalMultiBucketAggregation.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:

}
Aggregations aggregations = getAggregations();
String aggName = path.get(0);
if (aggName.equals("_count")) {
    if (path.size() > 1) {
        throw new InvalidAggregationPathException("_count must be the last element in the path");
    }
    return getDocCount();
} else if (aggName.equals("_key")) {
    if (path.size() > 1) {
        throw new InvalidAggregationPathException("_key must be the last element in the path");