N1ql operator & # 8594; IN does not work with other conditions

The following query works just fine when using only the IN statement
SELECT META().id FROM bucket_name WHERE description IN ['Item1','Item2']

But when I run this query, it gives me an empty result
SELECT META().id FROM bucket_name WHERE id = 123 AND description IN ['Item1','Item2']

Am I something wrong or is someone else having the same problem?

+4
source share
2 answers

I think you should take your "IN" condition in brackets to make it work:

SELECT META().id FROM bucket_name WHERE id = 123 AND (description IN ['Item1','Item2'])

This is due to the priority level of operator evaluation by the N1QL processor.

If you run it with EXPLAIN , it will show how it links conditions to each other.

eg.

explain SELECT META().id FROM bucket_name WHERE id = 123 AND (description IN ['Item1','Item2'])

against

explain SELECT META().id FROM bucket_name WHERE id = 123 AND description IN ['Item1','Item2']
+5
source

N1QL (http://docs.couchbase.com/developer/n1ql-dp3/n1ql-intro.html) IN , :

SELECT META(b).id FROM bucket_name b WHERE id = 123 AND description IN ['Item1','Item2']

( ) META(), , N1QL .

+2

All Articles