Permalink
Browse files

fix for geo with embedded loc SERVER-694

  • Loading branch information...
1 parent 2bdb76c commit 49edf4a645cc2c4df7840ca1cbe7f23b8d6848bf @erh erh committed Mar 3, 2010
Showing with 14 additions and 2 deletions.
  1. +2 −2 db/index_geo2d.cpp
  2. +12 −0 jstests/geoa.js
View
@@ -355,7 +355,7 @@ namespace mongo {
}
virtual void getKeys( const BSONObj &obj, BSONObjSetDefaultOrder &keys ) const {
- BSONElement geo = obj[_geo];
+ BSONElement geo = obj.getFieldDotted(_geo.c_str());
if ( geo.eoo() )
return;
@@ -452,7 +452,7 @@ namespace mongo {
virtual auto_ptr<Cursor> newCursor( const BSONObj& query , const BSONObj& order , int numWanted ) const;
virtual IndexSuitability suitability( const BSONObj& query , const BSONObj& order ) const {
- BSONElement e = query[_geo.c_str()];
+ BSONElement e = query.getFieldDotted(_geo.c_str());
switch ( e.type() ){
case Object: {
BSONObj sub = e.embeddedObject();
View
@@ -0,0 +1,12 @@
+
+t = db.geoa
+t.drop();
+
+t.save( { _id : 1 , a : { loc : [ 5 , 5 ] } } )
+t.save( { _id : 2 , a : { loc : [ 6 , 6 ] } } )
+t.save( { _id : 3 , a : { loc : [ 7 , 7 ] } } )
+
+t.ensureIndex( { "a.loc" : "2d" } );
+
+cur = t.find( { "a.loc" : { $near : [ 6 , 6 ] } } );
+assert.eq( 2 , cur.next()._id , "A1" );

0 comments on commit 49edf4a

Please sign in to comment.