Search code examples
couchbasesql++couchbase-viewnosql

Couchbase N1QL query against existing view


Im new to Couchbase and I'm wondering if it is possible to perform a N1QL query based on an existing View.

I'm curious if something like this would work in Couchbase:

Select * From `MY_VIEW_INSTEAD_OF_BUCKET` where id = 12 

From what I've gathered Views are a way to query the DB and N1QL is the new alternative I'm essentially trying to combined the two.

I ask this question because I believe querying against the view will be more efficient than querying against the entire bucket.


Solution

  • I would refer you to the N1QL documentation. In short, you cannot query views directly. N1QL can create and use indexes using views, and it can also create and use indexes using a dedicated technology called GSI. All the details are in the documentation.