N1QL query to update one document value from another document based on some condition


Want to update AKVFunctionDao document from another matching document but doesn’t seem to work. No errors but matching documents not getting updated. In this case softwareFunctionName is common between both document but both have different akvId.

MERGE INTO DPE-AkvsAndSoftwares as a
USING (SELECT b.softwareFunctionName, b.v1 FROM DPE-AkvsAndSoftwares AS b WHERE b.type = “AKVFunctionDao” AND b.akvId=“a34df8cc-e093-4437-9973-f4448f433789”) AS B
ON KEY B.softwareFunctionName
UPDATE SET a.v1 = B.v1 WHERE a.type = “AKVFunctionDao” AND a.akvId=“516c9027-7e7e-4b71-baed-dac996cc9526”;

Would you please paste a couple sample documents that you would expect to be involved in this query?

The above syntax tells softwareFunctionName must be document key in a then only updates.
6.0.0 you need to have relation through document key.
6.5.0 (In beta) you can do relation through filed names. ANSI merge

Some sample docs attached for reference
Couchbase Docs.zip (7.1 KB)