Change Field Data Type from Primitive to Object

Hello All,
I am looking for a solution for scenario where need to change data type of field.
We configure index using index mapping template and reindexing is done whenever there is any change in index mapping. We are using Elasticsearch 6.8.8

  • Current mapping
    "applicationType": { "type": "text", "index" : false }

  • Expected new mapping
    "applicationType.code": { "type": "keyword", "index": false }, "applicationType.value": { "type": "text", "index": false },

How can I support smooth migration?

  1. I do not want to lose old data
  2. I want to manually copy from old field value to new structure
    For ex, applicationType -> applicationType.code

I tried with alias option, it does not give expected result. Already went through definitive guide. Major challenging requirement is to support the same field name in json message "applicationType" for new mapping.
It's okay to use different name for old field, but do not want to loose data.
I hope there is a solution for this,
I will appreciate clean solution.

I'd probably use the reindex API to read all the old data and write to the new index.

I'd add an ingest pipeline to rename the old field names to the new ones.

I did not understand fully the requirements though so may be with a concrete example of a source document and a destination document could help to give you more information.

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