3
我在此查询中使用多个运算符。我没有得到任何语法错误,但我没有收到任何数据(应该是),所以我非常确定我正在查看逻辑错误。问题是,我没有看到它。AND和OR在Mongo查询
查询:
db.questions.find(
{'$and': [
{'answers.s_user_id': {'$ne': s_user_id}},
{'$or': [
{'s_text': re.compile(s_term, re.IGNORECASE)},
{'choices': re.compile(s_term, re.IGNORECASE)}
]}
]}
)
任何提示赞赏。
要添加到您的发现,你的查询等效于db.questions.find( { 'answers.s_user_id':{ '$ NE':s_user_id}},{ $或:[ {” s_text':re.compile(s_term,re.IGNORECASE)}, {'choices':re.compile(s_term,re.IGNORECASE)} ]} } ) – snez