MongoDB
 sql >> Base de Dados >  >> NoSQL >> MongoDB

Executando a consulta Mongo db.collection.runCommand(text,{search:search text})

_collection.Insert(new BsonDocument("x", "The quick brown fox"));  

var textSearchCommand = new CommandDocument
{
  { "text", _collection.Name },
  { "search", "fox" }
};
var commandResult = _database.RunCommand(textSearchCommand);
var response = commandResult.Response;

Assert.AreEqual(1, response["stats"]["nfound"].ToInt32());
Assert.AreEqual("The quick brown fox", response["results"][0]["obj"]["x"].AsString);

Fonte:Mongo