How to implement sophisticated search filters in couchdb? Should I avoid temporary views?

I want to manage my custom objects in a grid. I want to sort them, and I want to have a search filter for each column.

My dynamically created temporary view works fine:

function(doc){ if(doc.type === 'User' && // Dynamic filters: WHERE firstName LIKE '%jim%' AND lastName LIKE '%knopf%' (doc.firstName.match(/.*?jim.*?/i) && doc.lastName.match(/.*?knopf.*?/i)) ) { // Dynamic sort emit(doc.lastName, doc); } } 

BUT itโ€™s written everywhere that you should AVOID temporary viewing. Is there a better way? Do I have to keep these queries on demand at runtime?

thanks

+4
source share
1 answer

You should definitely not use temporary representations, as they need to be recounted every time they are requested. (which is a very "expensive" process). The saved view is beautiful when you know which fields you are looking ahead of time. (it builds the index once, only after that it makes incremental changes)

However, you will not be able to get a โ€œcontainingโ€ search. (you can get exact matches and "starts with" matches, but this is not what your example shows). If you need a special request, you should seriously consider couchdb-lucene .

+4
source

All Articles