Hello, I would like to create an "advanced search" for a couchDB database, and I don't know how to do it without reduce. The documentation warns me not to follow this strategy :
A common mistake new CouchDB users make, is attempting to construct complex aggregate values with a reduce function. Full reductions should result in a scalar value, like 5, not, for instance, a JSON hash with the set of unique keys, and the count of each. The problem with this approach is that you’ll end up with a very very large final value. The number of unique keys can be nearly as large as the number of total keys, even for a large set. It is fine to combine a few scalar calculations into one reduce function, for instance to find the total, average, and standard deviation of a set of numbers in a single function. http://books.couchdb.org/relax/design-documents/views For example, imagine a music database as iTunes. I would like to create a script to query such as : Sort all songs by genre then album : - with 3 or 5 stars - artist name matching "floyd" - duration between 5 and 8 minutes - heard last week (perhaps another couch database, logging user actions) - .... All the parameters are optional. Users can choose to filter with only 2 or 5 parameters. Other parameters should be added. My first reflex is to think like sql with index and joins. But how to code it with views and reduce ? Thank you for all, couchDB users ! Frédéric
