MongoDB: Can't canonicalize query: BadValue $not needs a regex or a document
mongodb
Solution
I think I found it. It needed `$ne`.
query = {
"venue_id": venue_id,
"status": {
"$ne": 404
}
}
Problem
Some of my documents contain a field named `status` with the value `404`. I do not wish to return those files, so I use the `$not` operator: ``` query = { "venue_id": venue_id, "status": { "$not": 404 } } ``` However I get an error: ``` OperationFailure: database error: Can't canonicalize query: BadValue $not needs a regex or a document ``` Does this happen because some of the docs have that field? I do not wish to use regex for speed reasons. How can I make this query correctly and efficiently?