使用 shuf 来打乱一个文件中的行或是选择文件中一个随机的行。

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

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

{
"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"
}
}
}
}
}
}
已邀请:

要回复问题请先登录注册