Some/every condition in N1QL for analytics

How do I write a some/every condition in N1QL for analytics?
Some are simple, but others are not:

SOME c IN channels SATISFIES c = "myChannel" END => "myChannel" IN channels

what about this one?

SOME c IN channels SATISFIES c IN ["channel1","channel2"] END

I tryed this one and it works, but is there a better solution?

ARRAY_LENGTH( ARRAY_INTERSECT(channels,["channel1", "channel2"]) ) > 0

How to handle more complex conditions of the “satisfies”?

Analytic supports SOME/EVERY

Thank you @vsr1, after a little bit I found what was the issue:

N1QL for Query

WHERE SOME el IN array SATISFIES condition END AND other conditions

N1QL for Analytics

WHERE (SOME el IN collection.array SATISFIES condition) AND other conditions

You need to put the expression between brackets and specify the collection, otherwise it doesn’t work. This is missing on the N1QL for Analytics vs. N1QL for Query | Couchbase Docs

Since this condition on channels will be in most of my analytics queries, what would be the best analytics index? I tried to create an index on channels as array but it doesn’t work

Array indexing in Analytic might be coming in next release. cc @dmitry.lychagin

1 Like

Yes, Array indexing support in Analytics is planned for the next release.

1 Like