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

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?

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.

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