Hello,
We have had a query that contains regex and is case insensitive.
As the collection grows, as i understood, its not efficient to keep it that way.
Here is the query : const query = { username: { $regex: "^" + req.params.username, $options: "i" } }

So I’ve created an Atlas search index
this is my search index

{
"mappings": {
"dynamic": false,
"fields": {
"username": {
"analyzer": "lucene.standard",
"foldDiacritics": true,
"maxGrams": 15,
"minGrams": 2,
"tokenization": "edgeGram",
"type": "autocomplete"
}
}
}
}

and we do this search query:

$search: {
index: 'users',
autocomplete: {
query: `${req.params.username}`,
path: 'username',
tokenOrder: "sequential"
}
}

This works fine most of the time, but for some cases its not as it used to be with regex (obviously) but maybe there are some ways to make the same behaviour as before?
For example searching for “ale” the result “aleksey” does not surface.
Searching for “alek” and it does find it.
Previously with native regex, it used to find all users with prefix * . Is it possible to replicate this with Atlas search ?
Thank you

In my opinion, usernames, just like, password should be case-sensitive. Or normalize to all lower case. You then may forget about $regex just to ignore cases. If you normalize to all lower cases, you could add a display name to be as fancy as you want. Often, people will use an email address anyway. I think people would be confused to see many account with similar names:

John_Doe_1
john_Doe_1
john_doe_1
John_dow_1

Normalizing to all lower cases and having a configurable display name would be akin to be able to change their avatar. Our john_doe_1 could change his display name to

John Doe at work
JD in vacations
John THE Doe
John Doe pissed of by Jonh_Dow_1