Reindex to join field type

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!

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