From c7759fa5e0c99092ffecd0521b68d7728a58279d Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 17 Jun 2021 14:58:20 -0400 Subject: [PATCH] Document types `terms` agg can consume (#73272) Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com> --- .../bucket/terms-aggregation.asciidoc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc index 5f985df78d454..a29fae91c2677 100644 --- a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc +++ b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc @@ -60,16 +60,13 @@ GET /_search { "aggs": { "genres": { - "terms": { "field": "genre" } <1> + "terms": { "field": "genre" } } } } -------------------------------------------------- // TEST[s/_search/_search\?filter_path=aggregations/] -<1> `terms` aggregation should be a field of type `keyword` or any other data type suitable for bucket aggregations. In order to use it with `text` you will need to enable -<>. - Response: [source,console-result] @@ -107,6 +104,16 @@ Response: By default, the `terms` aggregation will return the buckets for the top ten terms ordered by the `doc_count`. One can change this default behaviour by setting the `size` parameter. +[[search-aggregations-bucket-terms-aggregation-types]] +The `field` can be <>, <>, <>, <>, +or <>. + +NOTE: By default, you cannot run a `terms` aggregation on a `text` field. Use a +`keyword` <> instead. Alternatively, you can enable +<> on the `text` field to create buckets for the field's +<> terms. Enabling `fielddata` can significantly increase +memory usage. + [[search-aggregations-bucket-terms-aggregation-size]] ==== Size