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

Inconsistent behavior of "distinct" with index

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Index Maintenance
    • None
    • ALL

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: