jhilden
jhilden

Reputation: 12429

ElasticSearch - Get Statistics on Aggregation results

I have the following simple aggregation:

GET index1/type1/_search
{
  "size": 0,
  "aggs": {
    "incidentID": {
      "terms": {
        "field": "incidentID",
        "size": 5
      }
    }
  }
}

Results are:

   "aggregations": {
      "incidentID": {
         "buckets": [
            {
               "key": "0A631EB1-01EF-DC28-9503-FC28FE695C6D",
               "doc_count": 233
            },
            {
               "key": "DF107D2B-CA1E-85C9-E01A-C966DC6F7051",
               "doc_count": 226
            },
            {
               "key": "60B8955F-38FD-8DFE-D374-4387668C8368",
               "doc_count": 220
            },
            {
               "key": "B787868A-F72E-63DC-D837-B3A864D9FFC6",
               "doc_count": 174
            },
            {
               "key": "C597EC5F-C60F-F3BA-61CB-4990F12C1893",
               "doc_count": 174
            }
         ]
      }
   }

What I want to do is get the "statistics" of the "doc_count" returned. I want:

  1. Min Value
  2. Max Value
  3. Average
  4. Standard Deviation

Upvotes: 2

Views: 496

Answers (1)

ppearcy
ppearcy

Reputation: 2762

No, this is not currently possible, here is the issue tracking the support: https://github.com/elasticsearch/elasticsearch/issues/8110

Obviously, it is possible to do this client side if you are able to pull the full list of all buckets into memory.

Upvotes: 3

Related Questions