# Reindex - Renaming nested fields

**URL:** <https://discuss.elastic.co/t/reindex-renaming-nested-fields/187363>\
**Category:** Elasticsearch\
**Created:** [June 25, 2019, 2:16pm UTC](https://discuss.elastic.co/t/reindex-renaming-nested-fields/187363 "2019-06-25T14:16:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhithra](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@sudhithra](https://discuss.elastic.co/u/sudhithra)\
**Post date:** [June 25, 2019, 2:16pm UTC](https://discuss.elastic.co/t/reindex-renaming-nested-fields/187363/1 "2019-06-25T14:16:48Z")

</div>

Hi,

I am not able to rename a nested field while reindexing

My nested field in the source index:

"nestField" : {  
"type" : "nested",  
"properties" : {  
"fieldOne" : {  
"type" : "string",  
"store" : true,  
"analyzer" : "index\_whitespace\_lowercase\_analyzer",  
"search\_analyzer" : "search\_whitespace\_lowercase\_analyzer"  
},  
"fieldTwo" : {  
"type" : "string",  
"store" : true,  
"analyzer" : "index\_whitespace\_lowercase\_analyzer",  
"search\_analyzer" : "search\_whitespace\_lowercase\_analyzer"  
}  
}  
}

My nested field in the Destination index: (case of the field names converted to lowercase)

"nestfield" : {  
"type" : "nested",  
"properties" : {  
"fieldone" : {  
"type" : "string",  
"store" : true,  
"analyzer" : "index\_whitespace\_lowercase\_analyzer",  
"search\_analyzer" : "search\_whitespace\_lowercase\_analyzer"  
},  
"fieldtwo" : {  
"type" : "string",  
"store" : true,  
"analyzer" : "index\_whitespace\_lowercase\_analyzer",  
"search\_analyzer" : "search\_whitespace\_lowercase\_analyzer"  
}  
}  
}

POST \_reindex  
{  
"size": 1,  
"source": {  
"index": "src\_indx"  
},  
"dest": {  
"index": "tgt\_indx"  
},  
"script": {  
"inline": """ctx.\_source.['nestfield.fieldone'] = ctx.\_source.("nestField.fieldOne");  
ctx.\_source.['nestfield.fieldtwo'] = ctx.\_source.("nestField.fieldTwo");  
ctx.\_source.nestfield = ctx.\_source.nestField]"""  
}  
}

---

<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:** [July 23, 2019, 2:17pm UTC](https://discuss.elastic.co/t/reindex-renaming-nested-fields/187363/2 "2019-07-23T14:17:03Z")

</div>

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