ES求中位數


ES中沒有像求平均值一樣,可以直接獲取中位數的方法,可以使用獲取某個數值字段50%的值的方法來獲取。

GET applog-xmllog-2021-04-08/_search?pretty
{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "system_code.keyword": "InterfPlus"
          }
        },
        {
          "term": {
            "method_cname.keyword": "查詢航班(IBE+Shop)"
          }
        },
        {
          "range": {
            "created_time": {
              "lte": "now",
              "gte": "now-30m"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "percentiles": {
      "percentiles": {
        "field": "duration",
        "percents": [
          50
        ]
      }
    }
  }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM