Reputation: 439
I have the collection structure like:
{
name: "abcd",
location: {
type: "MultiPoint",
coordinates: [
[-73.57131,45.49758],[-73.57055,45.4984],[-73.57022,-73.57022],[-73.56968,45.49932],[-73.56896,45.50007],[-73.56807,45.50103],[-73.56722,45.50171]
]
}
}
I created index using
db.testCollection.createIndex( { coordinates: "2dsphere" })
Now I want to find nearby points from (lets say) [-73.56967,45.49933] out of the list location.coordinates thats present in my document.
So I queried
db.testCollection.find({ location:{ $near:{ $geometery:{ type:"Point", coordinates:[-73.56967,45.49933] }, $minDistance:0,$maxDistance:250}}})
but i got error:
Error: error: {
"$err" : "Can't canonicalize query: BadValue $geometry is required for geo near query",
"code" : 17287
}
CAN SOMEONE HELP ME OUT PLEASE!
Upvotes: 0
Views: 879
Reputation: 971
index name is incorrect
db.testCollection.createIndex( { location: "2dsphere" })
as @mrp answer there is an spell mistake. Use $geometry instead of $geometery.
Upvotes: 0
Reputation: 51
There is a spelling mistake.
Use $geometry
instead of $geometery.
Try the following query
db.testCollection.find(
{ location:{ $near:{ $geometry:{ type:"Point", coordinates:[-73.56967,45.49933] },
$minDistance:0,$maxDistance:250}}
})
Upvotes: 1