Mongo Query中的AND和OR

Don*_*nie 3 python mongodb pymongo

我在这个查询中使用了多个运算符.我没有语法错误,但我没有得到任何数据(应该是),所以我很确定我正在查看逻辑错误.问题是,我没有看到它.

查询:

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)}
        ]}
    ]}
)
Run Code Online (Sandbox Code Playgroud)

任何提示都表示赞赏.

Don*_*nie 6

我刚刚发现了这里记录的问题:https://jira.mongodb.org/browse/SERVER-2585

直到2011年7月24日MongoDB 1.9.1才支持嵌套的$ OR.我是旧版本.