I'm trying to get the distance between two points on a 2dsphere from MongoDB using Go.
I followed this answer and tried this
conditions["geolocation"] = bson.M{
"$geoNear": bson.M{
"near": bson.M{
"type": "Point",
"coordinates": []float64{latitude, longitude},
},
"maxDistance": rangeInMeters,
"spherical": true,
"distanceField": "distance",
},
}
filterCursor, err := collection.Find(ctx, conditions)
But I get this error : "Invalid arguement in geo near query:near"