要不要再翻翻文档呢?

通过 BucketScript 得到的聚合结果如何进行排序?

Elasticsearch | 作者 ivanshell | 发布于2016年08月19日 | 阅读数:6031

{
"from" : 0,
"size" : 20,
"query" : {
"bool" : {
"must" : [ {
"range" : {
"timestamp" : {
"from" : 1469952000000,
"to" : 1472544000000,
"include_lower" : true,
"include_upper" : true
}
}
} ]
}
},
"explain" : false,
"_source" : false,
"aggregations" : {
"byServiceName" : {
"terms" : {
"field" : "serviceName",
"order" : {
"byAvg.value" : "desc"
}
},
"aggregations" : {
"byCounter" : {
"sum" : {
"field" : "counter"
}
},
"byTotal" : {
"sum" : {
"field" : "total"
}
}
"byAvg" : {
"bucket_script" : {
"script" : {
"inline" : "total / counter"
},
"buckets_path" : {
"total" : "byTotal",
"counter" : "byCounter"
}
}
},
"byAvgHaving" : {
"bucket_selector" : {
"script" : {
"inline" : "avg > 3000"
},
"buckets_path" : {
"avg" : "byAvg"
}
}
},
"byMin" : {
"min" : {
"field" : "min"
}
}
}
}
}
}
已邀请:

要回复问题请先登录注册