# Change the mapping from parent child to nested

**URL:** <https://discuss.elastic.co/t/change-the-mapping-from-parent-child-to-nested/89096>\
**Category:** Elasticsearch\
**Created:** [June 12, 2017, 7:20pm UTC](https://discuss.elastic.co/t/change-the-mapping-from-parent-child-to-nested/89096 "2017-06-12T19:20:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sravanthi\_N\_S\_CH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sravanthi_n_s_ch/32/50473_2.png) [@Sravanthi\_N\_S\_CH](https://discuss.elastic.co/u/Sravanthi_N_S_CH)\
**Post date:** [June 12, 2017, 7:20pm UTC](https://discuss.elastic.co/t/change-the-mapping-from-parent-child-to-nested/89096/1 "2017-06-12T19:20:37Z")

</div>

Hello,

Currently, I have an index which holds 3 types of documents as described below.  
Document\_type1 (parent)  
Document\_type2 (child1 of parent)  
Document\_type3 (child2 of parent)

**Requirement:**  
Change the parent child relationship to nested document structure. I would like to create a new index with the nested mappings and migrate the data from old\_index to new\_index (which has nested mapping)

Is this possible ? If, yes what is the better approach.  
I looked at elastic reindex feature. Please look at the sample below. This approach just copies all the data to new\_index with same parent child relationship instead of merging the documents into nested documents using the new the nested mapping (in new\_index).

> POST \_reindex  
> {  
> "source": {  
> "index": "old\_index"  
> },  
> "dest": {  
> "index": "new\_index"  
> }  
> }

Is there anything that I missed ?

---

<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 10, 2017, 7:20pm UTC](https://discuss.elastic.co/t/change-the-mapping-from-parent-child-to-nested/89096/2 "2017-07-10T19:20:38Z")

</div>

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