0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

sparse geo index

This commit is contained in:
Eliot Horowitz 2010-02-28 22:19:04 -05:00
parent 0c9f391212
commit 346a47331c
2 changed files with 15 additions and 0 deletions

View File

@ -248,6 +248,8 @@ namespace mongo {
BSONObjBuilder b(64); BSONObjBuilder b(64);
BSONElement geo = obj[_geo]; BSONElement geo = obj[_geo];
if ( geo.eoo() )
return;
uassert( 13025 , (string)"geo field[" + _geo + "] has to be an Object or Array" , geo.isABSONObj() ); uassert( 13025 , (string)"geo field[" + _geo + "] has to be an Object or Array" , geo.isABSONObj() );
b.append( "" , _hash( geo.embeddedObject() ) ); b.append( "" , _hash( geo.embeddedObject() ) );

13
jstests/geo6.js Normal file
View File

@ -0,0 +1,13 @@
t = db.geo6;
t.drop();
t.ensureIndex( { loc : "2d" } );
t.insert( { _id : 1 , loc : [ 1 , 1 ] } )
t.insert( { _id : 2 , loc : [ 1 , 2 ] } )
t.insert( { _id : 3 } )
assert.eq( 3 , t.find().itcount() , "A1" )
assert.eq( 2 , t.find().hint( { loc : "2d" } ).itcount() , "A2" )
assert.eq( 2 , t.find( { loc : { $near : [50,50] } } ).itcount() , "A3" )