Reputation: 4560
I'm having a very strange problem with MongoDB Geospatial indexes:
> db.events.find({'geo': {'$maxDistance': 5, '$near': [45.21012750000001, 7.1364645]}})
error: {
"$err" : "geo values have to be numbers: { $maxDistance: 5.0, $near: [ 45.21012750000001, 7.1364645 ] }",
"code" : 13026
}
The weirdest thing is that the same query written in different order works perfectly:
> db.events.find({'geo': {'$near': [45.21012750000001, 7.1364645], '$maxDistance': 5}})
Shouldn't both queries hold the same result?
Upvotes: 1
Views: 336
Reputation: 42352
The two queries are not treated the same - as you saw, order matters.
There is a request to make the two identical in https://jira.mongodb.org/browse/SERVER-1990 but it's not currently targeted for a specific release.
Feel free to vote on the issue and/or watch it.
Upvotes: 2