我需要在我的网站中添加全文搜索选项,在 mongodb 中添加数据库,
蒙戈查询:
db.collection.runCommand("text",{"search":"search text"})
给出了结果,但是如何使用C#执行它?
_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);
Source: Mongo https://github.com/mongodb/mongo-csharp-driver/blob/master/MongoDB.DriverUnitTests/MongoCollectionTests.cs#L1606
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)