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

geoNear uniqueDocs not working as documented

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.3.2, 2.4.0, 2.4.1, 2.4.2, 2.4.3
    • Component/s: Geo
    • Environment:
      MongoHQ Large running MongoDB 2.4.3
    • ALL
    • Hide

      1- Run the geoNear command against a collection with documents having multiple locations. The geoNear command should NOT have the uniqueDocs parameter specified.
      2 - It should've return only one doc per matched location even if multiple locations were matched.
      3 - It ACTUALLY returns one copy of the same document per location matched (the opposite of what is documented on geoNear command referring to the uniqueDocs parameter)

      Show
      1- Run the geoNear command against a collection with documents having multiple locations. The geoNear command should NOT have the uniqueDocs parameter specified. 2 - It should've return only one doc per matched location even if multiple locations were matched. 3 - It ACTUALLY returns one copy of the same document per location matched (the opposite of what is documented on geoNear command referring to the uniqueDocs parameter)

      when I run the geoNear command with the near parameter without specifying uniqueDocs, it should only return one document per matched location (assuming my documents have multiple locations indexed).

      Instead, even not specifying uniqueDocs, it is returning the documents multiple times (as locations are matched by geoNear). This should only happen if I had explicitly specified uniqueDocs: false which I haven't.

      See uniqueDocs ref: http://docs.mongodb.org/manual/reference/command/geoNear/

      Here is my query (using pymongo):

      resNear = db.command(SON([
                      ("geoNear","missions"),
                      ("near", [float(kwargs.get("lon")),float(kwargs.get("lat"))]),
                      ("includeLocs", True),
                      ("spherical", True),
                      ("maxDistance", 30000/6378137),
                      ("distanceMultiplier", 6378137),
                      ("query", {
                          "status": "published",
                          "budget": {"$gt": 0}
                      })
                  ]))
      

      my indexes for this particular collection (referring to the geo stuff are):

      { key:

      { "locations.location": "2d" }

      , v: 1, ns: "cashme.missions", name: "locations.location_2d" }

      so either the default for uniqueDocs was documented erratically on MongoDB oficial docs or there is a problem with uniqueDocs for geoNear (or am I missing something?).

            Assignee:
            Unassigned Unassigned
            Reporter:
            ygbr@mac.com Ygor Lemos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: