In a 6.6 index, I have a join field 'relation' like so:
"relation": {
"type": "join",
"relations": {
"parent": "child"
}
Several hundred parent docs need to become children to another existing parent doc. I have lists of all the relevant _id values for 'demoted' docs and 'winner' docs. For example, I need to make 5678 a child of 5677
{
"_index": "myindex",
"_type": "place",
"_id": "5678",
"_source": {
"children": [],
"relation": {
"name": "parent"
}
}
},
{
"_index": "myindex",
"_type": "place",
"_id": "5677",
"_source": {
"children": [],
"relation": {
"name": "parent"
}
}
}
Currently, all child records include "_routing": "1". I don't remember why I configured it that way, e.g.
{
"_index": "myindex",
"_type": "place",
"_id": "6368962",
"_routing": "1",
"_source": {
"children": [],
"relation": {
"parent": "13005543",
"name": "child"
}
}
}
So the goal for the demoted doc is...
{
"_index": "myindex",
"_type": "place",
"_id": "5678",
"_routing": "1",
"_source": {
"children": [],
"relation": {
"parent": "5677",
"name": "child"
}
}
}
I have tried this _update in Kibana console
POST myindex/place/5678/_update
{"script":{
"source": """
ctx._source.relation=params.relation;
ctx._source.children=params.children;""",
"lang": "painless",
"params":{
"relation": {"name":"child","parent":"5677"},
"children": [] }
}}
and get this error:
"[routing] is missing for join field [relation]"
I tried adding ctx._routing=1;
to the script, and it has no effect.
Is there no way to "demote" a parent to a child and specify its new parent?
thx