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?
I think I found it. It needed $ne
.
query = {
"venue_id": venue_id,
"status": {
"$ne": 404
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With