Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-7888

Comment on: "manual/reference/operator/aggregation/first.txt"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • None
    • None

    Description

      Is it a bug when using sort with group?

      Like the example on the page, when performing operation like :
      db.sales.aggregate(
      [
      { $sort:

      { item: 1, date: 1 }

      },
      {
      $group:
      {
      _id: "$item",
      firstSalesDate:

      { $first: "$date" }

      }
      }
      ]
      )

      The operation returns the following results:

      { "_id" : "xyz", "firstSalesDate" : ISODate("2014-02-03T09:05:00Z") } { "_id" : "jkl", "firstSalesDate" : ISODate("2014-02-03T09:00:00Z") } { "_id" : "abc", "firstSalesDate" : ISODate("2014-01-01T08:00:00Z") }

      But i think the result should be liked :

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 38 weeks, 1 day ago