Collate Mongodb

Asked

Viewed 372 times

3

I need to make an auto complete that consumes a Mongodb database. The words can be written with or without accent, uppercase or lowercase, that is, I need to define a collate in the Ngo that allows me to do a search that ignores the accent and the case sensitive.

Mongo has this configuration module ? If not, is there any way to resolve this with the c driver# ?

var filterBuilder = Builders<UnidadeCurricular>.Filter;
var filter = filterBuilder.Exists(a => a.DeletedAt, false) & filterBuilder.Where(a => a.Nome.StartsWith(nome));
  • I went to do some research, and I found some guys saying that the best way is for you to save the field to be searched 2 times [Columns], 1 time NORMAL, and another CLEAN and all MINUTE. is even better in terms of search and performance. http://stackoverflow.com/questions/4458950/mongodb-and-c-case-insensitive-search

  • So, I had seen this way of doing it. It solves but it does not seem to me a "right" way of doing it. will not have a more automatic way of doing it . ?

2 answers

0

Has a query operator called $text.

An example of how to do:

var comandoPesquisa = new CommandDocument
{
    { "text", typeof(UnidadeCurricular).Name },
    { "search", nome }
};

var commandResult = _database.RunCommandAs<TextSearchCommandResult<T>>(comandoPesquisa);

I took it from here.

0

Browser other questions tagged

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