Robert Wille
Robert Wille

Reputation: 199

ElasticSearch terms aggregation throws exception on keyword inner field

I get this error when trying to do a terms aggregation on an inner keyword field: { "type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [prop.field_name] 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."}

The strange thing about this is that prop.field_name is a keyword field. It is not text. When I retrieve the mappings from ElasticSearch, I get "field_name": {"type":"keyword"}.

The aggregation is really simple: "aggs":{"foo":{"terms":{"field":"prop.field_name"}}}

Note that prop.field_name isn't nested. It's just a regular inner property.

I have a lot of these inner keyword properties, and as far as I can tell, they all throw the error. I have several top-level keyword properties, and only one of them throws the error. ES reports that the type of all these properties is keyword.

Any idea why ES would tell me that a property is a keyword property, but when I try to aggregate on it, it throws an error because it thinks it is analyzed?

Upvotes: 1

Views: 556

Answers (1)

Robert Wille
Robert Wille

Reputation: 199

I didn't have the mappings I thought. The field in question was a dynamic field, which is why it requires the .keyword suffix. It works as expected with the correct mappings.

Upvotes: 1

Related Questions