Top_metrics

Top metrics aggregation

/ 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.

How it works #

top_metrics walks the bucket’s documents and emits one entry per document for the first size of them, in index order. Each entry maps every configured metric field to its value in that document. The response is the flat form {"top": [{"price": 15.0}, …]}.

...