Good afternoon. I am stuck in the following scenario: I have a database (mongodb) of names, and I need to do a search using regex (so far ok). Let's assume the bank is this:
[{id: 1, Nome: "Luiz Claudio"}, {id: 2, Nome: "Luiz"}, {id: 3, Nome: "Luiz Felipe"}]
I need someone to search for "Luiz" the first result is the item id 2, because if the person searched only for "Luiz" she wants the result closest to that.
The real problem is sorting the results. Is there any way I can do this sorting only by commands in Mongo?