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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Geo, Querying
    • Environment:
    • Backwards Compatibility:
      Major Change
    • Operating System:
      ALL
    • Steps To Reproduce:
      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 ] } }

      Description

      $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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: