Description
2dsphere $near queries return the unhelpful message "not handled: $near" on queries if extra fields are erroneously included in the geo predicate:
> db.poiConcat.ensureIndex({l: "2dsphere"}) |
WriteResult({ "nInserted" : 1 }) |
> db.poiConcat.insert({l: {type: 'Point', coordinates: [ -73.56, 45.49 ] }, ts: 'amenity=pub'}) |
WriteResult({ "nInserted" : 1 }) |
> db.poiConcat.find( { l: { '$near': { '$geometry': { type: 'Point', coordinates: [ -73.56, 45.48] } } }, 'ts': 'amenity=pub' } ).limit(1).pretty(); |
{
|
"_id" : ObjectId("530f897fe931f3ea33c3fca2"), |
"l" : { |
"type" : "Point", |
"coordinates" : [ |
-73.56,
|
45.49
|
]
|
},
|
"ts" : "amenity=pub" |
}
|
> db.poiConcat.find( { l: { '$near': { '$geometry': { type: 'Point', coordinates: [ -73.56, 45.48] } }, foo: 'bar' }, 'ts': 'amenity=pub' } ).limit(1).pretty(); |
error: {
|
"$err" : "Can't canonicalize query: BadValue not handled: $near", |
"code" : 17287 |
}
|
This error message needs to be improved, particularly because the below query form was a (undocumented but) valid way to specify $maxDistance for a $near query in 2.4. This form is being broken for 2.6, but users who use the invalid form need better diagnostics.
> db.poiConcat.find( { l: { '$near': { '$geometry': { type: 'Point', coordinates: [ -73.56, 45.48] } }, $maxDistance: 100 }, 'ts': 'amenity=pub' } ).limit(1).pretty(); |
error: {
|
"$err" : "Can't canonicalize query: BadValue not handled: $near", |
"code" : 17287 |
}
|
Original ticket description:
With 2.4.x (and I also believe 2.5.5), I could run the following query:
db.poiConcat.find( { l: { '$near': { '$geometry': { type: 'Point', coordinates: [ -73.56, 45.49 ] } }, '$maxDistance' : 2500 }, 'ts': 'amenity=pub' } ).limit(1).pretty();With 2.6.0rc0, this now returns:
error: {"$err" : "Can't canonicalize query: BadValue not handled: $near","code" : 17287}Steps to reproduce: No data or indexes have to be created. Just run this:
derick@whisky:~ $ install/mongodb-linux-x86_64-2.6.0-rc0/bin/mongo fooMongoDB shell version: 2.6.0-rc0connecting to: fooServer has startup warnings:2014-02-27T09:25:14.228-0500 ** WARNING: --rest is specified without --httpinterface,2014-02-27T09:25:14.228-0500 ** enabling http interface> db.poiConcat.find( { l: { '$near': { '$geometry': { type: 'Point', coordinates: [ -73.56, 45.49 ] } }, '$maxDistance' : 2500 }, 'ts': 'amenity=pub' } ).limit(1).pretty();error: {"$err" : "Can't canonicalize query: BadValue not handled: $near","code" : 17287}
Attachments
Issue Links
- is related to
-
SERVER-11832 Misplaced $maxDistance can work in v2.4, not in v2.5
-
- Closed
-