# Reindex to join field type

**URL:** <https://discuss.elastic.co/t/reindex-to-join-field-type/163472>\
**Category:** Elasticsearch\
**Created:** [January 9, 2019, 8:25am UTC](https://discuss.elastic.co/t/reindex-to-join-field-type/163472 "2019-01-09T08:25:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M.alsioufi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.alsioufi/32/52269_2.png) [@M.alsioufi](https://discuss.elastic.co/u/M.alsioufi)\
**Post date:** [January 9, 2019, 8:25am UTC](https://discuss.elastic.co/t/reindex-to-join-field-type/163472/1 "2019-01-09T08:25:32Z")

</div>

Hi,  
I have an index with a field which has a value of array of objects, I want to reindex this to a field of type join (parent-child relation) in other words I want to move from this:  
`{ "field_A": "test field", "field_B": "test field2", "@timestamp": "2016-01-03T11:09:45.515872", "field_C": [{ "field_CA": "child_name", "field_CB": 1, "field_CC": true, "field_CD": false, "field_CE": ["A", "B", "C"] }, { "field_CA": "child_name", "field_CB": 2, "field_CC": false, "field_CD": false, "field_CE": ["A"] } ] }`

to an index with the mapping:  
`{ "mappings": { "doc": { "properties": { "field_C": { "type": "join", "relations": {"parent": "child"} } } } } }`

I started with reindexing the data excluding "field\_C" like this:  
`POST _reindex { "conflicts": "proceed", "source": { "index": "my_index", "_source": { "excludes": ["field_C"] } }, "dest": { "index": "my_new_index" } }`

then reindex children documents:  
`POST _reindex { "conflicts": "proceed", "source": { "index": "my_index", "_source": ["field_C", "_id"] }, "dest": { "index": "my_new_index" }, "script": { "inline": "ctx._source['field_C.name']= 'validation_result';ctx._source['field_C.parent'] = ctx._source['_id'];ctx._source['field_CA']=ctx._source['field_C.field_CA'];ctx._source['field_CB']=ctx._source['field_C.field_CB'];ctx._source['field_CC']=ctx._source['field_C.field_CC'];ctx._source['field_CD']=ctx._source['field_C.field_CD'];ctx._source.remove('_id');ctx._source.remove('field_C');" } }`

however I got an error with this cause:  
`"cause": { "type": "mapper_parsing_exception", "reason": "Could not dynamically add mapping for field [field_C.parent]. Existing mapping for [field_C] must be of type object but found [join]." }`

Any help will be highly appreciated!

---

<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:** [February 6, 2019, 8:25am UTC](https://discuss.elastic.co/t/reindex-to-join-field-type/163472/2 "2019-02-06T08:25:34Z")

</div>

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