Setup:
> t = db.t
> t.drop()
> t.ensureIndex({locs: "2d"})
> t.save({locs: [[49.999,49.999], [50.0,50.0], [50.001,50.001]]})
The js file attached can be used for an easy repro.
Case 1 (find):
The following $near query should return the document just once, but instead it returns the same document three times (de-duplication has failed):
> t.find({locs: {$near: [50.0, 50.0]}}) { "locs" : [ [ 49.999, 49.999 ], [ 50, 50 ], [ 50.001, 50.001 ] ], "_id" : ObjectId("52af410a39870765bef3419b") } { "locs" : [ [ 49.999, 49.999 ], [ 50, 50 ], [ 50.001, 50.001 ] ], "_id" : ObjectId("52af410a39870765bef3419b") } { "locs" : [ [ 49.999, 49.999 ], [ 50, 50 ], [ 50.001, 50.001 ] ], "_id" : ObjectId("52af410a39870765bef3419b") }
Case 2 (update):
Geo $near de-duplication also seems to be causing some update()-related issues. The following multiupdate fails entirely:
t.update({locs: {$near: [50.0, 50.0]}}, {$inc: {touchCount: 1}}, false, true) Update WriteResult({ "ok" : 0, "code" : 1, "errmsg" : " Update query failed -- RUNNER_ERROR", "n" : 0 })
The expected result is that the update() succeeds and that touchCount is set to a value of 1.
- is duplicated by
-
SERVER-9599 geoNear uniqueDocs not working as documented
- Closed
-
SERVER-5235 $uniqueDocs for near queries
- Closed
- is related to
-
SERVER-12068 Exception generated from update for 2d index, $near update
- Closed
- related to
-
SERVER-11379 require field name in geoNear, remove uniqueDocs
- Closed