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:
sortis accepted for compatibility; the current implementation returns the metrics of the firstsizematching documents.
Example #
Parameters for top_metrics
#
metrics
(Required, object array)fieldentries whose values are returned.sort
(Optional, array) Sort clause selecting the “top” documents.size
(Optional, integer, default:1) How many top entries to return.