Reputation: 785
I'm getting the "Fielddata is disabled on text fields by default" on a keyword field. Below is the code.
{
"aggs": {
"agg_terms_user": {
"terms": {
"field": "user"
}
}
}
}
The mapping for the user field is as below
user: { type: "keyword" }
Since the user field has type set as keyword I shouldn't get the error. However, the error is still thrown.
[illegal_argument_exception] Fielddata is disabled on text fields by default. Set fielddata=true on [user] 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.
I don't know what to try now.
Upvotes: 24
Views: 68205
Reputation: 11
Facing the same issue in heartbeat application.I have solved this issue by following below steps.
stop the application [ in my case I stopped the heartbeat application]
Delete the index related to apps.
Start the application
Upvotes: 1
Reputation: 777
Check out the documentation in the elastic which clearly mentions that we cannot use the text field for aggregations, sorting, or scripting
https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#fielddata-mapping-param
This can be achieved with help of keyword usage. Try searching by
"field" : "user.keyword"
Upvotes: 3
Reputation: 1549
The comment of @Andrey Borisko was correct
I used
"field": "user.keyword"
instead of
"field": "user"
based on Nikhil's example and it worked for me.
Upvotes: 39
Reputation: 785
I found the reason behind the unexpected error. The ES wasn't getting re-indexed properly. Once I deleted the indexed first and then recreated it then it started working like a charm.
Upvotes: 11