mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
geo2d command -> geoNear
This commit is contained in:
parent
a347ce9b85
commit
da23ec8f56
@ -859,7 +859,7 @@ namespace mongo {
|
||||
|
||||
class Geo2dFindNearCmd : public Command {
|
||||
public:
|
||||
Geo2dFindNearCmd() : Command( "geo2d" ){}
|
||||
Geo2dFindNearCmd() : Command( "geoNear" ){}
|
||||
virtual LockType locktype(){ return READ; }
|
||||
bool slaveOk() { return true; }
|
||||
bool slaveOverrideOk() { return true; }
|
||||
|
@ -11,8 +11,8 @@ for ( var x=-100; x<100; x+=2 ){
|
||||
|
||||
t.ensureIndex( { loc : "2d" } )
|
||||
|
||||
fast = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 } );
|
||||
slow = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 , start : "11" } );
|
||||
fast = db.runCommand( { geoNear : t.getName() , near : [ 50 , 50 ] , num : 10 } );
|
||||
slow = db.runCommand( { geoNear : t.getName() , near : [ 50 , 50 ] , num : 10 , start : "11" } );
|
||||
|
||||
printjson(fast.stats);
|
||||
printjson(slow.stats);
|
||||
|
@ -12,11 +12,11 @@ for ( var x=-100; x<100; x+=2 ){
|
||||
|
||||
t.ensureIndex( { loc : "2d" } )
|
||||
|
||||
fast = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 } );
|
||||
fast = db.runCommand( { geoNear : t.getName() , near : [ 50 , 50 ] , num : 10 } );
|
||||
|
||||
//printjson( fast.stats );
|
||||
|
||||
slow = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 , start : "11" } );
|
||||
slow = db.runCommand( { geoNear : t.getName() , near : [ 50 , 50 ] , num : 10 , start : "11" } );
|
||||
|
||||
//printjson( slow.stats );
|
||||
|
||||
@ -26,7 +26,7 @@ assert.eq( fast.stats.avgDistance , slow.stats.avgDistance , "A3" );
|
||||
|
||||
// test filter
|
||||
|
||||
filtered1 = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 , query : { a : 2 } } );
|
||||
filtered1 = db.runCommand( { geoNear : t.getName() , near : [ 50 , 50 ] , num : 10 , query : { a : 2 } } );
|
||||
assert.eq( 10 , filtered1.results.length , "B1" );
|
||||
filtered1.results.forEach( function(z){ assert.eq( 2 , z.obj.a , "B2: " + tojson( z ) ); } )
|
||||
//printjson( filtered1.stats );
|
||||
@ -34,7 +34,7 @@ filtered1.results.forEach( function(z){ assert.eq( 2 , z.obj.a , "B2: " + tojson
|
||||
t.dropIndex( { loc : "2d" } )
|
||||
t.ensureIndex( { loc : "2d" , a : 1 } )
|
||||
|
||||
filtered2 = db.runCommand( { geo2d : t.getName() , near : [ 50 , 50 ] , num : 10 , query : { a : 2 } } );
|
||||
filtered2 = db.runCommand( { geoNear : t.getName() , near : [ 50 , 50 ] , num : 10 , query : { a : 2 } } );
|
||||
assert.eq( 10 , filtered2.results.length , "B3" );
|
||||
filtered2.results.forEach( function(z){ assert.eq( 2 , z.obj.a , "B4: " + tojson( z ) ); } )
|
||||
//printjson( filtered2.stats );
|
||||
|
@ -4,15 +4,15 @@ t.drop();
|
||||
t.insert( { p : [ 0,0 ] } )
|
||||
t.ensureIndex( { p : "2d" } )
|
||||
|
||||
res = t.runCommand( "geo2d" , { near : [1,1] } );
|
||||
res = t.runCommand( "geoNear" , { near : [1,1] } );
|
||||
assert.eq( 1 , res.results.length , "A1" );
|
||||
|
||||
t.insert( { p : [ 1,1 ] } )
|
||||
t.insert( { p : [ -1,-1 ] } )
|
||||
res = t.runCommand( "geo2d" , { near : [50,50] } );
|
||||
res = t.runCommand( "geoNear" , { near : [50,50] } );
|
||||
assert.eq( 3 , res.results.length , "A2" );
|
||||
|
||||
t.insert( { p : [ -1,-1 ] } )
|
||||
res = t.runCommand( "geo2d" , { near : [50,50] } );
|
||||
res = t.runCommand( "geoNear" , { near : [50,50] } );
|
||||
assert.eq( 4 , res.results.length , "A3" );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user