Given a field named eventType with mapping.
"itemType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "folding"
}
I want to get all values of that specific field. When i use bucket-term aggregations
"aggs" : {
"values" : {
"terms" : { "field" : "eventType" }
}
}
i get the following exception:
Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [eventType] in order to load field data by uninverting the inverted index. Note that this can use significant memory
And in the ES official docs, there is a note as following.
The field can be Keyword, Numeric, ip, boolean, or binary. By default, you cannot run a terms aggregation on a text field. Use a keyword sub-field instead. Alternatively, you can enable fielddata on the text field to create buckets for the field’s analyzed terms. Enabling fielddata can significantly increase memory usage.
Ref
My questions are:
- My setting "keyword" on evenType mapping does not make that field can be seen as a keyword data type on aggregation ? As i know that, fields keyword allow a field can be indexed for multiple purposes.
- How can i solve this problem ?.