elasticsearch/docs/reference/esql/functions/aggregation-functions.asciidoc
Nik Everett fa00e6176f
ESQL: Values aggregation function (#106065)
This creates the `VALUES` aggregation function which buffers all field
values it receives and emits them as a multivalued field. It can use a
significant amount of memory and will circuit break if it uses too much
memory, but it's really useful for putting together self-join-like
behavior. It sort of functions as a stop-gap measure until we have more
self-join style things.

In the future we'll have spill-to-disk for aggregations and, likely,
some kind of self-join command for aggregations at least so this will be
able to grow beyond memory. But for now, memory it is.

Example:

```
  FROM employees
| EVAL first_letter = SUBSTRING(first_name, 0, 1)
| STATS first_name=VALUES(first_name) BY first_letter
| SORT first_letter
;

                                        first_name:keyword | first_letter:keyword
            [Anneke, Alejandro, Anoosh, Amabile, Arumugam] | A
[Bezalel, Berni, Bojan, Basil, Brendon, Berhard, Breannda] | B
                  [Chirstian, Cristinel, Claudi, Charlene] | C
                      [Duangkaew, Divier, Domenick, Danel] | D
```

I made this work for everything but `geo_point` and `cartesian_point`
because I'm not 100% sure how to integrate with those. We can grab those
in a follow up.

Closes #103600
2024-03-21 12:52:04 -04:00

34 lines
806 B
Text

[[esql-agg-functions]]
==== {esql} aggregate functions
++++
<titleabbrev>Aggregate functions</titleabbrev>
++++
The <<esql-stats-by>> function supports these aggregate functions:
// tag::agg_list[]
* <<esql-agg-avg>>
* <<esql-agg-count>>
* <<esql-agg-count-distinct>>
* <<esql-agg-max>>
* <<esql-agg-median>>
* <<esql-agg-median-absolute-deviation>>
* <<esql-agg-min>>
* <<esql-agg-percentile>>
* <<esql-agg-st-centroid>>
* <<esql-agg-sum>>
* <<esql-agg-values>>
// end::agg_list[]
include::avg.asciidoc[]
include::count.asciidoc[]
include::count-distinct.asciidoc[]
include::max.asciidoc[]
include::median.asciidoc[]
include::median-absolute-deviation.asciidoc[]
include::min.asciidoc[]
include::percentile.asciidoc[]
include::st_centroid.asciidoc[]
include::sum.asciidoc[]
include::values.asciidoc[]