【发布时间】:2016-08-25 12:05:24
【问题描述】:
我正在尝试通过将字符串数组与 MogoDB 文档中的特定字符串对象匹配来从 mongoDB 获取搜索结果。 我的示例 MongoDb 文档。
"Notedisp" : {
"NoteID" : NumberLong(100281),
"NoteTitle" : null,
"NoteContent" : "In mathematics, the Pythagorean theorem theorem, also known as Pythagoras's theorem, is a relation in Euclidean geometry among the three sides of a right triangle. It states that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the \"Pythagorean equation\"\r\n\r\na^2 + b^2 = c^2 ,\r\nwhere c represents the length of the hypotenuse and a and b the lengths of the triangle's other two sides.",
},
我已经尝试过以下代码。
var listTearm = ["what","is","Pythagorean","theorem"]
var filter = (builder.AnyIn("Notedisp.NoteContent", listTearm)
在上面的代码中,“Notedisp.NoteContent”是 MongoDB 文档中的一个字符串对象,它返回的是空字符串。那么有没有什么特定的方法可以让我将 String 匹配到 MogoDb 文档并返回特定的数据。
【问题讨论】: