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