Hi Martin,
On Tue, Jun 4, 2013 at 4:25 PM, Martin Angers <
martin....@gmail.com> wrote:
> Is there a way to use the [full text search feature][1] of Mongo 2.4? The
> `text` command must be run on a specific Collection, which doesn't seem
> possible with the current mgo API (Run() is only at the DB and Session
> level, if I've looked at up-to-date doc). Is there a workaround in the
> meantime?
I was waiting for the text feature to stabilize, but we'll certainly
have nice high-level wrappers to use the feature.
That said, any command you run in the shell can also be run with mgo, today.
Note how the db.collection.runCommand is implemented:
> db.test.runCommand
function ( cmd , params ){
if ( typeof( cmd ) == "object" )
return this._db._dbCommand( cmd );
var c = {};
c[cmd] = this.getName();
if ( params )
Object.extend( c , params );
return this._db._dbCommand( c );
}
Let's run some of this logic:
> var cmd = "text";
> var params = {key: "value"};
> var c = {};
> c[cmd] = db.test.getName();
> Object.extend(c, params);
{ "text" : "test", "key" : "value" }
That document is the actual command that gets sent to the database,
and you can provide that to the db.Run method in mgo as well.
It might make sense to provide a convenience run helper in Collection too.
gustavo @
http://niemeyer.net