Skip to content

Commit b08efbd

Browse files
DOCSP-14384 fix first last accumulators (#2231)
* Removed first and last array operator topics * Removed links to and array operator topics * Added array behavior to existing and topics * Cleaned up links * Removed includes, started work on making ref sections consistent * Fixed aggregation accumulators landing page entries for first and last * Fixed descriptions for first and last * PR feedback and testing a ref * Updates to link cleanup * Reduced number of links per style guidelines * Parallel cleanup on headings and structure * Latest cleanup on and * Fixed firstN summary in aggregation reference * Committing cleaned branch * Restoring first/last updates to manually back out time series changes * Removed draft content for time series changes * Added first/last accumulator links to ArrayElemAt to replace expression links * Rebuilding
1 parent 4fd8e18 commit b08efbd

File tree

11 files changed

+137
-586
lines changed

11 files changed

+137
-586
lines changed

source/includes/extracts-agg-operators.yaml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ content: |
177177
- Selects a subset of the array to return an array with only
178178
the elements that match the filter condition.
179179
180-
* - :expression:`$first`
181-
182-
- Returns the first array element. Distinct from :group:`$first` accumulator.
183-
184180
* - :expression:`$firstN`
185181
186182
- Returns a specified number of elements from the beginning of an array.
@@ -201,10 +197,6 @@ content: |
201197
202198
- Determines if the operand is an array. Returns a boolean.
203199
204-
* - :expression:`$last`
205-
206-
- Returns the last array element. Distinct from :group:`$last` accumulator.
207-
208200
* - :expression:`$lastN`
209201
210202
- Returns a specified number of elements from the end of an array.
@@ -1061,10 +1053,8 @@ content: |
10611053
10621054
* - :group:`$first`
10631055
1064-
- Returns a value from the first document for each group. Order
1065-
is only defined if the documents are sorted.
1066-
1067-
Distinct from the :expression:`$first` array operator.
1056+
- Returns the result of an :ref:`expression
1057+
<aggregation-expressions>` for the first document in a group.
10681058
10691059
.. versionchanged:: 5.0
10701060
@@ -1084,10 +1074,8 @@ content: |
10841074
10851075
* - :group:`$last`
10861076
1087-
- Returns a value from the last document for each group. Order
1088-
is only defined if the documents are sorted.
1089-
1090-
Distinct from the :expression:`$last` array operator.
1077+
- Returns the result of an :ref:`expression
1078+
<aggregation-expressions>` for the last document in a group.
10911079
10921080
.. versionchanged:: 5.0
10931081
@@ -1213,6 +1201,16 @@ content: |
12131201
- Returns an average of the specified expression or list of
12141202
expressions for each document. Ignores non-numeric values.
12151203
1204+
* - :group:`$first`
1205+
1206+
- Returns the result of an :ref:`expression
1207+
<aggregation-expressions>` for the first document in a group.
1208+
1209+
* - :group:`$last`
1210+
1211+
- Returns the result of an :ref:`expression
1212+
<aggregation-expressions>` for the last document in a group.
1213+
12161214
* - :group:`$max`
12171215
12181216
- Returns the maximum of the specified expression or list of
@@ -1352,9 +1350,9 @@ content: |
13521350
13531351
* - :group:`$first`
13541352
1355-
- Returns the value that results from applying an
1356-
:ref:`expression <aggregation-expressions>` to the first
1357-
document in a group or :ref:`window <setWindowFields-window>`.
1353+
- Returns the result of an :ref:`expression
1354+
<aggregation-expressions>` for the first document in a group
1355+
or :ref:`window <setWindowFields-window>`.
13581356
13591357
.. versionchanged:: 5.0
13601358
@@ -1368,9 +1366,9 @@ content: |
13681366
13691367
* - :group:`$last`
13701368
1371-
- Returns the value that results from applying an
1372-
:ref:`expression <aggregation-expressions>` to the last
1373-
document in a group or :ref:`window <setWindowFields-window>`.
1369+
- Returns the result of an :ref:`expression
1370+
<aggregation-expressions>` for the last document in a group
1371+
or :ref:`window <setWindowFields-window>`.
13741372
13751373
.. versionchanged:: 5.0
13761374

source/includes/note-group-and-window-behavior.rst

Lines changed: 0 additions & 20 deletions
This file was deleted.

source/meta/aggregation-quick-reference.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,7 @@ Index of Expression Operators
376376
- :expression:`$eq`
377377
- :expression:`$exp`
378378
- :expression:`$filter`
379-
- :expression:`$first` (array)
380-
- :group:`$first` (accumulator)
379+
- :group:`$first`
381380
- :expression:`$floor`
382381
- :expression:`$function`
383382
- :expression:`$getField`
@@ -394,8 +393,7 @@ Index of Expression Operators
394393
- :expression:`$isoDayOfWeek`
395394
- :expression:`$isoWeek`
396395
- :expression:`$isoWeekYear`
397-
- :expression:`$last` (array)
398-
- :group:`$last` (accumulator)
396+
- :group:`$last`
399397
- :expression:`$let`
400398
- :expression:`$literal`
401399
- :expression:`$ln`

source/reference/command/collMod.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Definition
1515

1616
.. dbcommand:: collMod
1717

18-
:dbcommand:`collMod` makes it possible to add options to a collection
19-
or to modify view definitions.
18+
:dbcommand:`collMod` makes it possible to add options to a
19+
collection or to modify view definitions.
2020

2121
.. |method| replace:: :method:`~db.collection.hideIndex` and
2222
:method:`~db.collection.unhideIndex` helper methods

source/reference/operator/aggregation.txt

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -502,31 +502,19 @@ Alphabetical Listing of Expression Operators
502502
.. versionchanged:: 5.0
503503

504504
Available in :pipeline:`$setWindowFields` stage.
505-
506-
Distinct from the :expression:`$first` array operator.
507-
508-
509-
* - :expression:`$first`
510-
511-
- Returns the first array element.
512-
513-
.. versionadded:: 4.4
514-
515-
Distinct from the :group:`$first` accumulator.
516505

517506
* - :expression:`$firstN`
518507

519508
- Returns a specified number of elements from the beginning of an
520-
array.
521-
Distinct from the :group:`$firstN` accumulator.
509+
array. Distinct from the :group:`$firstN` accumulator.
522510

523511
.. versionadded:: 5.2
524512

525513
* - :group:`$firstN`
526514

527515
- Returns an aggregation of the first ``n`` fields within a group.
528-
Only meaningful when documents are in a defined order.
529-
Distinct from the :expression:`$firstN` array operator.
516+
Results are only meaningful when documents are in a defined
517+
order. Distinct from the :expression:`$firstN` array operator.
530518

531519
.. versionadded:: 5.2
532520

@@ -654,17 +642,7 @@ Alphabetical Listing of Expression Operators
654642
.. versionchanged:: 5.0
655643

656644
Available in :pipeline:`$setWindowFields` stage.
657-
658-
Distinct from the :expression:`$last` array operator.
659-
660-
661-
* - :expression:`$last`
662645

663-
- Returns the last array element.
664-
665-
.. versionadded:: 4.4
666-
667-
Distinct from the :group:`$last` accumulator.
668646

669647
* - :expression:`$lastN`
670648

@@ -676,8 +654,8 @@ Alphabetical Listing of Expression Operators
676654
* - :group:`$lastN`
677655

678656
- Returns an aggregation of the last ``n`` fields within a group.
679-
Only meaningful when documents are in a defined order.
680-
Distinct from the :expression:`$lastN` array operator.
657+
Results are only meaningful when documents are in a defined
658+
order. Distinct from the :expression:`$lastN` array operator.
681659

682660
.. versionadded:: 5.2
683661

@@ -1336,7 +1314,6 @@ Alphabetical Listing of Expression Operators
13361314
/reference/operator/aggregation/filter
13371315
/reference/operator/aggregation/first
13381316
/reference/operator/aggregation/firstN
1339-
/reference/operator/aggregation/first-array-element
13401317
/reference/operator/aggregation/firstN-array-element
13411318
/reference/operator/aggregation/floor
13421319
/reference/operator/aggregation/function
@@ -1357,7 +1334,6 @@ Alphabetical Listing of Expression Operators
13571334
/reference/operator/aggregation/isoWeekYear
13581335
/reference/operator/aggregation/last
13591336
/reference/operator/aggregation/lastN
1360-
/reference/operator/aggregation/last-array-element
13611337
/reference/operator/aggregation/lastN-array-element
13621338
/reference/operator/aggregation/let
13631339
/reference/operator/aggregation/linearFill

source/reference/operator/aggregation/arrayElemAt.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ The operation returns the following results:
110110
See Also
111111
--------
112112

113-
- :expression:`$first`
113+
- :expression:`$slice`
114114

115-
- :expression:`$last`
115+
- :group:`$first`
116116

117-
- :expression:`$slice`
117+
- :group:`last`
118118

119119
- :ref:`agg-quick-ref-operator-array`

0 commit comments

Comments
 (0)