I have this users collection:
{
"_id" : ObjectId("501faa18a34feb05890004f2"),
"username" : "joanarocha",
}
{
"_id" : ObjectId("501faa19a34feb05890005d3"),
"username" : "cristianarodrigues",
}
{
"_id" : ObjectId("501faa19a34feb05890006d8"),
"username" : "anarocha",
}
When I query this: db.users.find({'username': /anaro/i})
results are sorted in natural order (insertion order).
I would like to sort them in a similarity search-term order. In this case results should return by this order:
{ "_id" : ObjectId("501faa19a34feb05890006d8"), "username" : "anarocha", } { "_id" : ObjectId("501faa18a34feb05890004f2"), "username" : "joanarocha", } { "_id" : ObjectId("501faa19a34feb05890005d3"), "username" : "cristianarodrigues", }