let searchResult = await UserModel.aggregate([
{
$search: {
index: indexes.USERS_SEARCH_INDEX,
text: {
query: searchText,
path: [
'profile.first_name',
'profile.last_name',
'profile.current_organization',
'profile.current_position',
'profile.headline',
],
fuzzy: {
maxEdits: 2,
}
}
}
}
]);
尝试使用 Atlas Search 参考实现模糊搜索 - https://www.mongodb.com/atlas/search
运行此代码会返回以下错误 -
MongoServerError: $_internalSearchMongotRemote is only valid as the first stage in a pipeline
我正在使用这个库https://www.npmjs.com/package/mongoose-delete,它破坏了聚合。通过删除包装来修复它。谢谢!