Using the MongoDB driver for the .NET framework, I need to develop a way of creating a full-text search method that ignores string cases and diacritics.
I’ve already tried using a regex expression for that, but it does not work for strings that have accents and weird casings (diacritics).
var filterDefinition = new BsonDocument("$expr", new BsonDocument("$regexMatch", new BsonDocument
{
{ "input", new BsonDocument("$toString", "$field") },
{ "regex", searchTerm },
{ "options", "i" }
}));
If I create a text index that ignores the diacritics, the full-text search method doesn’t work.
db.BsonDocument.createIndex({name: 'text'},{default_language: 'pt'})
var filter = Builders<BsonDocument>.Filter.Text(searchTerm);
Is there any way of combining these two approaches into something that meets the desired criteria?