gpt4 book ai didi

ElasticSearch - 通过嵌套字段上的嵌套聚合对聚合进行排序

转载 作者:行者123 更新时间:2023-12-02 22:11:21 25 4
gpt4 key购买 nike

{
"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"
}
}
}
}
}
}
}
}
}
}
在这里,我收到错误:

"Invalid terms aggregation order path [price>price>price.max]. Termsbuckets can only be sorted on a sub-aggregator path that is built outof zero or more single-bucket aggregations within the path and a finalsingle-bucket or a metrics aggregation at the path end. Sub-path[price] points to non single-bucket aggregation"


如果我按持续时间聚合排序,查询工作正常
"order": [
{
"duration.max": "desc"
}
那么有没有办法通过嵌套字段上的嵌套聚合对聚合进行排序,即如下所示?
"order": [
{
"price>price>price.max": "desc"
}

最佳答案

正如 Val 在评论中指出的那样,ES 尚不支持它。

在此之前,您可以先聚合嵌套聚合,然后使用反向嵌套聚合来聚合文档根中存在的持续时间。

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html

关于ElasticSearch - 通过嵌套字段上的嵌套聚合对聚合进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43451667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com