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