# "Fielddata is disabled on text fields by default" error on keyword field

**URL:** <https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175>\
**Category:** Elasticsearch\
**Created:** [January 7, 2019, 9:26am UTC](https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175 "2019-01-07T09:26:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![trondhindenes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trondhindenes/32/10534_2.png) [@trondhindenes](https://discuss.elastic.co/u/trondhindenes)\
**Post date:** [January 7, 2019, 9:26am UTC](https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175/1 "2019-01-07T09:26:02Z")

</div>

I'm getting this error in my log:

```auto
Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [component] 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.
        at org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:670) ~[elasticsearch-6.5.0.jar:6.5.0]

```

Which I don't understand. For this index we have a dynamic template containing:

```json
{
    "template" : "logs_rikstv_app_log*generic*",
    "order" : 1,
    "settings": {
        "index": {
            "refresh_interval": "5s"
        }
    },
    "mappings": {
        "generic": {
            "dynamic_templates": [
                {
                    "notanalyzed": {
                        "match_mapping_type": "string",
                        "mapping": {
                            "type": "keyword"
                        },
                        "match": "*"
                    }
                }
            ],
            "properties": {
                "@timestamp": {
                    "type": "date"
                },
                "errorid": {
                    "type": "integer"
                }
            }
        }
    }
}

```

If I query the actual index for its mappings I get (subset):

```auto
                "properties": {
                    "@timestamp": {
                        "type": "date"
                    },
                    "@version": {
                        "type": "keyword"
                    },
                    "Exception": {
                        "type": "keyword"
                    },
                    "Level": {
                        "type": "keyword"
                    },
                    "beat": {
                        "properties": {
                            "hostname": {
                                "type": "keyword"
                            },
                            "name": {
                                "type": "keyword"
                            },
                            "version": {
                                "type": "keyword"
                            }
                        }
                    },
                    "component": {
                        "type": "keyword"
                    },

```

So, given the fact that the component field is a keyword type, why am I getting this error? I'm sure there's something I don't understand, any pointers appreciated!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 7, 2019, 9:34am UTC](https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175/2 "2019-01-07T09:34:07Z")

</div>

Does your index pattern match more than one index? Is this mapping consistent across all indices matched by the pattern?

---

<div class="post-metadata">

**Author:** ![trondhindenes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trondhindenes/32/10534_2.png) [@trondhindenes](https://discuss.elastic.co/u/trondhindenes)\
**Post date:** [January 7, 2019, 9:53am UTC](https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175/3 "2019-01-07T09:53:18Z")

</div>

It does match multiple, but the error from Elasticsearch is related to the index I've posted the mapping for above as far as I can see. I'll go thru them all to see if there are diffs.

---

<div class="post-metadata">

**Author:** ![trondhindenes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trondhindenes/32/10534_2.png) [@trondhindenes](https://discuss.elastic.co/u/trondhindenes)\
**Post date:** [January 7, 2019, 10:04am UTC](https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175/4 "2019-01-07T10:04:21Z")

</div>

You're absolutely right. There are some type discrepancies. Thanks for the pointer!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 4, 2019, 10:04am UTC](https://discuss.elastic.co/t/fielddata-is-disabled-on-text-fields-by-default-error-on-keyword-field/163175/5 "2019-02-04T10:04:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
