Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11832

Misplaced $maxDistance can work in v2.4, not in v2.5

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Geo, Querying
    • Environment:
    • Major Change
    • ALL
    • Hide

      2.5.5-pre-

      > db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
      error: {
      	"$err" : "can't parse query (2dsphere): { $nearSphere: { $geometry: { type: \"Point\", coordinates: [ 20.0, 20.0 ] } }, $maxDistance: inf.0 }",
      	"code" : 16535
      }
      > db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
      error: {
      	"$err" : "can't parse query (2dsphere): { $near: { $geometry: { type: \"Point\", coordinates: [ 20.0, 20.0 ] } }, $maxDistance: inf.0 }",
      	"code" : 16535
      }
      > db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
      { "_id" : ObjectId("528fa99e6ce2fec2710a135a"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      { "_id" : ObjectId("528fa9b06ce2fec2710a135b"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
      > db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
      { "_id" : ObjectId("528fa99e6ce2fec2710a135a"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      { "_id" : ObjectId("528fa9b06ce2fec2710a135b"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
      

      2.4.9-pre-

      > db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
      { "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      { "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
      > db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]}},$maxDistance:10e100000}})
      { "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      { "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
      > db.c.find({loc:{$nearSphere:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
      { "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      { "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
      > db.c.find({loc:{$near:{$geometry:{type:"Point", coordinates:[20,20]},$maxDistance:10e100000}}})
      { "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      { "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
      
      Show
      2.5.5-pre- > db.c.find({loc:{$nearSphere:{$geometry:{type: "Point" , coordinates:[20,20]}},$maxDistance:10e100000}}) error: { "$err" : "can't parse query (2dsphere): { $nearSphere: { $geometry: { type: \" Point\ ", coordinates: [ 20.0, 20.0 ] } }, $maxDistance: inf.0 }" , "code" : 16535 } > db.c.find({loc:{$near:{$geometry:{type: "Point" , coordinates:[20,20]}},$maxDistance:10e100000}}) error: { "$err" : "can't parse query (2dsphere): { $near: { $geometry: { type: \" Point\ ", coordinates: [ 20.0, 20.0 ] } }, $maxDistance: inf.0 }" , "code" : 16535 } > db.c.find({loc:{$nearSphere:{$geometry:{type: "Point" , coordinates:[20,20]},$maxDistance:10e100000}}}) { "_id" : ObjectId( "528fa99e6ce2fec2710a135a" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } { "_id" : ObjectId( "528fa9b06ce2fec2710a135b" ), "loc" : { "type" : "Point" , "coordinates" : [ -1, 0 ] } } > db.c.find({loc:{$near:{$geometry:{type: "Point" , coordinates:[20,20]},$maxDistance:10e100000}}}) { "_id" : ObjectId( "528fa99e6ce2fec2710a135a" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } { "_id" : ObjectId( "528fa9b06ce2fec2710a135b" ), "loc" : { "type" : "Point" , "coordinates" : [ -1, 0 ] } } 2.4.9-pre- > db.c.find({loc:{$nearSphere:{$geometry:{type: "Point" , coordinates:[20,20]}},$maxDistance:10e100000}}) { "_id" : ObjectId( "528fa99e5142cd7d1e23d1ba" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } { "_id" : ObjectId( "528fa9b05142cd7d1e23d1bb" ), "loc" : { "type" : "Point" , "coordinates" : [ -1, 0 ] } } > db.c.find({loc:{$near:{$geometry:{type: "Point" , coordinates:[20,20]}},$maxDistance:10e100000}}) { "_id" : ObjectId( "528fa99e5142cd7d1e23d1ba" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } { "_id" : ObjectId( "528fa9b05142cd7d1e23d1bb" ), "loc" : { "type" : "Point" , "coordinates" : [ -1, 0 ] } } > db.c.find({loc:{$nearSphere:{$geometry:{type: "Point" , coordinates:[20,20]},$maxDistance:10e100000}}}) { "_id" : ObjectId( "528fa99e5142cd7d1e23d1ba" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } { "_id" : ObjectId( "528fa9b05142cd7d1e23d1bb" ), "loc" : { "type" : "Point" , "coordinates" : [ -1, 0 ] } } > db.c.find({loc:{$near:{$geometry:{type: "Point" , coordinates:[20,20]},$maxDistance:10e100000}}}) { "_id" : ObjectId( "528fa99e5142cd7d1e23d1ba" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } { "_id" : ObjectId( "528fa9b05142cd7d1e23d1bb" ), "loc" : { "type" : "Point" , "coordinates" : [ -1, 0 ] } }

      $near and $geoNear will still work and return documents even if the syntax for $maxDistance is incorrect (i.e., placed outside the $geometry operator's document) in version 2.4 of MongoDB. Version 2.5 throws an error instead.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            luke.lovett Luke Lovett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: