Hi, I have the following json objects and I want to make a join with the top level and their childres.
I’ve achieved to make a join between the higher json object level and the another document, but I can’t make the same join with the sub-documents belonging higher json object level.
Document a:
[
{
"node": {
"name": "products",
"sections": [
{
"name": "refund",
"sections": []
}
]
}
},
{
"node": {
"name": "info",
"sections": [
{
"name": "contact",
"sections": []
},
{
"name": "help",
"sections": []
}
]
}
}
]
Document B:
[
{
"word": {
"_id": "en_US-info",
"wordKey": "info",
"wordValue": "Information"
}
},
{
"word": {
"_id": "en_US-products",
"wordKey": "products",
"wordValue": "Products"
}
},
{
"word": {
"_id": "es_ES-info",
"wordKey": "info",
"wordValue": "Informacion"
}
},
{
"word": {
"_id": "es_ES-products",
"wordKey": "products",
"wordValue": "Productos"
}
},
{
"word": {
"_id": "es_ES-refund",
"wordKey": "refund",
"wordValue": "Reembolso"
}
},
{
"word": {
"_id": "es_ES-help",
"wordKey": "help",
"wordValue": "Ayusa"
}
},
{
"word": {
"_id": "en_US-refund",
"wordKey": "refund",
"wordValue": "Refund"
}
},
{
"word": {
"_id": "en_US-help",
"wordKey": "help",
"wordValue": "Help"
}
},
{
"word": {
"_id": "es_ES-contact",
"wordKey": "contact",
"wordValue": "Contacto"
}
},
{
"word": {
"_id": "en_US-contact",
"wordKey": "contact",
"wordValue": "Contact"
}
}
]
Desired output:
[
{
"name": "Informacion",
"sections": [
{
"name": "Contacto",
"sections": []
},
{
"name": "Ayuda",
"sections": []
}
]
},
{
"name": "Productos",
"sections": [
{
"name": "Reembolso",
"sections": []
}
]
}
]
But, In sections array, the name is not resolved by the join.
This is the query I’ve developed:
SELECT node.*, word.wordValue as name FROM
testword JOIN
testnode ON KEY "es_ES-" || node.name FOR word
The output of the query:
[
{
"name": "Informacion",
"sections": [
{
"name": "contact",
"sections": []
},
{
"name": "help",
"sections": []
}
]
},
{
"name": "Productos",
"sections": [
{
"name": "refund",
"sections": []
}
]
}
]