Reputation: 11
Just some clarification with my implementation in mongodb aggregation. I'm having an issue with my implementation. "$geoNear is only valid as the first stage in an optimized pipeline"
const coordinatesQuery = [
...findQuery,
{
$match: {
addressSuburb: { $in: [...suburbList, ...nearbySuburbList] },
},
},
{
$geoNear: {
near: {
type: "Point",
coordinates: [centerPointOfSearchedSuburbs[0], centerPointOfSearchedSuburbs[1]]
},
$maxDistance: 8000,
distanceField: "distance",
}
},
{
$project: {
...formattedProjection
}
},
{
$sort: sort
},
{
$limit: take
},
{
$skip: skip
}
];
This is what currently have implemented but same issue appear
{
$geoNear: {
near: {
type: "Point",
coordinates: [centerPointOfSearchedSuburbs[0], centerPointOfSearchedSuburbs[1]]
},
$maxDistance: 8000,
distanceField: "distance",
}
},
Upvotes: 1
Views: 39