Query on a document key range

In the couchbase UI in the Documents tab you are able to ask it to query for a range of document keys and the UI hits an endpoint that looks like /pools/default/buckets//docs with a startkey and endkey. This seems to be an undocumented endpoint but is there a way to replicate this functionality using N1QL without needing to add a primary key index or view?

This is incredibly useful when needing to get small one off lists of data that fit into a range but I can’t seem to get anything to work and every N1QL query gives me back a 'no index…" error message.

Is this something where I need something with USE KEYS?

N1QL requires GSI/FTS index. i.e GSI secondary/primary index or FTS index.

N1QL queries need more consistent vs UI. It will not use above API (it use to use through view based index, It has been removed, View Indexes for N1QL | Couchbase Docs).

At present it is not possible. In future there might be option to this.

Track via MB-35297

1 Like

@vsr1 thank you for reference to the ticket. Kind of unacceptable that something like this has had a ticket open for almost 2 years and that features are available via the UI that aren’t available from the SDK’s. IMO its severely limiting the usefulness of couchbase since so many things rely on primary indexes yet the guidance is to never use primary indexes.

@ThrowsException As I understand it, the feature in the UI works acceptably well in that context, but did not perform sufficiently well for production SDK usage. That said, please note that the ticket indicates the possibility of making the feature available in the next release.