MongoDB: how to find documents ignoring case sensitive, accents and percent like logic (%)
<p>I would like to make a search on a collection in my mongodb database. In my collection, I have documents with the field "name" can be values like:</p>

<p>[i] "Palácio Guanabara", "Palácio da Cidade", "Festa Palácio", etc.</p>

<p>When a user types a search like "pala" or "palá" or "Pala" or "PalÁ", all those itens in [i] must build the result set.</p>

<p>I found that in MongoDB I could use regex in searches, like:</p>

<pre><code>{ "name": { $regex: new Regex(".*pala.*", "i") } }
</code></pre>

<p>Ok, this approach is case insensitive and use the percent like logic from SQL ("%pala%"). But, it isn't ignore accents from the register in database.</p>

<p>I found another alternative with the $text index: <a href="https://docs.mongodb.org/manual/core/index-text/" rel="noreferrer">https://docs.mongodb.org/manual/core/index-text/</a></p>

<p>This approach can ignore case sensitive and accents. But the "search" does not accepts a regex, so I can't search things like "%pala%".</p>

<p>Summing up, I want to make the following SQL query in MongoDB:</p>

<pre><code>select * from collection where remove_accents(upper(name)) like '%Pala%'
</code></pre>

<p>And this query returning results with name like "palácio", "palacio", "PaláCiô", etc.</p>