-
I am struggling in creating a design document key to enable flexible queries (involving multiple conditions in AND or OR) of a complex database stored with CouchDB 3.3.2. After reading related documentations and previous posts on this topic, I realized that it may not be even possible to query a view using more than one condition. For example, if I let my design document to emit an array key with multiple fields like below (I am not entirely sure if I have to pad 0 to the numbers so that they can be sorted lexically in the right order)
I would get keys like With this index, I can search the range of the first field (age) with I can also use a different index strategy - by emitting multiple keys
however, the problem with this is still that I can only use one index ( I see a number of posts suggesting to create different design documents one for each search key, but again, when using is it even possible to use views to filter data with multiple keys in CouchDB? am I doing this incorrectly? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
anyone wants to share your experience on setting up couchdb design document indices? |
Beta Was this translation helpful? Give feedback.
You're right. Both the map-reduce views and _find queries operate on one underlying b-tree index at a time. It won't work to do arbitrary AND or OR queries on 2+ indices and combine them automatically.
If you go with having multiple design documents, each with a different view, you might be able to make your index a bit more efficient by putting multiple views in the same design document. That way they'll update together when the index updates (but they'll also i…