Average aggregation

The average aggregation finds an average across all the documents in the querying context:

GET bigginsight/_search
{
"aggregations": {
"download_average": { 1
"avg": { 2
"field": "downloadTotal"
}
}
},
"size": 0
}

The only notable differences from the sum aggregation are as follows:

  • We chose a different name, download_average, to make it apparent that the aggregation is trying to compute the average.
  • The type of aggregation that we are doing is avg, instead of the sum aggregation that we were doing earlier.

The response structure is identical, but the value field will now represent the average of the requested field.

The min and max aggregations are exactly the same.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset