# Elasticsearch Reindex to New map \[6.2\]

**URL:** https://discuss.elastic.co/t/elasticsearch-reindex-to-new-map-6-2/153912
**Category:** Elasticsearch
**Created:** [October 25, 2018, 5:49am UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-new-map-6-2/153912 "2018-10-25T05:49:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![trust](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@trust](https://discuss.elastic.co/u/trust)
#### Post date: [October 25, 2018, 5:49am UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-new-map-6-2/153912/1 "2018-10-25T05:49:07Z")

</div>

Hello,

I'm looking for a solution to reindex to new mapping.  
My old map look like this  
{  
"user": {  
"id": 1,  
"email": "example@mail.com",  
"role": "ROLE",  
}  
}

how can I achieve and change it too  
{  
"userId": 1  
}

Thank You.

---

<div class="post-metadata">

### Author: ![jakelandis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jakelandis/32/36163_2.png) [@jakelandis](https://discuss.elastic.co/u/jakelandis)
#### Post date: [October 26, 2018, 6:58pm UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-new-map-6-2/153912/2 "2018-10-26T18:58:32Z")

</div>

I think you are looking for: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-change-name](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-change-name)

For example:

```auto
DELETE old
DELETE new
PUT old/_doc/1
{
  "user": {
    "id": 1,
    "email": "example@mail.com",
    "role": "ROLE"
  }
}

GET old/_doc/1
POST _reindex
{
  "source": {
    "index": "old"
  },
  "dest": {
    "index": "new"
  },
   "script": {
    "source": "ctx._source.user.userId = ctx._source.user.remove('id')",
    "lang": "painless"
  }
}
GET new/_doc/1

```

results in

```auto
{
  "_index": "new",
  "_type": "_doc",
  "_id": "1",
  "_version": 1,
  "found": true,
  "_source": {
    "user": {
      "role": "ROLE",
      "userId": 1,
      "email": "example@mail.com"
    }
  }
}

```

---

<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: [November 23, 2018, 7:04pm UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-new-map-6-2/153912/3 "2018-11-23T19:04:50Z")

</div>

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