1

How should I do case insensitive and accent insensitive queries in MongoDB?

Example: A search for "sandalias" should return results like "sandálias"

For now my query is only case insensitive:

name :  {     $regex: word,
              $options: "i"
        };

I'm using MeteorJS my mongo version doesnt supports collations

Miguel Morujão
  • 1,131
  • 1
  • 14
  • 39
  • @felix I'm using MeteorJS my mongo version doesnt supports collations – Miguel Morujão Jun 29 '17 at 10:55
  • 1
    @MMrj i'd suggest editing your q to include this important information – Alex Jun 29 '17 at 10:56
  • what's you mongodb server version ? – felix Jun 29 '17 at 10:56
  • @felix probably not quite, since your own answer there does not actually show usage of a [`$text` search](https://docs.mongodb.com/manual/reference/operator/query/text/). There are options on a `$text` search though that allow this. You could include that in the answer. – Neil Lunn Jun 29 '17 at 10:57
  • 1
    There is no reason why you cannot use a separate server instance with meteor. In fact, you have to deploy at some point and that is exactly what is going to happen. Pointing your meteor app at an external server is an easy exercise. – Neil Lunn Jun 29 '17 at 10:59
  • 2
    @NeilLunn **`$text`** is diacritic insensitive by default since MongoDB 3.2. I'll update my answer to mention this – felix Jun 29 '17 at 11:06
  • 1
    @felix Please do. Also include a text search example and not just and equality search example and I will be happy to point there as a duplicate. Already voted on it BTW, since there is no other answer pointing out the usage. – Neil Lunn Jun 29 '17 at 11:09

0 Answers0