Skip to content

Commit 5d51537

Browse files
ianf-mongodbjeff-allen-mongo
authored andcommitted
Docsp-19837 document first n last n (#148)
* DOCSP-19837 init * DOCSP-19837 * DOCSP-19837 * * * remove highest * remove highest verbiage * adjust to feedback * * * Add more context * gameid to own line * fix 275 code block indent * * * Address Mihai comments #1 * *** * Added Aggregation Expression example and addressed Mickey Comments #1 * minor verbaige cleanup * a aggregation expression -> an aggregation expression * Updated based on latest TR feedback * corrected input statement * group key example for href * Adjust lastFive... bullet point and output on both pages * make aggregation.txt Available in... consistant with extracts-agg * Address Katyas comments #1 * correct emphasize lines for last ex * rebase * fix spacing in 5.2 * Add distinct notes to all accumulators * fix 5.2 build errors * *
1 parent 6dc1295 commit 5d51537

File tree

6 files changed

+888
-13
lines changed

6 files changed

+888
-13
lines changed

source/includes/extracts-agg-operators.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,18 @@ content: |
10741074
10751075
Available in :pipeline:`$setWindowFields` stage.
10761076
1077+
* - :group:`$firstN`
1078+
1079+
- Returns an aggregation of the first ``n`` elements within a group.
1080+
Only meaningful when documents are in a defined order.
1081+
Distinct from the :expression:`$firstN` array operator.
1082+
1083+
.. versionadded:: 5.2
1084+
1085+
Available in :pipeline:`$group`,
1086+
:ref:`expression <aggregation-expressions>` and
1087+
:pipeline:`$setWindowFields` stages.
1088+
10771089
* - :group:`$last`
10781090
10791091
- Returns a value from the last document for each group. Order
@@ -1085,6 +1097,18 @@ content: |
10851097
10861098
Available in :pipeline:`$setWindowFields` stage.
10871099
1100+
* - :group:`$lastN`
1101+
1102+
- Returns an aggregation of the last ``n`` elements within a group.
1103+
Only meaningful when documents are in a defined order.
1104+
Distinct from the :expression:`$lastN` array operator.
1105+
1106+
.. versionadded:: 5.2
1107+
1108+
Available in :pipeline:`$group`,
1109+
:ref:`expression <aggregation-expressions>` and
1110+
:pipeline:`$setWindowFields` stages.
1111+
10881112
* - :group:`$max`
10891113
10901114
- Returns the highest expression value for each group.
@@ -1097,6 +1121,7 @@ content: |
10971121
10981122
- Returns an aggregation of the ``n`` maximum valued elements in
10991123
a group.
1124+
Distinct from the :expression:`$maxN` array operator.
11001125
11011126
.. versionadded:: 5.2
11021127
@@ -1385,6 +1410,7 @@ content: |
13851410
13861411
- Returns an aggregation of the ``n`` minimum valued elements in a
13871412
group.
1413+
Distinct from the :expression:`$minN` array operator.
13881414
13891415
.. versionadded:: 5.2
13901416

source/includes/setWindowFields-operators.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ These operators can be used with the :pipeline:`$setWindowFields` stage:
33
.. _setWindowFields-accumulator-operators:
44

55
- Accumulator operators: :group:`$addToSet`, :group:`$avg`,
6-
:group:`$bottomN`, :group:`$count`, :group:`$covariancePop`,
7-
:group:`$covarianceSamp`, :group:`$derivative`,
8-
:group:`$expMovingAvg`, :group:`$integral`, :group:`$max`, :group:`$maxN`,
9-
:group:`$min`, :group:`$minN`, :group:`$push`, :group:`$stdDevSamp`,
10-
:group:`$stdDevPop`, :group:`$sum` and :group:`$topN`.
6+
:group:`$bottom`, :group:`$bottomN`, :group:`$count`,
7+
:group:`$covariancePop`, :group:`$covarianceSamp`,
8+
:group:`$derivative`, :group:`$expMovingAvg`, :group:`$firstN`,
9+
:group:`$integral`, :group:`$lastN`, :group:`$max`, :group:`$maxN`,
10+
:group:`$min`, :group:`$minN`, :group:`$push`, :group:`$stdDevSamp`,
11+
:group:`$stdDevPop`, :group:`$sum`, :group:`$top`, :group:`$topN`.
1112

1213
.. _setWindowFields-gap-filling-operators:
1314

source/reference/operator/aggregation.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,18 @@ Alphabetical Listing of Expression Operators
520520

521521
.. versionadded:: 5.2
522522

523+
* - :group:`$firstN`
524+
525+
- Returns an aggregation of the first ``n`` fields within a group.
526+
Only meaningful when documents are in a defined order.
527+
Distinct from the :expression:`$firstN` array operator.
528+
529+
.. versionadded:: 5.2
530+
531+
Available in :pipeline:`$group`,
532+
:ref:`expression <aggregation-expressions>` and
533+
:pipeline:`$setWindowFields` stages.
534+
523535
* - :expression:`$floor`
524536

525537
- Returns the largest integer less than or equal to the specified number.
@@ -659,6 +671,18 @@ Alphabetical Listing of Expression Operators
659671

660672
.. versionadded:: 5.2
661673

674+
* - :group:`$lastN`
675+
676+
- Returns an aggregation of the last ``n`` fields within a group.
677+
Only meaningful when documents are in a defined order.
678+
Distinct from the :expression:`$lastN` array operator.
679+
680+
.. versionadded:: 5.2
681+
682+
Available in :pipeline:`$group`,
683+
:ref:`expression <aggregation-expressions>` and
684+
:pipeline:`$setWindowFields` stages.
685+
662686
* - :expression:`$let`
663687

664688
- Defines variables for use within the scope of a subexpression and
@@ -735,6 +759,7 @@ Alphabetical Listing of Expression Operators
735759

736760
- Returns an aggregation of the ``n`` maximum valued elements in a
737761
group.
762+
Distinct from the :expression:`$maxN` array operator.
738763

739764
.. versionadded:: 5.2
740765

@@ -761,10 +786,18 @@ Alphabetical Listing of Expression Operators
761786

762787
Available in :pipeline:`$setWindowFields` stage.
763788

789+
* - :expression:`$minN`
790+
791+
- Returns the ``n`` smallest values in an array.
792+
Distinct from the :group:`$minN` accumulator.
793+
794+
.. versionadded:: 5.2
795+
764796
* - :group:`$minN`
765797

766798
- Returns an aggregation of the ``n`` minimum valued elements in a
767799
group.
800+
Distinct from the :expression:`$minN` array operator.
768801

769802
.. versionadded:: 5.2
770803

@@ -1261,6 +1294,7 @@ Alphabetical Listing of Expression Operators
12611294
/reference/operator/aggregation/avg
12621295
/reference/operator/aggregation/binarySize
12631296
/reference/operator/aggregation/bottom
1297+
/reference/operator/aggregation/bottomN
12641298
/reference/operator/aggregation/bsonSize
12651299
/reference/operator/aggregation/ceil
12661300
/reference/operator/aggregation/cmp
@@ -1294,6 +1328,7 @@ Alphabetical Listing of Expression Operators
12941328
/reference/operator/aggregation/expMovingAvg
12951329
/reference/operator/aggregation/filter
12961330
/reference/operator/aggregation/first
1331+
/reference/operator/aggregation/firstN
12971332
/reference/operator/aggregation/first-array-element
12981333
/reference/operator/aggregation/firstN-array-element
12991334
/reference/operator/aggregation/floor
@@ -1314,6 +1349,7 @@ Alphabetical Listing of Expression Operators
13141349
/reference/operator/aggregation/isoWeek
13151350
/reference/operator/aggregation/isoWeekYear
13161351
/reference/operator/aggregation/last
1352+
/reference/operator/aggregation/lastN
13171353
/reference/operator/aggregation/last-array-element
13181354
/reference/operator/aggregation/lastN-array-element
13191355
/reference/operator/aggregation/let
@@ -1395,6 +1431,7 @@ Alphabetical Listing of Expression Operators
13951431
/reference/operator/aggregation/toLong
13961432
/reference/operator/aggregation/toObjectId
13971433
/reference/operator/aggregation/top
1434+
/reference/operator/aggregation/topN
13981435
/reference/operator/aggregation/toString
13991436
/reference/operator/aggregation/toLower
14001437
/reference/operator/aggregation/toUpper

0 commit comments

Comments
 (0)