Couchbase - getting multiple documents using a key prefix

in Couchbase DB, is it possible to get multiple documents using a key prefix as a query string, and it returns all key values ​​that have a key starting with the supplied key prefix (for example, an operator type)? without using views or queries / indexes.

I design my keys as shown on slide 51 of this presentation http://www.slideshare.net/Couchbase/couchbase-103-data-modeling

+5
source share
1 answer

If you do not want to use a query of the form or n1ql, there is no way to get documents without knowing their exact keys. That is, you can only get keys based on the prefix, if you have a way to pre-create possible keys on the client side, for example. User-1, User-2 ... User-n.

However, you can query the prefix you are talking about in n1ql without creating any additional indexes, because with n1ql you will already have the main index for all the keys in the document. So you can do something like "SELECT META(myBucket).id FROM myBucket WHERE META(myBucket).id LIKE "prefix%";

+10
source

All Articles