Jay*_*hah 5 elasticsearch elasticsearch-5
{
"query": {
"match_all": {}
},
"from": 0,
"size": 0,
"aggs": {
"itineraryId": {
"terms": {
"field": "iid",
"size": 2147483647,
"order": [
{
"price>price>price.max": "desc"
}
]
},
"aggs": {
"duration": {
"stats": {
"field": "drn"
}
},
"price": {
"nested": {
"path": "prl"
},
"aggs": {
"price": {
"filter": {
"terms": {
"prl.cc.keyword": [
"USD"
]
}
},
"aggs": {
"price": {
"stats": {
"field": "prl.spl.vl"
}
}
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我收到错误:
“术语聚合顺序路径 [price>price>price.max] 无效。术语存储桶只能在子聚合器路径上进行排序,该子聚合器路径是由路径中的零个或多个单存储桶聚合以及最终的单存储桶或路径末端的指标聚合。子路径[价格]指向非单桶聚合”
如果我按持续时间聚合排序,查询工作正常
"order": [
{
"duration.max": "desc"
}
Run Code Online (Sandbox Code Playgroud)
那么有没有什么方法可以通过嵌套字段上的嵌套聚合来排序聚合,即如下所示?
"order": [
{
"price>price>price.max": "desc"
}
Run Code Online (Sandbox Code Playgroud)
正如 Val 在评论中指出的那样,ES 还不支持它。
在此之前,您可以首先聚合嵌套聚合,然后使用反向嵌套聚合来聚合文档根目录中存在的持续时间。
| 归档时间: |
|
| 查看次数: |
4673 次 |
| 最近记录: |