- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
所以根据 MongoDB 文档,
if a document field contains the word blueberry, a search on the term blue will not match the document
这对我的用例有好处,这是我想要发生的。但是,鉴于以下数据库条目:
> db.test.drop()
> db.test.insert({ "t" : "Men's Fashion" })
> db.test.insert({ "t" : "Women's Fashion" })
> db.test.ensureIndex({ "t" : "text" })
搜索 Men's 返回预期结果:
> db.test.find({ "$text" : { "$search" : "\"Men's\"" } }, { "_id" : 0 })
{ "t" : "Men's Fashion" }
但是搜索整个短语 Men's Fashion,居然还返回 Women's Fashion:
> db.test.find({ "$text" : { "$search" : "\"Men's Fashion\"" } }, { "_id" : 0 })
{ "t" : "Women's Fashion" }
{ "t" : "Men's Fashion" }
我也尝试过 "\"Men's\"\"Fashion\""
,结果相同。是否有解决方法/技巧让完整的短语只返回整个单词匹配?
我使用的是 Mongo 2.6.4。有趣的是,它的女性得分确实低于男性。
最佳答案
您看到的结果是因为 woMEN'S FASHION 与 MEN'S FASHION 匹配,因为搜索字符串 是 在要搜索的字符串中。
此数据集不会发生匹配行为:
/* 1 */
{
"_id" : ObjectId("55ca6060fb286267994d297e"),
"text" : "potato pancake"
}
/* 2 */
{
"_id" : ObjectId("55ca6075fb286267994d297f"),
"text" : "potato salad"
}
/* 3 */
{
"_id" : ObjectId("55ca612ffb286267994d2980"),
"text" : "potato's pancake"
}
用查询
db.getCollection('rudy_test').find({$text : {"$search" : "\"potato pancake\""}})
这是由于条目确实包含整个查询,分数较低是因为它还包含其他文本。您可以使用 Regular Expression Query (即 db.test.find({t : {$regex :/^Men\'s Fashion$/}})
)。
关于带有确切短语的MongoDB全词搜索未返回预期结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31659196/
通过多次搜索和pytorch文档本身,我可以发现在嵌入层内部有一个查找表,用于存储嵌入向量。我无法理解的是: 在这一层的培训期间究竟发生了什么? 权重是多少,以及这些权重的梯度是如何计算的? 我的直觉
当应用程序有大量数据(400M)要写入非阻塞套接字时,write() 返回EWOULDBLOCK 或EAGAIN 当发送缓冲区变满时。 当套接字被(e)轮询时,我有时会看到发送缓冲区中有 7M 空间(
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我经常阅读一些编程语言对模块的支持(“一流”)(OCaml,Scala,TypeScript [?]),并且最近偶然发现了这样的答案,即在Scala的显着特征中引用模块作为一流公民。 我以为我很清楚模
我已经提交了一个自定义的开放图表故事,但它被拒绝并显示以下消息: 打开图表捐赠(行动类型)提交内容、操作、对象和使用说明必须以英文提交。您可以在应用程序面板的“本地化”选项卡中翻译操作和对象。 如果我
给定一个任意的 boolean 值列表,确定其中一个恰好为真的最优雅的方法是什么? 最明显的 hack 是类型转换:将 false 转换为 0,将 true 转换为 1,然后对它们求和,并返回 sum
这个问题在这里已经有了答案: When to use extern "C" in simple words? [duplicate] (7 个答案) 关闭 9 年前。 如果您想将此问题标记为重复问题
我是一名优秀的程序员,十分优秀!