Monday 7 August 2017

How can you do accent insensitive searches with regex?

It seems if you use the $text operator, you can use diacritics but it doesnt work with regex.Is this relative? http://ift.tt/2vx37aD seems regex with collation, strength: 1 doesnt work either.Here is an example query I have:router.get('/wine/search/wine/:name', auth, function(req, res) { wineName = req.params.name; var wineSlug = wineName.replace(/\s+/g, '-').toLowerCase(); var db = req.db; var collection = db.collection('wines'); var wineSearch = '/' + wineSlug + '/'; collection.find({slug: eval(wineSearch)}).collation({ locale: 'en', strength: 1 }).toArray(function(err, docs) { res.render('searchwine', { "wineslist": docs, params: { slug: wineSlug, winecount: docs.length, search: req.params.name } }); }); });

Submitted August 07, 2017 at 03:18PM by InsertCoinPushStart

No comments:

Post a Comment