I am running into the same problem with this alert: Query Targeting: Scanned Objects / Returned has gone above 1000 - #2 by Pavel_Duchovny
My search looks like this:
const searchStep = {
$search: {
index: 'autocomplete', // optional, defaults to "default"
compound: {
minimumShouldMatch: 0, // if one clause fails, still get documents back
should: [
{
autocomplete: {
query: args.searchText,
path: 'email',
},
},
{
autocomplete: {
query: args.searchText,
path: 'firstName',
},
},
{
autocomplete: {
query: args.searchText,
path: 'lastName',
},
},
],
},
},
}
Is there anything I can do?
After the $search I add a $match like
{
$match: {
clinicId: args.clinicId,
},
},