"Fielddata is disabled on text fields by default" error

I am trying to add condition Group by in Grafana with Elasticsearch data source but I get the following error:
Fielddata is disabled on text fields by default

I tried to fix it by:

curl -XPUT 'localhost:9200/logstash-2017.06.07/_mapping/text?pretty' -H 'Content-Type: application/json' -d'
{
  "properties": {
    "beat.hostname": { 
      "type":     "text",
      "fielddata": true
    }
  }
}
'

But got the error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [beat.hostname] conflicts with existing mapping in other types:\n[mapper [beat.hostname] has different [norms] values, cannot change from disable to enabled, mapper [beat.hostname] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types., mapper [beat.hostname] is used by multiple types. Set update_all_types to true to update [fielddata] across all types.]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [beat.hostname] conflicts with existing mapping in other types:\n[mapper [beat.hostname] has different [norms] values, cannot change from disable to enabled, mapper [beat.hostname] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types., mapper [beat.hostname] is used by multiple types. Set update_all_types to true to update [fielddata] across all types.]"
  },
  "status" : 400
}

Any ideas how to fix that?

You probably don’t want to enable fielddata. Usually you want to index it as a keyword (or not analyzed in v2.x) instead which means that ES indexes the whole string and does not split it into multiple values. The text index is for full text data - like a product description.

1 Like

In my case is happening on a “number” field. Is that correct? How can we avoid that?

@interpeix where you able to figure out the issue. I am also facing this on a “number” field.