我正在寻找查询,以便在其他集合的查找中进行$geoWithin。
我实际拥有的是:
db.getCollection('polygons').aggregate([{
$lookup: {
from: "coll1",
let: { geometry_poly: "$geometry" },
pipeline: [
{ $match: { "location": { $geoWithin: { $geometry: "$$geometry_poly" } } } },
{ $project: { name: "$hashtag" } }
],
as: "PolyAvg"
}
}])coll1:
{
"_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无效
发布于 2020-04-18 02:40:18
https://stackoverflow.com/questions/61273434
复制相似问题