Inconsistent behavior of "distinct" with index

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This is surprising:

      > db.collection.insert({a:1})
      > db.collection.insert({})
      > db.collection.distinct('a')
      [ 1 ]
      > db.collection.createIndex({a:1})
      > db.collection.distinct('a')
      [ null, 1 ]
      

      A document without the 'a' field has no effect on the 'distinct' output when there's no index, but it contributes a 'null' to the output when there is an index.

              Assignee:
              Unassigned
              Reporter:
              A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: