N1QL querying views

n1ql

#1

I have read on multiple places that it is possible to query views with N1QL.
My vision of it is for instance reducing only (type=“user” AND registration_month=“january”) with a view
and then doing a N1QL on that
for instance WHERE name LIKE “%John”

This is of course only a stupid example but my question is where can I find an example of this if it is possible?


#2

Hi Tony,

Currently, N1QL can create views and use them as indexes:

CREATE INDEX idx ON mybucket(expr1, …) USING VIEW;

This is roughly equivalent to using the N1QL-oriented GSI indexes. The difference is in the underlying architecture (hash-partitioned vs. global index).

Currently, N1QL cannot query pre-existing or manually created views. This is in a future backlog.