1. 程式人生 > >elasticsearch 查詢聚合結果排序

elasticsearch 查詢聚合結果排序

       
{
  "query" : {
    "bool" : {
      "filter" : [
        {
          "term" : {
            "type" : {
              "value" : "URL",
              "boost" : 1.0
            }
          }
        }
      ]
    }
  },
  "aggregations" : {
    "CATEGORY" : {
      "terms" : {
        "field" : "name",
        "size" : 5,
        "order" : {"responseTime.avg" : "asc" }
}, "aggregations" : { "responseTime" : { "extended_stats" : { "field" : "durationInMillis", "sigma" : 2.0 } }, "error" : { "sum" : { "script" : { "inline" : "def errorTemp=doc['status'].value; if(errorTemp=='0'){return 0;}else{return 1;}", "lang" : "painless" } } }, "apdex" : { "avg" : { "script" : { "inline" : "def responseTemp=doc['durationInMillis'].value; if(responseTemp>params.threshold){return 0.5;}else{return 1;}", "lang" : "painless", "params" : { "threshold" : 20.0 } } } }, "errorRate" : { "percentile_ranks" : { "script" : { "inline" : "def errorTemp=doc['status'].value; if(errorTemp=='0'){return 1;}else{return 0;}", "lang" : "painless" }, "values" : [ 0.0 ], "keyed" : true, "tdigest" : { "compression" : 100.0 } } } } } } }