[SERVER-12120] geo $near deduping is not working Created: 16/Dec/13  Updated: 11/Jul/16  Resolved: 29/Jan/14

Status: Closed
Project: Core Server
Component/s: Querying, Write Ops
Affects Version/s: 2.5.4
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File geo_update_dedup.js     File update_geo_dedup.js    
Issue Links:
Duplicate
is duplicated by SERVER-9599 geoNear uniqueDocs not working as doc... Closed
is duplicated by SERVER-5235 $uniqueDocs for near queries Closed
Related
related to SERVER-11379 require field name in geoNear, remove... Closed
is related to SERVER-12068 Exception generated from update for 2... Closed
is related to DOCS-2647 uniqueDocs deprecated for geo commands Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 29/Jan/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-12120 fixed geo $near deduping. deprecated uniqueDocs option.
Branch: master
https://github.com/mongodb/mongo/commit/c944016bba355d29540129d8a37101f5441bc27a

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