elasticsearch/docs/reference/query-languages/esql/_snippets/functions/top.md
Colleen McGinnis b7e3a1e14b
[docs] Migrate docs from AsciiDoc to Markdown (#123507)
* delete asciidoc files

* add migrated files

* fix errors

* Disable docs tests

* Clarify release notes page titles

* Revert "Clarify release notes page titles"

This reverts commit 8be688648d.

* Comment out edternal URI images

* Clean up query languages landing pages, link to conceptual docs

* Add .md to url

* Fixes inference processor nesting.

---------

Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com>
Co-authored-by: Liam Thompson <leemthompo@gmail.com>
Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
Co-authored-by: István Zoltán Szabó <szabosteve@gmail.com>
2025-02-27 17:56:14 +01:00

996 B

TOP [esql-top]

Syntax

:::{image} ../../../../../images/top.svg :alt: Embedded :class: text-center :::

Parameters

field
The field to collect the top values for.
limit
The maximum number of values to collect.
order
The order to calculate the top values. Either asc or desc.

Description

Collects the top values for a field. Includes repeated values.

Supported types

field limit order result
boolean integer keyword boolean
date integer keyword date
double integer keyword double
integer integer keyword integer
ip integer keyword ip
keyword integer keyword keyword
long integer keyword long
text integer keyword keyword

Example

FROM employees
| STATS top_salaries = TOP(salary, 3, "desc"), top_salary = MAX(salary)
top_salaries:integer top_salary:integer
[74999, 74970, 74572] 74999