-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.5.1, 2.6.3
-
Component/s: Querying
-
None
-
Query Optimization
It is possible to negate arbitrary expression using the "$nor" expression. This ticket only tracks extending the syntax to allow negating expressions with "$not" as well.
Original description:
$not currently (<=2.5.1) only supports negating equality operators. so i can do { field: { $not : { [$eq,$gt,$lt,...] } }
but there is no way to negate an entire expression.
some example negated expressions (that don't work now):
Example expression | Logically equivalent to |
---|---|
{ $not: {a: 1} } | {a: {$ne: 1}} |
{ $not:
{a: 1, b: 2}
|
{$or: [ {a: {$ne: 1}}, {b: {$ne: 2}} ]} |
{ $not: {$and: [ {a: 1}, {b: 2}] } | {$or: [ {a: {$ne: 1}}, {b: {$ne: 2}} ]} |
{ $not: {$or: [ {a:1}, {b:2} ]} | {$and: [ {a: {$ne: 1}}, {b: {$ne: 2}} ]} |
{ a: 1, $not: {b: 2}} | {a: 1, b: {$ne: 2}} |
- duplicates
-
SERVER-1454 Use $not as a top-level logical op
- Backlog
- is duplicated by
-
SERVER-21936 support $not as top level operator
- Closed