When building an autocomplete aggregation pipeline using MongoDb Atlas search indexes. How do I limit the autocomplete to only search through specific ID's?
I'm building search functionality where a user can search for people and the application should autocomplete the search but the user should only be suggested users that it is allowed to view.
My pipeline (works but need to be filtered):
{
'compound': {
'should': [{
'autocomplete': {
'query': "John",
'path': 'firstName'
}
}, {
'autocomplete': {
'query': "Doe",
'path': 'lastName'
}
},
]
}
}
If I have an array of people Id:s that the user can view, how do I go about only applying the autocomplete search on the people with the ID:s I supply?
Something like {_id: {$in myIdList}}