/ avg,
/ aggregationAvg aggregation # A single-value metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents.
Examples # Assuming the data consists of documents representing exams grades (between 0 and 100) of students we can average their scores with:
POST /exams/_search { "aggs": { "avg_grade": { "avg": { "field": "grade" } } } } The above aggregation computes the average grade over all documents.
...
/ date,
/ histogram,
/ aggregationDate histogram aggregation # This multi-bucket aggregation is similar to the normal histogram, but it can only be used with date or date range values. Because dates are represented internally in Elasticsearch as long values, it is possible, but not as accurate, to use the normal histogram on dates as well. The main difference in the two APIs is that here the interval can be specified using date/time expressions. Time-based data requires special support because time-based intervals are not always a fixed length.
...
/ max,
/ aggregationMax aggregation # A single-value metrics aggregation that keeps track and returns the maximum value among the numeric values extracted from the aggregated documents.
Examples # Computing the max price value across all documents:
POST /sales/_search { "aggs": { "max_price": { "max": { "field": "price" } } } } Response:
{ ... "aggregations": { "max_price": { "value": 200.0 } } } As can be seen, the name of the aggregation (max_price above) also serves as the key by which the aggregation result can be retrieved from the returned response.
...
/ min,
/ aggregationMin aggregation # A single-value metrics aggregation that keeps track and returns the minimum value among numeric values extracted from the aggregated documents.
Examples # Computing the min price value across all documents:
POST /sales/_search { "aggs": { "min_price": { "min": { "field": "price" } } } } Response:
{ ... "aggregations": { "min_price": { "value": 10.0 } } } As can be seen, the name of the aggregation (min_price above) also serves as the key by which the aggregation result can be retrieved from the returned response.
...
/ percentile,
/ aggregationPercentiles aggregation # A multi-value metrics aggregation that calculates one or more percentiles over numeric values extracted from the aggregated documents.
Percentiles show the point at which a certain percentage of observed values occur. For example, the 95th percentile is the value which is greater than 95% of the observed values.
Percentiles are often used to find outliers. In normal distributions, the 0.13th and 99.87th percentiles represents three standard deviations from the mean.
...
/ sum,
/ aggregationSum aggregation # A single-value metrics aggregation that sums up numeric values that are extracted from the aggregated documents.
Examples # Assuming the data consists of documents representing sales records we can sum the sale price of all hats with:
POST /sales/_search { "query": { "constant_score": { "filter": { "match": { "type": "hat" } } } }, "aggs": { "hat_prices": { "sum": { "field": "price" } } } } Resulting in:
...
/ terms,
/ aggregationTerms aggregation # A multi-bucket value source based aggregation where buckets are dynamically built - one per unique value.
Examples # POST /_search { "aggs": { "genres": { "terms": { "field": "genre" } } } } Response:
{ ... "aggregations": { "genres": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "electronic", "doc_count": 6 }, { "key": "rock", "doc_count": 3 }, { "key": "jazz", "doc_count": 2 } ] } } } Parameters for terms # field
...
/ value_count,
/ aggregationValue count aggregation # A single-value metrics aggregation that counts the number of values that are extracted from the aggregated documents. Typically, this aggregator will be used in conjunction with other single-value aggregations. For example, when computing the avg one might be interested in the number of values the average is computed over.
value_count does not de-duplicate values, so even if a field has duplicates each value will be counted individually.
...