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

geo queries are order dependent when using $maxDistance

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Duplicate
    • None
    • None
    • Geo
    • None
    • ALL

    Description

      Test case:

      use geo
      db.zips.drop();
      db.zips.insert({ "city": "KELLYTON", "zip": "35089", "loc": { "y": 32.979068, "x": 86.048397 }, "pop": 1584, "state": "AL" });
      db.zips.insert({ "city": "NEW SITE", "zip": "35010", "loc": { "y": 32.941445, "x": 85.951086 }, "pop": 19942, "state": "AL" });
      db.zips.insert({ "city": "GOODWATER", "zip": "35072", "loc": { "y": 33.074642, "x": 86.078149 }, "pop": 3813, "state": "AL" });
      db.zips.insert({ "city": "MILLERVILLE", "zip": "36267", "loc": { "y": 33.158959, "x": 85.969001 }, "pop": 863, "state": "AL" });
      db.zips.insert({ "city": "JACKSONS GAP", "zip": "36861", "loc": { "y": 32.879698, "x": 85.848662 }, "pop": 2236, "state": "AL" });
      db.zips.ensureIndex({loc: '2d'});
       
      db.zips.find({loc : {$nearSphere : [33.0, 86.0], $maxDistance : 0.1}}).count()  // returns 2 record
       
       
      db.zips.find({loc : {$maxDistance : 0.1, $near: [33.0, 86.0]}}).count()
      error: {
          "$err" : "geo values have to be numbers :: caused by :: { 0: 0.1, 1: [ 33.0, 86.0 ] }",
          "code" : 13026
      }

      Some languages (python) don't have control over the order of items in dictionaries. There is a SON type but forcing the user to use this seems the wrong place to fix it.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ross@mongodb.com Ross Lawley
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: