# When creating keyword field it gets changed to text field + .keyword?

**URL:** <https://discuss.elastic.co/t/when-creating-keyword-field-it-gets-changed-to-text-field-keyword/185599>\
**Category:** Elasticsearch\
**Created:** [June 13, 2019, 9:59am UTC](https://discuss.elastic.co/t/when-creating-keyword-field-it-gets-changed-to-text-field-keyword/185599 "2019-06-13T09:59:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kim\_huizing](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kim\_huizing](https://discuss.elastic.co/u/kim_huizing)\
**Post date:** [June 13, 2019, 9:59am UTC](https://discuss.elastic.co/t/when-creating-keyword-field-it-gets-changed-to-text-field-keyword/185599/1 "2019-06-13T09:59:41Z")

</div>

Hi,

I am using Elasticsearch 6.5 . I have an existing index with a mapping. I want to add a field to this mapping called `documentYear` which is of type `keyword`. This field is not relevant for full-text search so I want it created only as a keyword field. I add this to the mapping:

```
    "documentYear": {
      "type": "keyword"
    },

```

Then I re-index my data. As the field is getting populated it turns out it's created like this:

```
      "documentYear": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },

```

How can I avoid that happening? I used to use `index.mapper.dynamic = false` to avoid this, but it has been deprecated. How can I ensure my field gets created as keyword only?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 13, 2019, 10:15am UTC](https://discuss.elastic.co/t/when-creating-keyword-field-it-gets-changed-to-text-field-keyword/185599/2 "2019-06-13T10:15:38Z")

</div>

It just means that the mapping you defined is not applied.  
May be the mapping was already existing for this field so you can't change it or may be you did something wrong.

---

<div class="post-metadata">

**Author:** ![kim\_huizing](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kim\_huizing](https://discuss.elastic.co/u/kim_huizing)\
**Post date:** [June 13, 2019, 11:02am UTC](https://discuss.elastic.co/t/when-creating-keyword-field-it-gets-changed-to-text-field-keyword/185599/3 "2019-06-13T11:02:01Z")

</div>

Ok. Maybe it's the order then. We have a reprocessing module that maps all documents to the new version of the model and then re-indexes them, but maybe it re-indexes the first documents before posting the new mapping template.

Thanks for your answer

---

<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:** [July 11, 2019, 11:02am UTC](https://discuss.elastic.co/t/when-creating-keyword-field-it-gets-changed-to-text-field-keyword/185599/4 "2019-07-11T11:02:12Z")

</div>

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