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

Inconsistent behavior of "distinct" with index

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

      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 Unassigned
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: