mongodb gmongo runCommand

379 Views Asked by At

I'm working on a grails/mongodb project. I want to do a full text research on a mongodb database using:

db.test.runCommand( "text", { search : "my_texte" } )

The problem is that I didn't found how to do it in groovy (or using gmongo).

How do execute a "runCommand" from groovy ?

Thanks.

2

There are 2 best solutions below

4
On

Since this is just a wrapper around the Java driver so most of the documentation is there.

Just translate into the "Groovy" form:

db.command( "text", [ search: "mytexte" ] )
1
On

I have found the Java version which works:

DBObject searchCmd = new BasicDBObject();
searchCmd.put("text", "test"); 
searchCmd.put("search", "mytexte"); 
CommandResult res = db.command( searchCmd )