This version of the OpenSearch documentation is no longer maintained. For the latest version, see the current documentation. For information about OpenSearch version maintenance, see Release Schedule and Maintenance Policy.

Stats aggregations

The stats metric is a multi-value metric aggregation that returns all basic metrics such as min, max, sum, avg, and value_count in one aggregation query.

The following example returns the basic stats for the taxful_total_price field:

  1. GET opensearch_dashboards_sample_data_ecommerce/_search
  2. {
  3. "size": 0,
  4. "aggs": {
  5. "stats_taxful_total_price": {
  6. "stats": {
  7. "field": "taxful_total_price"
  8. }
  9. }
  10. }
  11. }

copy

Example response

  1. ...
  2. "aggregations" : {
  3. "stats_taxful_total_price" : {
  4. "count" : 4675,
  5. "min" : 6.98828125,
  6. "max" : 2250.0,
  7. "avg" : 75.05542864304813,
  8. "sum" : 350884.12890625
  9. }
  10. }
  11. }