mongodb - MongoDB 的 $lookup 中的 $geoWithing
问题描述
我正在寻找查询以在其他集合的查找中创建 $geoWithin。
我实际上拥有的是:
db.getCollection('polygons').aggregate([{
$lookup: {
from: "coll1",
let: { geometry_poly: "$geometry" },
pipeline: [
{ $match: { "location": { $geoWithin: { $geometry: "$$geometry_poly" } } } },
{ $project: { name: "$hashtag" } }
],
as: "PolyAvg"
}
}])
科尔1:
{
"_id" : ObjectId("5e90bf7b49ebb0e6b459a00f"),
"hashtag" : "stayhome",
"timestamp" : ISODate("2020-04-10T18:48:25.876Z"),
"location" : {
"type" : "Point",
"coordinates" : [
14.421425,
40.26084
]
},
}
多边形:
{
"_id" : ObjectId("5e95d56e49ebb0e6b45a34c4"),
"type" : "Feature",
"geometry" : {
"type" : "Polygon",
"coordinates" : [
[
[ ... , ... ]
]
]
}
}
当我执行此操作时,它总是说 $$geometry_poly 无效
解决方案
推荐阅读
- java - 解码 base64 字符串并重新编码返回的字节不会返回相同的字符串
- rx-java - 获取正在运行的 RxJava (1.x) Observable (blocking) 的最新元素的最简单方法
- html - 在 contentBox 上添加操作代码 - Liferay - AUI 模态
- html - 找不到在哪里更改“背景附件:固定;”
- c# - 我可以在 Unity 中的特定位置销毁克隆的游戏对象吗?
- php - 如何在 laravel 中为 hasMany 关系分页(App\News::user 必须返回一个关系实例)
- php - 将 MySQL 更改为由 bot 电报接受的特殊值
- windows - 修改安装路径
- java - 抽象类中的单元测试具体方法
- excel - 选择excel范围内的最后一个非空单元格