Skip to content

Commit 13a2ba5

Browse files
author
Richard Kreuter
committed
Backport 27e684c to 1.4.x. SERVER-1283, SUPPORT-50.
1 parent f793409 commit 13a2ba5

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

db/index_geo2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ namespace mongo {
988988
min.checkCur( found , hopper );
989989
max = min;
990990

991-
if ( min.bucket.isNull() ){
991+
if ( min.bucket.isNull() || ( ! (hopper->found()) )){
992992
min.bucket = id.head.btree()->locate( id , id.head , start.wrap() ,
993993
spec->_order , min.pos , min.found , minDiskLoc , -1 );
994994
min.checkCur( found , hopper );

jstests/geoe.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Was reported as SERVER-1283.
2+
// The problem seems to be that sometimes the index btrees are such that
3+
// the first search for a matching point in the geo code could run to
4+
// the end of the btree and not reverse direction (leaving the rest of
5+
// the search always looking at some random non-matching point).
6+
7+
t=db.geo_box;
8+
t.drop();
9+
10+
t.insert({"_id": 1, "geo" : [ 33, -11.1 ] });
11+
t.insert({"_id": 2, "geo" : [ -122, 33.3 ] });
12+
t.insert({"_id": 3, "geo" : [ -122, 33.4 ] });
13+
t.insert({"_id": 4, "geo" : [ -122.28, 37.67 ] });
14+
t.insert({"_id": 5, "geo" : [ -122.29, 37.68 ] });
15+
t.insert({"_id": 6, "geo" : [ -122.29, 37.67 ] });
16+
t.insert({"_id": 7, "geo" : [ -122.29, 37.67 ] });
17+
t.insert({"_id": 8, "geo" : [ -122.29, 37.68 ] });
18+
t.insert({"_id": 9, "geo" : [ -122.29, 37.68 ] });
19+
t.insert({"_id": 10, "geo" : [ -122.3, 37.67 ] });
20+
t.insert({"_id": 11, "geo" : [ -122.31, 37.67 ] });
21+
t.insert({"_id": 12, "geo" : [ -122.3, 37.66 ] });
22+
t.insert({"_id": 13, "geo" : [ -122.2435, 37.637072 ] });
23+
t.insert({"_id": 14, "geo" : [ -122.289505, 37.695774 ] });
24+
25+
26+
t.ensureIndex({ geo : "2d" });
27+
28+
c=t.find({geo: {"$within": {"$box": [[-125.078461,36.494473], [-120.320648,38.905199]]} } });
29+
assert.eq(11, c.count(), "A1");
30+
31+
c=t.find({geo: {"$within": {"$box": [[-124.078461,36.494473], [-120.320648,38.905199]]} } });
32+
assert.eq(11, c.count(), "B1");

0 commit comments

Comments
 (0)