# How to re-create doc id (\_id) during remote reindex?

**URL:** <https://discuss.elastic.co/t/how-to-re-create-doc-id--id-during-remote-reindex/74951>\
**Category:** Elasticsearch\
**Created:** [February 14, 2017, 3:50am UTC](https://discuss.elastic.co/t/how-to-re-create-doc-id--id-during-remote-reindex/74951 "2017-02-14T03:50:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hailima](https://avatars.discourse-cdn.com/v4/letter/h/f19dbf/32.png) [@hailima](https://discuss.elastic.co/u/hailima)\
**Post date:** [February 14, 2017, 3:50am UTC](https://discuss.elastic.co/t/how-to-re-create-doc-id--id-during-remote-reindex/74951/1 "2017-02-14T03:50:26Z")

</div>

I am doing remote reindex from ES 1.4.4 to ES 5.1.1 for data migration, the doc id in source index is created manually and I need to re-create it in destination index (either auto generated by destination ES server or uuid by the painless script) on destination server.  
I tried as followings, but none of them is working, How can I replace the doc id (\_id) during the reindex?

Thanks lot for help!

{  
"source": {  
"remote": {  
"host": "source hostname :9200"  
},  
"index": "srcindex",  
"size": 200  
},  
"dest": {  
"index": "desindex",  
"type": "mytype"  
},  
"script": {  
"inline": "ctx.\_id=UUID.fromString("????xxxxxx")", // use the script to gen uuid

# "inline": "ctx.\_id.delete()", // delete it and let ES auto gen it

```
"lang": "painless"

```

}  
}

---

<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 14, 2017, 3:51am UTC](https://discuss.elastic.co/t/how-to-re-create-doc-id--id-during-remote-reindex/74951/2 "2017-03-14T03:51:00Z")

</div>

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