Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10708

negation of query expressions using "$not"

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 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}}

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            jsr Jared Rosoff
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: