elasticsearch - aggregation_execution_exception : 聚合顺序路径无效,子路径指向非单桶聚合
问题描述
当我运行 es aggration 时:
"aggregations": {
"author": {
"terms": {
"field": "author",
"size": 100,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": {
"interactions-c>interactions-sum": "desc"
}
},
"aggregations": {
"interactions-c": {
"children": {
"type": "interactions"
},
"aggregations": {
"interactions-sum": {
"sum": {
"field": "interactions.likes"
}
}
}
}
}
}
}
例外:
{
"error" : {
"root_cause" : [
{
"type" : "aggregation_execution_exception",
"reason" : "Invalid aggregation order path [interactions-c>interactions-sum]. Buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end. Sub-path [interactions-c] points to non single-bucket aggregation"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "article_20200910",
"node" : "fLYvCQjfTEKG0QIivtn3Hg",
"reason" : {
"type" : "aggregation_execution_exception",
"reason" : "Invalid aggregation order path [interactions-c>interactions-sum]. Buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end. Sub-path [interactions-c] points to non single-bucket aggregation"
}
}
]
},
"status" : 500
}
这是我的索引映射:
{
"article" : {
"aliases" : { },
"mappings" : {
"properties" : {
"author" : {
"type" : "keyword"
},
"interactions" : {
"properties" : {
"comments" : {
"type" : "long"
},
"dislikes" : {
"type" : "long"
},
"forwards" : {
"type" : "long"
},
"likes" : {
"type" : "long"
},
"views" : {
"type" : "long"
}
}
},
"joinField" : {
"type" : "join",
"eager_global_ordinals" : false,
"relations" : {
"article" : [
"interactions"
]
}
}
}
}
}
}
我创建了一个使用连接字段(父:文章;子:交互)的索引,我想要什么:
- 按作者聚合交互次数(作者是父索引字段,交互是子字段)
- 然后按interations sum value desc排序
但是es说childern aggs不是一个单独的桶aggs!那么有什么办法吗?
解决方案
推荐阅读
- azure - 使用 Azure Databricks 从 ADLS 访问数据
- javascript - 无法重新定义第三方模块的属性
- windows - ddev-magento2 启动失败:ddev-ssh-agent 启动失败:docker-compose 启动失败
- javascript - 在 ExtJS 7.1.0 中使用 Font-Awesome 4.7.0
- php - 通过文件/文件夹的名称从 google drive api 搜索文件或文件夹?
- r - 在R中的空白行和特定单词之后提取文本
- node.js - 使用 Mongo DB 了解流量和限制
- checkstyle - Checkstyle 生成不完整的 XML 报告
- c# - Bot framework v4 如何在对话框中等待用户响应提示
- google-chrome - 如何修复 Tableau 嵌入式视图无法在 Chrome 中加载(更新 chrome 后)