mongodb - 具有 nearSphere 条件的 MongoDB 查找表达式
问题描述
我有一个场景,我必须根据他们的位置加入我的餐厅和拉链系列。
餐厅
[{
"_id" : ObjectId("55cba2486c522cafdb059deb"),
"location" : {
"coordinates" : [
-74.138492,
40.631136
],
"type" : "Point"
},
"name" : "Indian Oven"
}]
拉链
[{
"_id" : "99950",
"city" : "KETCHIKAN",
"loc" : [
-133.18479,
55.942471
],
"pop" : 422,
"state" : "AK"
}]
现在我必须加入这两个基于 nearSphere 地理空间查询的集合。我应该在 $lookup 管道中使用什么标准。
我尝试的是
db.restaurants.aggregate([
{
$lookup:
{
from: "zips",
let: { location: "$location" },
pipeline: [{
$match: {
'loc': { $nearSphere: '$$location' }
}
}],
as: "t"
}
}
]);
但这不起作用。
需要帮忙
解决方案
推荐阅读
- pug - 我的 app.js 文件中有什么错误 | 我的“/demo”命令不起作用
- python - 想要消除为减少重复而创建的类中的重复
- javascript - 如何模拟在 JavaScript 或 jQuery 中按下的退格键
- sql - SQL 中的透视聚合
- html - HTML 图像未加载。它显示了alt。但不是图像
- javascript - Javascript如何格式化饼图DataTable的json值
- visual-studio-code - VSCode - “查找”框中的文本突出显示
- python - 如何在python中计算列表的平方和?
- python - 在 Python 中使用 OpenCV triangulatePoints 时遇到问题
- node.js - 在快速会话中关闭滚动会话不起作用