Min Aggregation

A single-value metrics aggregation that keeps track and returns the minimum value among numeric values extracted from the aggregated documents. These values are extracted from specific numeric fields in the documents.

Structuring

The following snippet captures the structure of min aggregations:

"<aggregation_name>": {
  "_min": {
    "_field": "<field_name>"
  },
  ...
}

Field

The <field_name> in the _field parameter defines the specific field from which the numeric values in the documents are extracted and used to compute the returned minimum value.

Assuming the data consists of documents representing bank accounts, as shown in the sample dataset of Data Exploration section, computing the min balance value across all accounts:

SEARCH /bank/
{
  "_query": "*",
  "_limit": 0,
  "_check_at_least": 1000,
  "_aggs": {
    "min_balance": {
      "_min": {
        "_field": "balance"
      }
    }
  }
}

Response:

{
  "aggregations": {
    "_doc_count": 1000,
    "min_balance": {
      "_min": 7.99
    }
  }, ...
}

As can be seen, the name of the aggregation (min_balance above) also serves as the key by which the aggregation result can be retrieved from the returned response.