Update mapping from text to text.keyword

Hello all,
I have my elasticsearch with 100gb of data and now I’m trying to add keyword for one field . So is it possible to update the mapping without reindexing the date

if keyword is not there for particular field I couldn’t not apply visualization

No, adding a field will require reindexing.

I am not going to add extra index just need to make keyword for existing field

Hi,
Im not 100% sure but may this helps a bit.

First read the Put Mapping API:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

Than take a look here:

For a special EXISTING Field:

POST /yourindex/_update_by_query?conflicts=proceed
{
  "query": {
    "bool": {
      "filter": {
        "terms": {
          "EXISTING": [
            "1234"
          ]
        }
      }
    }
  },
  "script": {
    "source": "ctx._source.EXISTING_New = ctx._source.EXISTING",
    "lang": "painless"
  }
}

Or for all EXISTING Fields:

POST /yourindex/_update_by_query?conflicts=proceed
{
  "query": {
    "match_all": {}
  },
  "source": "ctx._source.EXISTING_New = ctx._source.EXISTING",
  "lang": "painless"
}

If no special Mapping is PUT, elastic should generate a text and keyword field for EXISTING_New

Maybe you need to Add a new Mapping to recocgnize new fields as Keyword to your Index!?
If so take a look here to do that with no downtime using Alias:

mappings-and-settings-without-downtime

Regards

1 Like

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