Hi @Jason_Tran ,
Thank you so much for the response and the greetings.
Yes, I will contextualize better. First of all, this is the front end consuming my Api: https://notare.dev.qa.smartpos.net.br/ (I am sorry, it is in Portuguese, but I think it will be easy to explain). As you can see, it is a list of products. This req executes the query that I send above.
There is also a search bar. This search bar uses the same requisition, but it passes a query param called “description”. This is the query that will be executed using the Atlas search
db.product.aggregate([
{
"$search": {
"autocomplete": {
"path": "description",
"query": "Nota"
}
}
},
{
"$match": {
"tenantId": "bbb60d4e-212f-445e-97a7-ddad13395931",
"isArchive": false,
"isActive": true
}
},
{
"$sort": {
"description": 1
}
},
{
"$skip": 0
},
{
"$limit": 10
}
])
So, sometimes I can do the query using the $search and sometimes not, but what I really want is to make every time the sorting to be case insensitive. So, I was trying to figure out if it is possible to do this with the Atlas search index. Passing the query in both manners, it is returning case sensitive.
Basically, this is the document:
{
"_id": {
"$oid": "62bb64108f4e7c44e778c81a"
},
"productCode": 430566,
"tenantId": "bbb60d4e-212f-445e-97a7-ddad13395931",
"codAlfa": "1",
"description": "Caderno preto "
}
And for the second question, yes I would use the $toLower, but it would not return the lower field to the final user, I would just use to sort.