elasticsearch group sum top 10

{
  "version": true,
  "size": 0,
  "sort": [
    {
      "request_length": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "stored_fields": [
    "*"
  ],
  "script_fields": {},
  "docvalue_fields": [
    {
      "field": "@timestamp",
      "format": "date_time"
    }
  ],
  "_source": {
    "includes": []
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "bool": {
            "should": [
              {
                "match_phrase": {
                  "remote_addr": "1"
                }
              },
              {
                "match_phrase": {
                  "remote_addr": "1"
                }
              }
            ],
            "minimum_should_match": 1
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": "2023-06-28T10:50:00.000Z",
              "lte": "2023-06-28T11:05:28.781Z",
              "format": "strict_date_optional_time"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "sum_b_by_a": {
      "terms": {
        "field": "request_uri.keyword",
        "size": 10,
        "order": {
          "sum_b": "desc"
        }
      },
      "aggs": {
        "sum_b": {
          "sum": {
            "field": "request_length"
          }
        }
      }
    }
  }
}
posted @ 2023-07-04 21:35  萱乐庆foreverlove  阅读(12)  评论(0编辑  收藏  举报