Skip to content

Improve terms aggregation example #31592

Closed
@debadair

Description

@debadair

The first example on the terms agg page doesn't provide sample data and is somewhat misleading. For the example to work as-is, fielddata must be enabled on the genre field. Alternatively (preferably) you can use the keyword field, instead. Otherwise, you'll get the following error:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [color] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"

This sent someone looking at the Definitive Guide down a rabbit hole trying to run against 6.3.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

https://www.elastic.co/blog/strings-are-dead-long-live-strings

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions