[SERVER-3736] objects with array of locations returned multiple times in geo search Created: 31/Aug/11  Updated: 02/Sep/11  Resolved: 01/Sep/11

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

> db.foo.drop()
true
> for (var i=0; i<100; i+) for (var j=0; j<100; j+) db.foo.insert({locs:{loc:[[i+Math.random(), j+Math.random()],[i+Math.random(), j+Math.random()],[i+Math.random(), j+Math.random()],[i+Math.random(), j+Math.random()],[i+Math.random(), j+Math.random()],]}})
> db.foo.ensureIndex(

{'locs.loc':'2d'}

)
> db.foo.find({'locs.loc': {$near: [50,50]}}, {_id:1}).limit(10)

{ "_id" : ObjectId("4e5e9db248cf912e7af1a478") } { "_id" : ObjectId("4e5e9db248cf912e7af1a414") } { "_id" : ObjectId("4e5e9db248cf912e7af1a414") } { "_id" : ObjectId("4e5e9db248cf912e7af1a478") } { "_id" : ObjectId("4e5e9db248cf912e7af1a414") } { "_id" : ObjectId("4e5e9db248cf912e7af1a415") } { "_id" : ObjectId("4e5e9db248cf912e7af1a479") } { "_id" : ObjectId("4e5e9db248cf912e7af1a478") } { "_id" : ObjectId("4e5e9db248cf912e7af1a479") } { "_id" : ObjectId("4e5e9db248cf912e7af1a415") }

Note that we do dedupe on normal indexes:
> db.bar.insert(

{a:[1,2,3,4]}

)
> db.bar.insert(

{a:[1,2,3,4]}

)
> db.bar.find({a:{$in:[1,2,3,4]}})

{ "_id" : ObjectId("4e5e9ee648cf912e7af1b7d0"), "a" : [ 1, 2, 3, 4 ] } { "_id" : ObjectId("4e5e9ee848cf912e7af1b7d1"), "a" : [ 1, 2, 3, 4 ] }

 Comments   
Comment by Mathias Stearn [ 01/Sep/11 ]

Given that arrays of locations don't work correctly yet we should probably add the assert to disallow them back in.

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