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.

Extended stats aggregations

The extended_stats aggregation is an extended version of the stats aggregation. Apart from including basic stats, extended_stats also returns stats such as sum_of_squares, variance, and std_deviation. The following example returns extended stats for taxful_total_price:

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

copy

Example response

  1. ...
  2. "aggregations" : {
  3. "extended_stats_taxful_total_price" : {
  4. "count" : 4675,
  5. "min" : 6.98828125,
  6. "max" : 2250.0,
  7. "avg" : 75.05542864304813,
  8. "sum" : 350884.12890625,
  9. "sum_of_squares" : 3.9367749294174194E7,
  10. "variance" : 2787.59157113862,
  11. "variance_population" : 2787.59157113862,
  12. "variance_sampling" : 2788.187974983536,
  13. "std_deviation" : 52.79764740155209,
  14. "std_deviation_population" : 52.79764740155209,
  15. "std_deviation_sampling" : 52.80329511482722,
  16. "std_deviation_bounds" : {
  17. "upper" : 180.6507234461523,
  18. "lower" : -30.53986616005605,
  19. "upper_population" : 180.6507234461523,
  20. "lower_population" : -30.53986616005605,
  21. "upper_sampling" : 180.66201887270256,
  22. "lower_sampling" : -30.551161586606312
  23. }
  24. }
  25. }
  26. }

The std_deviation_bounds object provides a visual variance of the data with an interval of plus/minus two standard deviations from the mean. To set the standard deviation to a different value, say 3, set sigma to 3:

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