Top metrics aggregation

Top metrics aggregation #

A metrics aggregation that returns metric values from the leading matching documents — a cheaper alternative to top_hits when you only need field values, not whole documents.

Engine note: sort is accepted for compatibility; the current implementation returns the metrics of the first size matching documents.

Example #

Parameters for top_metrics #

  • metrics
    (Required, object array) field entries whose values are returned.
  • sort
    (Optional, array) Sort clause selecting the “top” documents.
  • size
    (Optional, integer, default: 1) How many top entries to return.
Calendar September 26, 2026
Edit Edit this page