I am trying to write an aggregation query using $lookup. This is the whole pipeline.
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'
}
}
])
I am getting an error maxDistance should be a Number. Any leads on how to resolve this?