From 8b00f0dfd1b124c01ada67138e746ca86ce2ff80 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 20 May 2021 08:42:37 -0400 Subject: [PATCH 1/3] Document types `terms` agg can consume --- .../bucket/terms-aggregation.asciidoc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc index ee0ddaa6b17de..9212b14f0693f 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,19 @@ 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. + +The `field` can be <>, <>, <>, <>, +or <>. + +NOTE:: If you try to run it on a text field you will get an error back about +field data. You have a choice, run `terms` on a `keyword` +<> instead or enable <> on the text +field. Generally the `keyword` sub-field is better because fielddata consumes a +ton of memory. But the `fielddata` way of running the terms aggregation will +return a bucket per <> term in the `text` field while the +`keyword` way will return a bucket for each value in the keyword. + + [[search-aggregations-bucket-terms-aggregation-size]] ==== Size From f57ca772f3d3532ec6fd9b50bd626805e5057700 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 20 May 2021 08:44:01 -0400 Subject: [PATCH 2/3] anchro --- docs/reference/aggregations/bucket/terms-aggregation.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc index 9212b14f0693f..82693d150ac9f 100644 --- a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc +++ b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc @@ -104,7 +104,7 @@ 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 <>. From ee8879a669c851032ece9cbcf416780806a952ad Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 17 Jun 2021 14:45:30 -0400 Subject: [PATCH 3/3] Update docs/reference/aggregations/bucket/terms-aggregation.asciidoc Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com> --- .../aggregations/bucket/terms-aggregation.asciidoc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc index 82693d150ac9f..d6712b883b384 100644 --- a/docs/reference/aggregations/bucket/terms-aggregation.asciidoc +++ b/docs/reference/aggregations/bucket/terms-aggregation.asciidoc @@ -108,14 +108,11 @@ change this default behaviour by setting the `size` parameter. The `field` can be <>, <>, <>, <>, or <>. -NOTE:: If you try to run it on a text field you will get an error back about -field data. You have a choice, run `terms` on a `keyword` -<> instead or enable <> on the text -field. Generally the `keyword` sub-field is better because fielddata consumes a -ton of memory. But the `fielddata` way of running the terms aggregation will -return a bucket per <> term in the `text` field while the -`keyword` way will return a bucket for each value in the keyword. - +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