I’m trying to find a way to modify a field value in a deeply nested json document using queries from web console. My document is something like this.
{
"docid": bdadc59c9db9461fbebd8ae21f5a80b0,
"pid": 123456,
"sid": 1,
"items": [{
"flag": false,
"data": {
"next": "1",
"cause": ""
},
"tz": "-0400",
"text": "This is my super secret id GVID 1234 keep it safe",
"ts": "1606971971700"
}, {
"flag": false,
"tz": "-0400",
"ack": false,
"text": "Taken care of. Thank you",
"ts": "1606972104492"
}],
"_id": "bdadc59c9db9461fbebd8ae21f5a80b0.1"
}
I’m able to search for GVID xxxx
using select c._id from
messages as m where any item in m.items satisfies regex_contains(item.text, "\\bGVID\\s*\\b\\d{3,4}\\b*") END;
. This query returns ids of those documents.
What I’m trying to achieve is search and modify the text This is my super secret id GVID 1234 keep it safe
to This is my super secret id GVID xxxx keep it safe
in a single statement. Is it possible to do from WebConsole? I tried a numer of ARRAY_* operations and I couldn’t get them correct. Appreciate some help from N1QL experts in this community.