假设我的模型看起来像:
{_id: ..., 标签: ["stackoverflow", "github", "bootstrap", ...]}
如何搜索与 BOTH /stack/
和 /git/
匹配的所有项目?
最佳答案
有 mongo 正则表达式文档 http://docs.mongodb.org/manual/reference/operator/query/regex/
db.collection.find(
{
$and :
[
{ tags: { $regex: /git/ } },
{ tags: { $regex: /boot/ } }
]
})
这个解决方案可能对您有帮助 Searching in MongoDB
关于regex - MongoDB 通过带有正则表达式的标签进行搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26814947/