I’m using couchbase 6.5.1 and java sdk 2.7.1
I have compare speed between using N1QL and SDK, it’s much faster using SDK
(N1QL insert vs SDK upsert)
I have merge query below:
MERGE INTO myBucket AS target
USING [
{ “name”:“test”}
] AS source
ON key “TEST::1”
WHEN MATCHED THEN
UPDATE SET target.name= source.name
WHEN NOT MATCHED THEN
INSERT (
{
“name”: source.name,
} )
returning target.*;
let say i have 5 concurrent message in kafka to be processed with sequence inside doc :
{ “seq”:”a” ,… } { “seq”:”b” ,…} { “seq”:”c” ,…} { “seq”:”d”,…} { “seq”:”e”,…}
this will be appended into 1 couchbase doc id with expected result:
If you are using SUBDOC array insert ot array append will not work.
You need to get whole array and construct by inserting right order and write . If cas miss match you need to repeat.