Update value in an array of strings within an array

Hi,

I am using couchbase 4.1.
I am trying to change the a particular value in an array within an array in the following couchbase document:

{
  "id": "1234",
  "lastModifiedDate": 1472575054702,
  "relationKeys": [
    "chat-id_454212509A",
    "uiid_1234"
  ],
  "relationPairs": [
    {
      "certainty": 1,
      "createdDate": 1472574488762,
      "element1": {
        "entityId": "454212509A",
        "entityType": "uiid"
      },
      "element2": {
        "entityId": "9TDNCG01",
        "entityType": "ccn"
      },
      "inferenceSource": "test.xml",
      "lastModifiedDate": 1472574488762,
      "relationKeys": [
        "ccn_9TDNCG01",
        "user-id_454212509A"
      ]
    },
    {
      "certainty": 1,
      "createdDate": 1472574159619,
      "element1": {
        "entityId": "454212509A",
        "entityType": "uiid"
      },
      "element2": {
        "entityId": "454212509A",
        "entityType": "chat-id"
      },
      "inferenceSource": "booking.xml",
      "lastModifiedDate": 1472574159619,
      "relationKeys": [
        "chat-id_454212509A",
        "user-id_454212509A"
      ]
    }
  ]
}

I am trying to change particular values that start with user-id to uiid in the relationKeys array within the relationPairs array using the query:

UPDATE write SET e = REPLACE(e, ‘user-id’, ‘uiid’) FOR r in relationPairs.relationKeys WHEN r.e LIKE ‘user-id%’ END WHERE id = '1234;

The query runs successfully but the document does not update.

Can anyone show me where I am going wrong? I have also tried using a combination of FOR statements but I get syntax errors on FOR when I run those queries.

Any help would be greatly appreciated.

Regards,
Damian.

Hi @damianChapman,
upcoming 4.5.1 has an improvement to help this. See following posts for details:

-Prasad

Thanks for your reply Prasad.