我有将近5万个文档在一个类似这样的mongo集合中:
{"title":"sample title sample title",
"content":"test content test content",
"reply":{
"replyContent":"sample reply content test"
}
}
我有一系列类似这样的词:
^{pr2}$我需要匹配我的文档集合中是否存在任何单词形式的wordArr。我必须遍历集合中的每个文档,并搜索array id中给定的单词是否出现在其中的任何一个字段中,即title、content和replyContent
假设你的mongo集合在字典中,下面的方法应该有效(对不起,我没有mongo集合的经验)。在
这将为您提供以下输出:
^{pr2}$如果只想返回True或False:
如果有任意级别的嵌套,则可能需要嵌套方法
相关问题 更多 >
编程相关推荐