How to mitigate "[routing] is missing for join field [join_field]

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"
},
"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"
},
"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"
},
"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)?

2 Likes

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

1 Like

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