# How to reindex a Index with new data field types?

**URL:** https://discuss.elastic.co/t/how-to-reindex-a-index-with-new-data-field-types/192475
**Category:** Elasticsearch
**Created:** [July 26, 2019, 4:14pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-index-with-new-data-field-types/192475 "2019-07-26T16:14:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![matheusribeirogarcia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheusribeirogarcia/32/44363_2.png) [@matheusribeirogarcia](https://discuss.elastic.co/u/matheusribeirogarcia)
#### Post date: [July 26, 2019, 4:14pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-index-with-new-data-field-types/192475/1 "2019-07-26T16:14:06Z")

</div>

Hi, I'm trying to change a field type to another type, I've seem that I cannot do that directly in my current Index, so I'm trying to use the REINDEX API.

I've tried something like this, I know it's wrong, but it's just to show my idea.

```
POST _reindex
{
  "source": {
    "index": "auto_de_infracao"
  },
  "dest": {
    "index": "auto_de_infracao2"
  },
  "script": {
    "lang": "painless",
    "inline": "ctx._source.valAutoInfracao = ctx._source.valAutoInfracaoX",
    "type":"number"
  }
}

```

Objective change valAutoInfracao type to number

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [July 26, 2019, 6:25pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-index-with-new-data-field-types/192475/2 "2019-07-26T18:25:32Z")

</div>

Hey there, you can change your mappings with a two-step process:

1. Create the destination index with the mappings you want, e.g. `valAutoInfracao` is a number.
2. Reindex data from the source index into the destination index.

As documents are indexed into the destination index, they'll be mapped with the mapping you've specified on that index. See [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#\_updating\_existing\_field\_mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#_updating_existing_field_mappings) for more info.

Thanks,  
CJ

---

<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: [August 23, 2019, 6:25pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-index-with-new-data-field-types/192475/3 "2019-08-23T18:25:33Z")

</div>

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