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

Bounding box queries in embedded geo documents (Mongo v1.9) not working properly

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.9.0
    • Component/s: Geo
    • Environment:
      Platform independent
    • Linux

      Bounding box queries inside the embedded documents are giving inaccurate results. Sample document

      "_id" : ObjectId("4dff052e1d41c8588000000a"),
      "isused" : true,
      "isfixed" : true,
      "kind" : 0,
      "name" : "Used whirlpool refrigirator wanted",
      "desc" : "2 years used 200 litres Whirlpool refrigerator is for sale.",
      "price" : 5000,
      "locations" : [

      { "name" : "Samiyar Madam, Kodambakkam, Chennai, Tamil Nadu, India", "loc" : [ 80.22167450000006, 13.0454044 ], "is_exact" : true, "kind" : "neighborhood", "_id" : ObjectId("4dff052e1d41c8588000000b") }

      ,

      { "_id" : ObjectId("4dff052e1d41c8588000000c"), "kind" : "route", "name" : "Shiyamala Vadhana St, Samiyar Madam, Kodambakkam, Chennai, Tamil Nadu, India", "loc" : [ 80.2216906, 13.0452927 ] }

      ,

      { "_id" : ObjectId("4dff052e1d41c8588000000d"), "kind" : "sublocality", "name" : "Kodambakkam, Chennai, Tamil Nadu, India", "loc" : [ 80.223766, 13.049043 ] }

      ,
      }]
      }

      when issuing the $box query with this co-ordinates [[80.21758681346137, 13.04706625300893], [80.2238953690644, 13.052333939665253]], it should not pick the above item

      db.items.find({"locations.is_exact":true,"locations.loc" : {"$within" :

      {"$box" :[[80.21758681346137, 13.04706625300893], [80.2238953690644, 13.052333939665253]] }

      }})

      But this query picks the above item.

      So i created another document(not embedded) with the same data & location. like this

      "_id" : ObjectId("4dff052e1d41c8588000000a"),
      "isused" : true,
      "isfixed" : true,
      "kind" : 0,
      "name" : "Used whirlpool refrigirator wanted",
      "desc" : "2 years used 200 litres Whirlpool refrigerator is for sale.",
      "price" : 5000,
      "loc" : [
      80.22167450000006,
      13.0454044
      ]

      and used the same box query

      db.items.find({loc : {"$within" :

      {"$box" :[[80.21758681346137, 13.04706625300893], [80.2238953690644, 13.052333939665253]] }

      }})

      now it works fine. it doesn't pick up the item. So this problem only exists in v1.9 geo indexes in embedded documents

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            rameshvel ramesh vel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: