I have (what I thought) would be a relatively simple N1QL query that is turning out to be quite difficult. I have a single document that contains a relatively small list of codes with multiple attributes as a nested array:
{
"version": 9,
"docId": "codes-version-9",
"codes": [
{
"code": "001",
"type": "P",
"title": "SYSTEM W MCC",
"weight": 26.2466
},
{
"code": "166",
"type": "P",
"title": "SYSTEM W/O MCC",
"weight": 14.6448
}
]
}
Then I have a list of “accounts” with associated codes. The idea being that when we update the type, title, weight of the codes, we want these updates to be reflected across all accounts:
{
"accountNumber": 123456789,
"docId": "account-customerXYZ-123456789",
"code": "166"
}
So we want to JOIN the “accounts” document against the “codes” document, such that the result would be:
{
"accountNumber": 123456789,
"docId": "account-customerXYZ-123456789",
"code": "166"
"type": "P",
"title": "SYSTEM W/O MCC",
"weight": 14.6448
}
This would be pretty easy if the codes were stored as keys (e.g. codes-001, codes-166) but unfortunately that is not the way this particular piece of data was created. Is it possible to JOIN across the elements of the array in this fashion? I did a ton of reading on the CB 4.5 documentation and can’t find any examples where they’re joining to individual elements within a nested array.