# How to migrate indices from old .raw template to new .keyword mapping

**URL:** <https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610>\
**Category:** Logstash\
**Created:** [February 6, 2018, 10:25am UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610 "2018-02-06T10:25:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![T3rm11](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@T3rm11](https://discuss.elastic.co/u/T3rm11)\
**Post date:** [February 6, 2018, 10:25am UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610/1 "2018-02-06T10:25:33Z")

</div>

I think I ran into a very big problem when I upgraded from ELK 5 to ELK 6. When I look at the Logstash template in ELK 5 I see a keyword mapping with `.raw`. After the upgrade to ELK 6 the new template has a keyword mapping with `.keyword`.

Two problems:

1. All my Kibana visualizations rely on `.raw`. Is there an easy way to update that?
2. The much bigger problem is that I have tons of old indices with a `.raw` mapping. All new indices have `.keyword`. How can I solves this problem?

This is my old mapping:

```
"string_fields": {
					   
										 
          "mapping": {
            "fielddata": {
              "format": "disabled"
            },
            "index": "analyzed",
            "omit_norms": true,
            "type": "string",
            "fields": {
              "raw": {
                "ignore_above": 256,
                "index": "not_analyzed",
                "type": "string"
              }
            }
          },
          "match_mapping_type": "string",
          "match": "*"
        }

```

This is the new mapping:

```
"string_fields": {
          "match": "*",
          "match_mapping_type": "string",
          "mapping": {
            "type": "text",			
            "norms": false,			 
            "fields": {
              "keyword": {						
                "type": "keyword"
              }
            }
          }			  
        }
```

---

<div class="post-metadata">

**Author:** ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)\
**Post date:** [February 7, 2018, 6:21am UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610/2 "2018-02-07T06:21:36Z")

</div>

I don't know if there's a better solution.

In our case, we used the reindex API ([https://www.elastic.co/guide/en/elasticsearch](https://www.elastic.co/guide/en/elasticsearch)) to recreate the old indexes with .keyword.

In Kibana we exported all saved objects to json, replaced .raw with .keyword and imported the modified json file.

Since we use alias on all indexes, the rest was pretty straight forward.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 7, 2018, 7:13am UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610/3 "2018-02-07T07:13:55Z")

</div>

If you want to stick to .raw you can start managing the index template yourself. Just download the existing template, rename the field, upload the modified template, and disable the elasticsearch output's `manage_template` option.

---

<div class="post-metadata">

**Author:** ![T3rm11](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@T3rm11](https://discuss.elastic.co/u/T3rm11)\
**Post date:** [February 8, 2018, 3:03pm UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610/4 "2018-02-08T15:03:44Z")

</div>

If I decide to reindex what do I need to do? It looks like I have to reindex each index on its own. How can I migrate .raw to .keyword with the reindex API?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 8, 2018, 3:13pm UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610/5 "2018-02-08T15:13:57Z")

</div>

> It looks like I have to reindex each index on its own.

Yeah, probably, but that's easy to script.

> How can I migrate .raw to .keyword with the reindex API?

That'll take care of itself. Try reindexing one of the indexes (it won't delete the old index) and you can inspect the results.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 8, 2018, 3:14pm UTC](https://discuss.elastic.co/t/how-to-migrate-indices-from-old-raw-template-to-new-keyword-mapping/118610/6 "2018-03-08T15:14:13Z")

</div>

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