Allow $not under object $elemMatch to use an index

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      SERVER-78260 was a bug related to "lifting" negation predicates outside of an $elemMatch. We appear to have solved this bug by making it so that $not under object $elemMatch cannot use an index, for example:

      > db.foo.createIndex({"arr.b": 1})
      > db.foo.find({arr: {$elemMatch: {b: {$ne: 1}}}}).explain()
      // collscan

      It seems to me like this query could use this index (with a residual filter), the same way that the non-negated query can.
       
      This ticket is to allow $not within an object $elemMatch to be able to use an index on the nested field. However, we should make sure not to re-introduce the bug fixed by SERVER-78260.

            Assignee:
            Unassigned
            Reporter:
            Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: