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

negation of query expressions using "$not"

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Duplicate
    • 2.5.1, 2.6.3
    • None
    • Querying
    • None

    Description

      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}}

      Attachments

        Issue Links

          Activity

            People

              backlog-query-optimization Backlog - Query Optimization
              jsr Jared Rosoff
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: