Get document by id using regullar expression


#1

Is there a way to get a document by id using regex, or is there a way to set query startkey and endkey by regex and get the query rows ?

if regex is supported then this could change the way of storing documents and reference document keys.


#2

No; that’s not possible with any type of index I know about. Indexes just store keys in order and let you quickly find a key by exact match.

You can do this yourself by iterating over all documents and doing a regex match on the docID. Even if we implemented this functionality, we’d be doing it the same way. It won’t scale very well, of course, so I wouldn’t recommend it if you have a large data set.

Part of working with databases is adapting to doing things in ways that they’re efficient at. There are probably other ways of doing the key lookup you want to do, that will work better.