# How to mitigate "\[routing\] is missing for join field \[join\_field\]

**URL:** <https://discuss.elastic.co/t/how-to-mitigate-routing-is-missing-for-join-field-join-field/128145>\
**Category:** Elasticsearch\
**Created:** [April 16, 2018, 9:08am UTC](https://discuss.elastic.co/t/how-to-mitigate-routing-is-missing-for-join-field-join-field/128145 "2018-04-16T09:08:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![modalikasi](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@modalikasi](https://discuss.elastic.co/u/modalikasi)\
**Post date:** [April 16, 2018, 9:08am UTC](https://discuss.elastic.co/t/how-to-mitigate-routing-is-missing-for-join-field-join-field/128145/1 "2018-04-16T09:08:17Z")

</div>

Getting the following exception "[routing] is missing for join field [join\_field]" while reindexing data from 1.x to 6.x and 2.4 to 6.x. How to resolve this kind of issue. Actually we have 3 document types in that one is parent and other two are child documents, modified dynamic mapping template file to establish relationship between paraent and child using join data type as explained in the elasticsearch documentation.

Here is the join code.

> "join\_field": {  
> "type": "join",  
> "relations": {  
> "parent": ["child1", "child2"]  
> }  
> }

I'm trying to reindex per document type. Here is the script.  
_Parent_

> POST \_reindex  
> {  
> "source": {  
> "remote": {  
> "host": "[http://remote-host:9200](http://remote-host:9200)"  
> },  
> "index": "data-2017.10",  
> "type": "Session"  
> },  
> "dest": {  
> "index": "reindex-data-2017.10"  
> },  
> "script": {  
> "params": {  
> "parentJoin": {  
> "name": "Session"  
> }  
> },  
> "source": """  
> ctx.\_source.type = ctx.\_type;  
> ctx.\_id = ctx.\_id;  
> ctx.\_type = 'doc';  
> ctx.\_source.join\_field = params.parentJoin;  
> """  
> }  
> }

_Child1_

> POST \_reindex  
> {  
> "source": {  
> "remote": {  
> "host": "[http://remote-host:9200](http://remote-host:9200)"  
> },  
> "index": "data-2017.10",  
> "type": "child1"  
> },  
> "dest": {  
> "index": "reindex-data-2017.10"  
> },  
> "script": {  
> "params" : {  
> "childJoin": {  
> "name": "child1",  
> "parent": "1"  
> }  
> },  
> "source": """  
> ctx.\_source.type = ctx.\_type;  
> ctx.\_id = ctx.\_id;  
> ctx.\_type = "doc";  
> ctx.\_routing = ctx.\_source.sessionID;  
> params.childJoin.parent = ctx.\_source.sessionID;  
> params.childJoin.name = ctx.\_source.type;  
> ctx.\_source.join\_field = params.childJoin;  
> ctx.remove('\_parent');  
> """  
> }  
> }

_Child2_

> POST \_reindex  
> {  
> "source": {  
> "remote": {  
> "host": "[http://remote-host:9200](http://remote-host:9200)"  
> },  
> "index": "data-2017.10",  
> "type": "child2"  
> },  
> "dest": {  
> "index": "reindex-data-2017.10"  
> },  
> "script": {  
> "params" : {  
> "childJoin": {  
> "name": "child2",  
> "parent": "1"  
> }  
> },  
> "source": """  
> ctx.\_source.type = ctx.\_type;  
> ctx.\_id = ctx.\_id;  
> ctx.\_type = "doc";  
> ctx.\_routing = ctx.\_source.sessionID;  
> params.childJoin.parent = ctx.\_source.sessionID;  
> params.childJoin.name = ctx.\_source.type;  
> ctx.\_source.join\_field = params.childJoin;  
> ctx.remove('\_parent');  
> """  
> }  
> }

_Exception_

> {  
> "index": "reindex-data-2017.10",  
> "type": "doc",  
> "id": "AV9rmff8hwZtXSiQ-stJ",  
> "cause": {  
> "type": "mapper\_parsing\_exception",  
> "reason": "failed to parse",  
> "caused\_by": {  
> "type": "illegal\_argument\_exception",  
> "reason": "[routing] is missing for join field [join\_field]"  
> }  
> },  
> "status": 400  
> },

Please suggest right approach to perfrom reindex when we have parent/child relation (using join data type)?

---

<div class="post-metadata">

**Author:** ![siddharthgoel88](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/siddharthgoel88/32/10616_2.png) [@siddharthgoel88](https://discuss.elastic.co/u/siddharthgoel88)\
**Post date:** [April 17, 2018, 4:55am UTC](https://discuss.elastic.co/t/how-to-mitigate-routing-is-missing-for-join-field-join-field/128145/2 "2018-04-17T04:55:05Z")

</div>

@modalikasi any luck in this? I am also running into the same issue.

---

<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:** [May 15, 2018, 4:55am UTC](https://discuss.elastic.co/t/how-to-mitigate-routing-is-missing-for-join-field-join-field/128145/3 "2018-05-15T04:55:14Z")

</div>

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