1

Using the couchbase SDK or spring data couchbase, is there a way to look up documents in a [low, high] range of ids, without using an index?

In more details, I have a bucket with document ids structured in the standard ${entityType}::${id} format, and I would like to get all documents in a certain [low, high] range of ids.

For instance, for the Address entity type, I would like to get all Address documents whose ids are between 1000 and 2000, inclusive. Given only Address::1234, Address::1567 and Address::2222 are in my bucket, only the two first documents should be returned.

I would expect that it is possible since it seems possible in the GUI Bucket > Documents - show range but I can't seem to find how.

Lastly, I don't want to use indexes because

  1. I'm using couchbase community and index replicas are only available in the enterprise edition, which makes manually duplicating them and managing them a pain
  2. I'm trying to save space on my couchbase server

Couchbase SDK version: 3+, using java

bernard paulus
  • 1,644
  • 1
  • 21
  • 33
  • 1
    This is a common feature request, tracked as [MB-35297](https://issues.couchbase.com/browse/MB-35297) (currently targeting the "Morpheus" release, which will probably be 7.2). In the meantime you could use a [View](https://docs.couchbase.com/server/current/learn/views/views-intro.html), but that would just create a different kind of index and would still use space on your server. – dnault Dec 01 '21 at 20:31
  • Hello @dnault - thank you for your answer, good to know that it's coming! On my side, I'm considering the following workaround: what about making a REST call to `${lb_in_front_of_couchbase}/pools/default/buckets/Entity/docs?skip=0&include_docs=true&limit=100&startkey="Address%3A%3A1000"&endkey="Address%3A%3A2000"`? That seems to work – bernard paulus Dec 02 '21 at 08:47
  • 1
    Hi! I don't believe that's a supported API, but if you can accept the risk the API might change or be removed, then go ahead. For what it's worth, it looks like the API hasn't changed since at least 2017, if [this forum post](https://forums.couchbase.com/t/is-it-possible-to-select-data-by-key-pattern-without-adding-extra-index/14695) is any indication. – dnault Dec 02 '21 at 20:34
  • Dear @dnault, copy-paste your comments in an answer and I'll gladly accept it! Thanks a lot – bernard paulus Dec 02 '21 at 21:17

0 Answers0