Hi all:
I am using Couchbase server(4.5 Enterprise) Node SDK(v2.3.0) to execute some N1ql.
When I use couchbase web workbench to execut the following N1ql, all works fine. Custom index ‘groups’ is found and applied automatically by couhcbase, even I did not name it in the N1ql.
SELECT meta().id, * FROM `Sample-Bucket` where owner != 'userid' AND recycled IS MISSING AND ANY g IN groups SATISFIES g = 'groupid' END
Here is the index:
CREATE INDEX `#groups` ON `Sample-Bucket`((distinct (array `g` for `g` in `groups` end)))
While I use node SDK with the same N1ql string as follows:
const QUERY_BASE = 'SELECT meta().id, * FROM `Sample-Bucket` where owner != $userid AND recycled IS MISSING AND ANY g IN groups SATISFIES g = $groupid END'
let query = n1ql.fromString(QUERY_BASE).adhoc(false);
params = {
userid: 'userid',
groupid: 'groupid'
};
cluster.executeN1ql(query, params, (err, results) => {
console.log(err);
})
I got error:
{ [ErrInternalError: Unexpected Database Error]
status: 500,
message: 'Unexpected Database Error',
name: 'ErrInternalError',
_trace: true,
_cause:
{ [Error: Unable to decode prepared statement - cause: Unrecognizable prepared statement - cause: JSON unmarshalling error: No operator for name DistinctScan]
requestID: '2d3d28f9-7298-4d4f-93f8-cd35aab04077',
code: 4070,
otherErrors: [] } }
Question is, why the same N1ql works in workbench but not in SDK? Are we able to use n1ql via Node SDK without naming the custom index?
Any ideas?