[SERVER-795] Geo with query doesn't return results if results are far away and limit isn't high Created: 19/Mar/10  Updated: 12/Jul/16  Resolved: 22/Mar/10

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 1.3.5

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

> db.people.find({ loc:{$near:{y:40.74,x:74}}, city:'NEWARK'}).count()
0
> db.people.find({ loc:{$near:{y:40.74,x:74}}, city:'NEWARK'}).limit(368).toArray().length
0
> db.people.find({ loc:{$near:{y:40.74,x:74}}, city:'NEWARK'}).limit(369).count()
0

the $near location is in Manhattan



 Comments   
Comment by Eliot Horowitz (Inactive) [ 26/Apr/10 ]

in a release

Comment by auto [ 22/Mar/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: test for SERVER-795
http://github.com/mongodb/mongo/commit/d74909dfc0a78fec4f650f692cd7665f2d46a3a5

Comment by auto [ 22/Mar/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: fix geo with limit with sparse results SERVER-795
http://github.com/mongodb/mongo/commit/6a27f13e5d26745b335408b200a5813819a418ec

Comment by Mathias Stearn [ 19/Mar/10 ]

test case:

> db.temp.drop()
true
> for (var i=0; i<100000; i++) db.temp.insert(

{loc:[100+Math.random(), 100+Math.random()], z:0}

)
> for (var i=0; i<100000; i++) db.temp.insert(

{loc:[0+Math.random(), 0+Math.random()], z:1}

)
> for (var i=0; i<100000; i++) db.temp.insert(

{loc:[-100+Math.random(), -100+Math.random()], z:2}

)
> db.temp.ensureIndex(

{loc:'2d'}

)
> db.temp.find({loc:{$near:[100,100]}, z:0}).limit(1) // looking at the right place

{ "_id" : ObjectId("4ba420f8aea776eb0349f5fb"), "loc" : [ 100.00044369581227, 100.00137553042174 ], "z" : 0 }

> db.temp.find({loc:{$near:[100,100]}, z:1}).limit(1) // looking for value near 0,0
> db.temp.find({loc:{$near:[100,100]}, z:1}).limit(2)

{ "_id" : ObjectId("4ba42135aea776eb034b7d67"), "loc" : [ 0.9986111981839165, 0.9982225271724401 ], "z" : 1 } { "_id" : ObjectId("4ba42135aea776eb034b5ef0"), "loc" : [ 0.9983649024881919, 0.9975999943082721 ], "z" : 1 }

> db.temp.find({loc:{$near:[100,100]}, z:2}).limit(2) // looking for value near -100,-100
> db.temp.find({loc:{$near:[100,100]}, z:2}).limit(10)
> db.temp.find({loc:{$near:[100,100]}, z:2}).limit(1000)
> db.temp.find({loc:{$near:[100,100]}, z:2}).limit(100000)
> db.temp.find({loc:{$near:[100,100]}, z:2}).limit(10000000)

{ "_id" : ObjectId("4ba42152aea776eb034ce325"), "loc" : [ -99.0044038143625, -99.00276528062463 ], "z" : 2 } { "_id" : ObjectId("4ba42154aea776eb034d5079"), "loc" : [ -99.00004697901932, -99.00724764759275 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c65a1"), "loc" : [ -99.00340094000919, -99.00442751786046 ], "z" : 2 } { "_id" : ObjectId("4ba42151aea776eb034c8ff4"), "loc" : [ -99.00303390340963, -99.00616623000317 ], "z" : 2 } { "_id" : ObjectId("4ba42152aea776eb034cbd89"), "loc" : [ -99.00113233644916, -99.00997758210232 ], "z" : 2 } { "_id" : ObjectId("4ba42154aea776eb034d5a7b"), "loc" : [ -99.00261081620683, -99.00860889548798 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c51b5"), "loc" : [ -99.01030136617017, -99.0023052758157 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c61e0"), "loc" : [ -99.00845150698072, -99.00502577423593 ], "z" : 2 } { "_id" : ObjectId("4ba42152aea776eb034ceb91"), "loc" : [ -99.00918556748063, -99.00493494389337 ], "z" : 2 } { "_id" : ObjectId("4ba42154aea776eb034d7ee2"), "loc" : [ -99.01044391158419, -99.00402419982002 ], "z" : 2 } { "_id" : ObjectId("4ba42154aea776eb034d705a"), "loc" : [ -99.01420555480644, -99.00057518513223 ], "z" : 2 } { "_id" : ObjectId("4ba42151aea776eb034c7d3a"), "loc" : [ -99.01540024864526, -99.00039293544691 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c339c"), "loc" : [ -99.00931192985665, -99.00830653526737 ], "z" : 2 } { "_id" : ObjectId("4ba42152aea776eb034cbb66"), "loc" : [ -99.0116846961002, -99.00649041663408 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c64a8"), "loc" : [ -99.00204798277124, -99.01636040573327 ], "z" : 2 } { "_id" : ObjectId("4ba4214faea776eb034c1e76"), "loc" : [ -99.01523053704679, -99.0041634893516 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c63b9"), "loc" : [ -99.01827296215806, -99.0012895288803 ], "z" : 2 } { "_id" : ObjectId("4ba42150aea776eb034c6a26"), "loc" : [ -99.01765181245926, -99.00237173076631 ], "z" : 2 } { "_id" : ObjectId("4ba42151aea776eb034cb329"), "loc" : [ -99.01121099488644, -99.00895698787542 ], "z" : 2 } { "_id" : ObjectId("4ba42153aea776eb034d2ad7"), "loc" : [ -99.01258166523415, -99.00805880968434 ], "z" : 2 }

has more
>

Generated at Thu Feb 08 02:55:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.