I'm so shamed, but I don't know how to do this.

Unless you mean something like this: ((Map.Entry<String, DBObject>)cmd.toMap().entrySet().iterator().next()).getKey()

In FongoTest.java (line 313) I'm using DB.command method to generate db.runCommand request to DB.
It passes DBObject: {"db" => { "text" : { "search" : "aaa -eee"}}}
where "db" is a collection name the request should be proceed to.

Sorry if I didn't get the point.