Reindex from 5 to 6 and add explicit type field


(juiip) #1

I have the below command to reindex an ES 5 index into an ES 6 index. I am going to take each type of document within an index and change its type to "_type".

I have added an explicit "type" field within the new index template, and was wondering if its possible to put the old type value into the explicit type field within my new index?

Is it possible to do so by adding something into the below code?

POST _reindex
{
  "source": {
    "index": "v5_index-2018.11.07",
    "type": "server"
  },
  "dest": {
    "index": "v6_index-2018.11.07",
    "type": "_doc"
  }
}

(Peter Dyson) #2

The best strategies to deal with the removal of types are explained in the docs here:
https://www.elastic.co/guide/en/elasticsearch/reference/6.5/removal-of-types.html#removal-of-types

The two general options are reindex to a separate index per pre-existing type or to migrate to using a custom type field to differentiate the type using that field.

I think the reindex example for the custom type method is probably most closely matching what you're looking for:
https://www.elastic.co/guide/en/elasticsearch/reference/6.5/removal-of-types.html#_custom_type_field_2