mongodb - 分页时MongoDB geoNear返回空白
问题描述
我试图带回一个配置文件列表。这很好用 find()
但我需要切换到聚合进行距离排序。
现在不是让我的全部 100 条记录每条记录 20 条。我得到了 40,就好像它没有找到其余的一样。
有什么帮助吗?(是的,我尝试过使用简单的 geoNear 过滤器。结果相同)
await Profile.aggregate([
{
$geoNear: {
near: {
type: "Point",
coordinates: [long, lat]
},
distanceMultiplier:
req.user.distanceMetric === "km" ? 0.001 : 0.000621371, // meter to ki:miles
distanceField: "distance",
spherical: true,
maxDistance: distance !== 100 ? distance * 1609.34 : 99999999999
}
},
{
$match: {
$and: [
{
_id: {
$ne: Profile.castID(req.user.profileID),
$nin: doNotDisplayList.map(id => Profile.castID(id))
}
}
]
}
},
{ $skip: skip },
{ $limit: limit }
]).sort({
online: -1
});
解决方案
推荐阅读
- single-sign-on - 通过 SSO 从 Databricks 连接到 Snowflake
- reactjs - 错误消息:TypeError:无法读取未定义的属性“过滤器”
- python - 如何询问打字参数(列表、元组、字典...)
- c# - 有没有办法让 VSC 的 c# 插件在 ubuntu linux 上为目标为 net5.0-windows 的项目工作?
- postgresql - 增加 BBOX 大小但保持比例 (Lon/Lat)
- azure - Azure 存储 Blob CORS 错误
- docker-swarm - 当服务位于多个覆盖网络中时,traefik 不起作用
- python - 如何使用 pandas 弹出导致错误的日期记录?
- qlikview - Qlik sense if 语句在表达式中带有星期过滤器
- python - 使用 WebDriver 截取屏幕截图并始终在进程中