Link Search Menu Expand Document
POST /sales/_search?size=0
{
  "aggs": {
    "t_shirts": {
      "filter": { "term": { "type": "t-shirt" } },
      "aggs": {
        "avg_price": { "avg": { "field": "price" } }
      }
    }
  }
}
  • resp
{
  ...
  "aggregations": {
    "t_shirts": {
      "doc_count": 3,
      "avg_price": { "value": 128.33333333333334 }
    }
  }
}

Copyright © 2020 Thence LLC