While trying the N1QL language, I found a difficulty to request the following:
Let say the document contains, among other attributes, an array of values as in
varArray : [ val1, val2, val3 ]
How can I make the WHERE condition such that the SELECT returns the document containing such an attribute varArray with at least one value being val2 ?
Even if not explained in the N1QL language, it seems that it could be
WHERE val1 IN varArray
Is that the correct way? Is there other way ?
I’m asking this too because when I add an INDEX on this varArray by:
CREATE INDEX varArrayIndex ON MyBucket(varArray)
And then executing the SELECT with EXPLAIN, I saw that it does not take into account the index.
Obviously when I got more than 1 millions of element, the request takes very long (full scan) while it should be quick if the index was used.
Am I missing something ?
Note: I’m using the last available versions of Couchbase and Java SDK and N1QL binaries at the time I wrote this question.