ElasticSearch 5.1 Fielddata is disabled in text field by default [ERROR: trying to use aggregation on field] ElasticSearch 5.1 Fielddata is disabled in text field by default [ERROR: trying to use aggregation on field] elasticsearch elasticsearch

ElasticSearch 5.1 Fielddata is disabled in text field by default [ERROR: trying to use aggregation on field]


You need to aggregate on the keyword sub-field, like this:

"aggs": {"answer": {  "terms": {    "field": "answer.keyword"  }},

That will work.


In Aggregation, just add keyword to answer.It worked for me. For text fields we need to add keyword. "field": "answer.keyword"


Adding to @Val's answer, you can also set the fielddata to true during your mapping itself:

"answer": {        "type": "text",        "fielddata": true, <-- add this line        "fields": {          "keyword": {            "type": "keyword",                            "ignore_above": 256          }        }      },