[SERVER-9599] geoNear uniqueDocs not working as documented Created: 06/May/13  Updated: 15/Nov/21  Resolved: 02/Mar/14

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.3.2, 2.4.0, 2.4.1, 2.4.2, 2.4.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ygor Lemos Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: commands, geoNear, uniqueDocs
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoHQ Large running MongoDB 2.4.3


Issue Links:
Duplicate
duplicates SERVER-12120 geo $near deduping is not working Closed
Operating System: ALL
Steps To Reproduce:

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)

Participants:

 Description   

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?).



 Comments   
Comment by Daniel Pasette (Inactive) [ 02/Mar/14 ]

i believe this is a duplicate of SERVER-12120.

Generated at Thu Feb 08 03:20:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.