How to fix ElasticSearch ‘Fielddata is disabled on text fields by default’ for keyword field How to fix ElasticSearch ‘Fielddata is disabled on text fields by default’ for keyword field elasticsearch elasticsearch

How to fix ElasticSearch ‘Fielddata is disabled on text fields by default’ for keyword field


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.


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.


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"