Hi folks! Is it a good idea to query couchdb like this:
- stored documents have format like this: { "_id": ..., "_rev": ..., "Title": "Test title", "Accounts": ["joe", "johny"], "Labels": ["work", "school", "programming"], "Status": 0, "Type": "ticket" } - map function will generate rows where keys consists of document field name and it's value (multiple times when it's an array): function(doc) { if(doc.Type && (doc.Type == "ticket")) { emit(["_id", doc._id], null); emit(["title", doc.Title], null); for(var index in doc.Accounts) { emit(["accounts", doc.Accounts[index]], null); } for(var index2 in doc.Labels) { emit(["labels", doc.Labels[index2]], null); } emit(["status", doc.Status], null); } } - list function[1] will merge the map function result based on data sent in POST like this: curl -X POST -d '{"keys":[["accounts","joe"],["labels","school"],["status",2]]}' -H "Content-Type: application/json" http://127.0.0.1:5984/testdb/_design/docs/_list/listTest/adhoc?include_docs=true Result contains only "ticket" type documents which have "joe" in Accounts field, "school" in Labels field and number 2 in Status field. Is it a good idea to use this "pattern" for "ad-hoc querying" in couchdb? I can imagine that database with millions of documents (or with thousands of documents where each document have lots of fields or big arrays) could have serious performance issues due to map and list function from this scenario. Thanks for your help and time. [1] http://www.vertigrated.com/blog/2010/04/generic-ad-hoc-queries-in-couchdb/