I'm having documents like this in kibana:
...
"children_relationship_type": [
"Blood",
"Blood",
"Adopted",
"Adopted"
],
"children_uuid": [
"a385a319",
"f27e7c95",
"e01ebd42",
"773622e4"
],
...
I want to create a painless scripted field from these 2 fields, with the following output:
"siblings": [
{"id": "a385a319","type": "Blood"},
{"id": "27e7c95","type": "Blood"},
{"id": "e01ebd42","type": "Adopted"},
{"id": "773622e4","type": "Adopted"}
],
I'm using this painless script:
def res="";
def i=0;
for(i=0; i < doc['sibling_uuid'].length;i++){
res +='{"id": "'+doc['sibling_uuid'][i] + '","type": "' + doc['sibling_relationship_type'][i]+"},";
}
return res;
But this gives the following (wrong) output:
"siblings": [
{"id": "773622e4","type": "Blood"},{"id": "a385a319","type": "Adopted"},{"id": "e01ebd42","type": ""},{"id": "f27e7c95","type": "}
]
Can you help me?
Thanks. Frank