Reputation: 6351
I'm using multiple operators in this query. I get no syntax errors, but I'm not getting any data back (and should be), so I'm pretty certain that I'm looking at a logical error. Problem is, I don't see it.
Query:
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)}
]}
]}
)
Any tips are appreciated.
Upvotes: 3
Views: 2520
Reputation: 434
Please find the query
AND Queries With Multiple Expressions Specifying the Same Operator
Consider the following example:
db.inventory.find( {
$and : [
{ $or : [ { price : 0.99 }, { price : 1.99 } ] },
{ $or : [ { sale : true }, { qty : { $lt : 20 } } ] }
]
} )
Upvotes: 0
Reputation: 6351
I just found the issue as documented here: https://jira.mongodb.org/browse/SERVER-2585
Nested $OR is not supported until MongoDB 1.9.1 as of 7-24-2011. I'm on an older version.
Upvotes: 6