[英]Find doc from field having all specified words
I've problem to find the good document search request do find all documents containing in their 'name' field all the specified values.我很难找到好的文档搜索请求,确实可以找到在其“名称”字段中包含所有指定值的所有文档。
I've this document:我有这份文件:
{
"_id" : ObjectId("607c1caa4b2964d0185301ff"),
"nb" : 1,
"name" : "mini computer 24GB"
}
When I run the following find request...当我运行以下查找请求时...
db.getCollection('test').find({"$text":{$search:'computer dummy'}})
... the document is returned. ... 文件被退回。 An OR is done but I want a AND operation.
OR 已完成,但我想要 AND 操作。 Should I use a list of $and?
我应该使用 $and 列表吗?
Many thanks非常感谢
I've problem to find the good document search request do find all documents containing in their 'name' field all the specified values.我很难找到好的文档搜索请求确实找到在其“名称”字段中包含所有指定值的所有文档。
I've this document:我有这个文件:
{
"_id" : ObjectId("607c1caa4b2964d0185301ff"),
"nb" : 1,
"name" : "mini computer 24GB"
}
When I run the following find request...当我运行以下查找请求时...
db.getCollection('test').find({"$text":{$search:'computer dummy'}})
... the document is returned. ...文件被退回。 An OR is done but I want a AND operation.
OR 已完成,但我想要 AND 操作。 Should I use a list of $and?
我应该使用 $and 的列表吗?
Many thanks非常感谢
Ok I found.好的,我找到了。 each word must be in quotes as this:
每个单词都必须用引号引起来,如下所示:
db.getCollection('test').find({$text:{$search:"\"computer\" \"24GB\""}})
Not really intuitive!不是很直观!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.