distinct on a view doesn't "flatten" array members

XMLWordPrintableJSON

    • Fully Compatible
    • ALL
    • v3.4
    • Query 2017-02-13
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If you create an identity view on a collection which has some field that contains an array, the result of db.collection.distinct("thatfield") and db.identityview.distinct("thatfield") will not be the same.

      db.coll.find()
      { "_id" : ObjectId("5876aaed34e6e16cd498d61c"), "a" : 1 }
      { "_id" : ObjectId("5876aaf034e6e16cd498d61d"), "a" : [ 2 ] }
      { "_id" : ObjectId("5876aaf734e6e16cd498d61e"), "a" : [ 3, 4 ] }
      db.coll.distinct("a")
      [ 1, 2, 3, 4 ]
      db.createView("view","coll",[])
      { "ok" : 1 }
      agg@127.0.0.1:27017(3.4.1) > db.view.distinct("a")
      [ [ 3, 4 ], [ 2 ], 1 ]
      

              Assignee:
              Kyle Suarez (Inactive)
              Reporter:
              Asya Kamsky
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: