This kind of query is not typically what CouchDB was built for. You can
nonetheless achieve what you wish by building a view (like this).
functionemit_normalized_substrings(txt) {
varr=txt.toLowerCase();
r=r.replace(newRegExp("\\s",'g'),"");
r=r.replace(newRegExp("[àáâãäå]",'g'),"a");
r=r.replace(newRegExp("æ",'g'),"ae");
r=r.replace(newRegExp("ç",'g'),"c");
r=r.replace(newRegExp("[èéêë]",'g'),"e");
r=r.replace(newRegExp("[ìíîï]",'g'),"i");
r=r.replace(newRegExp("ñ",'g'),"n");
r=r.replace(newRegExp("[òóôõö]",'g'),"o");
r=r.replace(newRegExp("œ",'g'),"oe");
r=r.replace(newRegExp("[ùúûü]",'g'),"u");
r=r.replace(newRegExp("[ÿ]",'g'),"y");
r=r.replace(newRegExp("\\W",'g'),"");
for(vari=0;i<=r.length-3;i++) {
emit(r.substr(i,r.length-i),docId);
}
}
map=function(doc) {
emit_normalized_substrings(doc.fieldYouWantToQuery);
};
For "Hermes":
hermes: id of your doc
ermes: id of your doc
rmes: id of your doc
mes : id of your doc
are going to be emitted.
A range query erm -> erm\uffff will be equivalent to %erm%
Note that you need min 3 characters for your query to work with this view.
Cheers,
Antoine
Hermes Alves <mailto:[email protected]>
11 juin 2015 00:44
Hello,
I'm a newbie on CouchDB. Thanks for your patience :)
I need to find by keword on couchdb databse use a query type "Like %key%"
Anyone can help me to do this using AngularJS? I already searched on
Google, but i can't find a functional sample.