File tree Expand file tree Collapse file tree 4 files changed +16
-16
lines changed
reference/operator/aggregation Expand file tree Collapse file tree 4 files changed +16
-16
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -32,11 +32,10 @@ Definition
3232Behavior
3333--------
3434
35- When using :group:`$first` in a :pipeline:`$group` stage, the
36- :pipeline:`$group` stage should follow a :pipeline:`$sort` stage to
37- have the input documents in a defined order.
38-
39- .. include:: /includes/note-group-pipeline-sort-order.rst
35+ When using :group:`$first` in a :pipeline:`$group` stage, the output
36+ value depends on the order of the documents coming into pipeline. To
37+ guarantee a defined order, the :pipeline:`$group` pipeline stage should
38+ follow a :pipeline:`$sort` stage.
4039
4140Example
4241-------
Original file line number Diff line number Diff line change @@ -32,11 +32,10 @@ Definition
3232Behavior
3333--------
3434
35- When using :group:`$last` in a :pipeline:`$group` stage, the
36- :pipeline:`$group` stage should follow a :pipeline:`$sort` stage to
37- have the input documents in a defined order.
38-
39- .. include:: /includes/note-group-pipeline-sort-order.rst
35+ When using :group:`$last` in a :pipeline:`$group` stage, the output
36+ value depends on the order of the documents coming into pipeline. To
37+ guarantee a defined order, the :pipeline:`$group` pipeline stage should
38+ follow a :pipeline:`$sort` stage.
4039
4140Example
4241-------
Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ Definition
3232Behavior
3333--------
3434
35+ When using :group:`$push` in a :pipeline:`$group` stage, the order of
36+ the documents in the output array is determined by the order of the
37+ documents coming into pipeline. To guarantee a defined order, the
38+ :pipeline:`$group` pipeline stage should follow a :pipeline:`$sort`
39+ stage.
40+
3541Memory Restrictions
3642~~~~~~~~~~~~~~~~~~~
3743
@@ -67,7 +73,8 @@ compute the list of items and quantities sold for each group:
6773
6874 db.sales.aggregate(
6975 [
70- {
76+ { $sort: { date: 1, item: 1 } },
77+ {
7178 $group:
7279 {
7380 _id: { day: { $dayOfYear: "$date"}, year: { $year: "$date" } },
You can’t perform that action at this time.
0 commit comments