-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.4.3
-
Component/s: None
-
None
-
Query
-
ALL
Hello,
I'm trying to get nearest points from joined collection like this:
db.collectionA.aggregate( [ { $geoNear: { near: { "type": "Point", "coordinates": [-4.4657183, 48.38249] }, distanceField: "calcDistance", maxDistance: 10, key: "geometry", includeLocs: "dist.geometry", spherical: "true" } }, {$limit: 100}, { $lookup: { from: "collectionB", let: { plon: {"$arrayElemAt":["$geometry.coordinates",0]}, plat: {"$arrayElemAt":["$geometry.coordinates",1]}, }, pipeline: [ { $geoNear:{ "near": {type: "Point", coordinates: ["$$plon","$$plat"], }, key: "geometry", maxDistance: 10000, distanceField: "dist.calculated", spherical: "true" } }, ], as: 'joinedGeometry' } } ] )
So i need for every point in collectionA to find nearest points in the collectionB.
On the specified aggregation im recieving the following error:
geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 10000.0
I tried to remove that field and the following message:
invalid argument in geo near query: type
I also tried to specify in the let section the numbers like this:
let: { plon: -3.4032917, plat: 46.91752, }
But with the same results
Thanks
- duplicates
-
SERVER-34766 Allow $expr or $$field in the $geoNear stage
- Closed