Mongodb $lookup管道中的地理查询
嗨,我有两个收集区和餐厅 我将从每个区域获取距离,并根据此距离从餐厅集合中获取餐厅列表Mongodb $lookup管道中的地理查询,mongodb,Mongodb,嗨,我有两个收集区和餐厅 我将从每个区域获取距离,并根据此距离从餐厅集合中获取餐厅列表 db.area.aggregate([ { $lookup: { from: 'restaurant', let: { distance: "$distance" }, pipeline: [ { "$geoNear": {
db.area.aggregate([
{
$lookup:
{
from: 'restaurant',
let: { distance: "$distance" },
pipeline: [
{
"$geoNear": {
"spherical": true,
"maxDistance": "$$distance",
"near": {
"type": "Point",
"coordinates": [
77.61546419999999,
12.9131813
]
},
"distanceField": "data.distance",
"distanceMultiplier": 0.001,
"query":{}
}
},
},
],
as: 'records'
}
}
])
但这不起作用,我是如何得到这种情况的
此区域收集数据
[
{
"_id" : ObjectId("609b95d90cc373430554d29d"),
"data" : {
"storeid" : ObjectId("60903de5cd97cb204f61f202"),
},
distance:5000
"geopoint" : {
"coordinates" : [
77.5717752,
12.812942
],
"type" : "Point"
},
}],
这是餐厅的数据
{"active":true,"name":"test restaurant","geopoint":{"coordinates":[77.6325948,12.9109546],"type":"Point"}}
当我像这样通过时$$distance MongoDB给定错误最大距离必须是一个数字请提供数据集的某些部分。请在问题中提供它、来自该地区的文档和餐厅收藏。