Use the _update_by_query API for a mapping change

Hello,

I have the following mappings defined for a field in an index that has hundreds of thousands of documents:

{
  "status": {
      "type": "text"
  }
}

and I want to change its definition to:

{
  "status": {
      "type": "keyword"
  }
}

Is this do-able using the _update_by_query API? What will the performance impact be? If I can run it offline, would it be quicker than the reindexing to v2, dropping the original alias, creating an alias, and then removing the v1 index technique described in the zero-downtime post (https://www.elastic.co/guide/en/elasticsearch/guide/current/index-aliases.html)?

Thanks in advance

You cannot do this with the update by query API. The _update_by_query API only allows you to reindex a subset of documents, replacing the existing version of the documents (in the same index). The problem is that in order to make the change you want, you'll have to change the mappings, and since this is not an additive change you can only make it on a new index.

One way to accomplish this would be to create a new index with the different mappings you want, and then to use the _reindex API https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-reindex.html to reindex the data into the new index with the correct mapping.

Yes. I tried it and realized that type change requires reindex. Thanks

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