1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
// make sure we're enabled
db.adminCommand( { setParameter : "*", textSearchEnabled : true } );
if ( "isdbgrid" == db.runCommand( "ismaster" ).msg ) {
db.getSisterDB( "config" ).shards.find().forEach(
function(shard) {
var m = new Mongo( shard.host );
m.getDB( "admin" ).runCommand( { setParameter : "*", textSearchEnabled: true } );
}
);
}
function queryIDS( coll, search, filter, extra ){
var cmd = { search : search }
if ( filter )
cmd.filter = filter;
if ( extra )
Object.extend( cmd, extra );
lastCommadResult = coll.runCommand( "text" , cmd);
return getIDS( lastCommadResult );
}
function getIDS( commandResult ){
if ( ! ( commandResult && commandResult.results ) )
return []
return commandResult.results.map( function(z){ return z.obj._id; } )
}
|