Mongodb queries using like and disregarding accents and case

Asked

Viewed 771 times

0

I would like to know how I can make queries in mongodb when I can consult in any position of the string (Like), but it would also be necessary to disregard special characters such as accents.

I was able to disregard the special characters in the queries but it does not search for parts of a string. Any suggestions as to how I should make such a query?

Coleção

db.pessoas.find({$text: {$search: "jose"})

Result obtained

Resultado obtido

But he wanted the name returned Joseane containing the characters Jose

1 answer

-1

Voce can use regex to search:

db.getCollection('pessoas').find({ nome: { $in: [ /^Jos/i, /^é/ ] } } )

Browser other questions tagged

You are not signed in. Login or sign up in order to post.