lookup with pipeline and geoIntersects that use let variable
Unfortunately coordinates can't be populated from document field.
Geospatial are query expressions and $let
variables are only permitted to use in $match
with $expr
variant for aggregation expressions in $lookup
pipeline.
You have to perform the query in two steps.
First step to get the coordinates for matching record.
var result = db.posts.findOne({ _id: ObjectId('5a562e62100338001218dffa')},{ _id: 0, 'location':1});
Second step to look for point in the polygon.
db.neighborhoods.find( { "boundries": { $geoIntersects: { $geometry: { type: "Point" , coordinates: result.location.coordinates.coordinates } } } })