[DOCS-7888] Comment on: "manual/reference/operator/aggregation/first.txt" Created: 17/May/16  Updated: 03/Nov/17  Resolved: 24/May/16

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.com/manual/reference/operator/aggregation/first/
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36
Screen Resolution: 1920 x 1080


Participants:
Days since reply: 7 years, 38 weeks, 1 day ago

 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 :



 Comments   
Comment by Githook User [ 24/May/16 ]

Author:

{u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-7888 sort+group output order clarification
Branch: master
https://github.com/mongodb/docs/commit/83ceba036664119512c6ffca7110477a83eaaafd

Generated at Thu Feb 08 07:55:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.