Aggregation Pipeline Quick Reference聚合管道快速参考
On this page本页内容
Stages阶段Stages阶段 (db.collection.aggregate
)Stages阶段 (db.aggregate
)Stages Available for Updates可用于更新的阶段Expressions表达式Field Paths字段路径Aggregation Variables聚合变量Literals字面量Expression Objects表达式对象Operator Expressions运算符表达式Arithmetic Expression Operators算术表达式运算符Array Expression Operators数组表达式运算符Boolean Expression Operators布尔表达式运算符Comparison Expression Operators比较表达式运算符Conditional Expression Operators条件表达式运算符Custom Aggregation Expression Operators自定义聚合表达式运算符Data Size Expression Operators数据大小表达式运算符Date Expression Operators日期表达式运算符Literal Expression Operator字面量表达式运算符Miscellaneous Operators混杂运算符Object Expression Operators对象表达式运算符Set Expression Operators设置表达式运算符String Expression Operators字符串表达式运算符Text Expression Operator文本表达式运算符Trigonometry Expression Operators三角表达式运算符Type Expression Operators类型表达式运算符Accumulators累加器 ($group, $bucket, $bucketAuto, $setWindowFields
)Accumulators (in Other Stages)累加器(其他阶段)Variable Expression Operators变量表达式运算符Window Operators窗口运算符Index of Expression Operators表达式运算符索引
For details on a specific operator, including syntax and examples, click on the link to the operator's reference page.有关特定运算符的详细信息,包括语法和示例,请单击该运算符参考页的链接。
Stages阶段
Stages阶段 (db.collection.aggregate
)
In the 在db.collection.aggregate()
method, pipeline stages appear in an array. db.collection.aggregate()
方法中,管道阶段显示在一个数组中。Documents pass through the stages in sequence. 文件按顺序通过各个阶段。All except the 除$out
, $merge
, and $geoNear
stages can appear multiple times in a pipeline.$out
、$merge
和$geoNear
阶段外,所有阶段都可以在管道中多次出现。
db.collection.aggregate( [ { <stage> }, ... ] )
$addFields | $project , $addFields reshapes each document in the stream; specifically, by adding new fields to output documents that contain both the existing fields from the input documents and the newly added fields.$project ,$addFields 对流中的每个文档进行重新整形;具体地说,通过将新字段添加到既包含输入文档中的现有字段又包含新添加字段的输出文档中。$set $addFields . $addFields 的别名。 |
$bucket | |
$bucketAuto | |
$changeStream | |
$changeStreamSplitLargeEvent | $changeStreamSplitLargeEvent in a $changeStream pipeline and it must be the final stage in the pipeline. $changeStream 管道中使用$changeStreamSplitTargetEvent ,并且它必须是管道中的最后阶段。 |
$collStats | |
$count | $count aggregation accumulator. $count 聚合累加器不同。 |
$densify | |
$documents | |
$facet | |
$fill | null and missing field values within documents. null 字段值和缺少的字段值。 |
$geoNear | $match , $sort , and $limit for geospatial data. $match 、$sort 和$limit 功能。 |
$graphLookup | |
$group | |
$indexStats | |
$limit | |
$listSampledQueries | |
$listSearchIndexes | |
$listSessions | system.sessions collection.system.sessions 集合的所有会话。 |
$lookup | |
$match | $match |
$merge | $merge stage, it must be the last stage in the pipeline. $merge 阶段,它必须是管道中的最后一个阶段。 |
$out | $out stage, it must be the last stage in the pipeline.$out 阶段,它必须是管道中的最后一个阶段。 |
$planCacheStats | |
$project | $unset for removing existing fields. $unset 以删除现有字段。 |
$redact | $project and $match . $project 和$match 的功能。 |
$replaceRoot | _id field. _id 字段。$replaceWith $replaceRoot stage. $replaceRoot 阶段的别名。 |
$replaceWith | _id field. _id 字段。$replaceWith is an alias for $replaceRoot stage. |
$sample | |
$search | Note $search |
$searchMeta | Note $searchMeta |
$set | $project , $set reshapes each document in the stream; specifically, by adding new fields to output documents that contain both the existing fields from the input documents and the newly added fields.$project 类似,$set 对流中的每个文档进行重新整形;具体地说,通过将新字段添加到既包含输入文档中的现有字段又包含新添加字段的输出文档中。$set $addFields stage. $addFields 阶段的别名。 |
$setWindowFields | |
$skip | |
$sort | |
$sortByCount | |
$unionWith | |
$unset | $unset $project stage that removes fields. $project 阶段的别名。 |
$unwind |
Stages阶段 (db.aggregate
)
Starting in version 3.6, MongoDB also provides the 从3.6版本开始,MongoDB还提供了db.aggregate()
method:db.aggregate()
方法:
db.aggregate( [ { <stage> }, ... ] )
The following stages use the 以下阶段使用db.aggregate()
method and not the db.collection.aggregate()
method.db.aggregate()
方法,而不是db.collection.aggregate()
方法。
$changeStream | |
$currentOp | |
$listLocalSessions | mongos or mongod instance. mongos 或mongod 实例上使用的所有活动会话。system.sessions collection.system.sessions 集合。 |
$documents |
Stages Available for Updates可用于更新的阶段
Starting in MongoDB 4.2, you can use the aggregation pipeline for updates in:从MongoDB 4.2开始,您可以在以下位置使用聚合管道进行更新:
For the updates, the pipeline can consist of the following stages:对于更新,管道可以由以下阶段组成:
$addFields
and its alias及其别名$set
$project
and its alias及其别名$unset
$replaceRoot
and its alias及其别名$replaceWith
.
See also: 另请参阅:
Expressions表达式
Expressions can include field paths, literals, system variables, expression objects, and expression operators. 表达式可以包括字段路径、字面量、系统变量、表达式对象和表达式运算符。Expressions can be nested.表达式可以嵌套。
Field Paths字段路径
Aggregation expressions use field path to access fields in the input documents. 聚合表达式使用字段路径访问输入文档中的字段。To specify a field path, prefix the field name or the dotted field name (if the field is in the embedded document) with a dollar sign 若要指定字段路径,请在字段名或虚线字段名(如果字段在嵌入文档中)前面加上美元符号$
. $
。For example, 例如,"$user"
to specify the field path for the user
field or "$user.name"
to specify the field path to "user.name"
field."$user"
指定user
字段的字段路径,或"$user.name"
指定"user.name"
字段的字段通路。
"$<field>"
is equivalent to "$$CURRENT.<field>"
where the CURRENT
is a system variable that defaults to the root of the current object, unless stated otherwise in specific stages."$<field>"
相当于"$$CURRENT.<field>"
,其中CURRENT
是一个系统变量,默认为当前对象的根,除非在特定阶段另有说明。
Aggregation Variables聚合变量
MongoDB provides various aggregation system variables for use in expressions. MongoDB提供了用于表达式的各种聚合系统变量。To access variables, prefix the variable name with 要访问变量,请在变量名前面加上$$
. $$
。For example:例如:
$$ $$ 访问 | ||
---|---|---|
NOW | $$NOW | |
CLUSTER_TIME | $$CLUSTER_TIME | |
ROOT | $$ROOT | |
CURRENT | $$CURRENT | ROOT but can be changed.ROOT ,但可以更改。 |
REMOVE | $$REMOVE | |
DESCEND | $$DESCEND | $redact expression.$redact 表达式允许的结果之一。 |
PRUNE | $$PRUNE | $redact expression.$redact 表达式允许的结果之一。 |
KEEP | $$KEEP | $redact expression.$redact 表达式允许的结果之一。 |
USER_ROLES | $$USER_ROLES | USER_ROLES , see the find, aggregation, view, updateOne, updateMany, and findAndModify examples. USER_ROLES 的用例,请参阅find 、aggregation 、视图、updateOne 、updateMany 和findAndModify 示例。 |
For a more detailed description of these variables, see system variables.有关这些变量的更详细描述,请参阅系统变量。
Literals字面量
Literals can be of any type. 字面量可以是任何类型。However, MongoDB parses string literals that start with a dollar sign 然而,MongoDB解析以美元符号$
as a path to a field and numeric/boolean literals in expression objects as projection flags. $
开头的字符串字面量作为字段的路径,解析表达式对象中的数字/布尔字面量作为投影标志。To avoid parsing literals, use the 为了避免解析字面量,请使用$literal
expression.$literal
表达式。
Expression Objects表达式对象
Expression objects have the following form:表达式对象具有以下形式:
{ <field1>: <expression1>, ... }
If the expressions are numeric or boolean literals, MongoDB treats the literals as projection flags (e.g. 如果表达式是数字或布尔文本,MongoDB将文本视为投影标志(例如,1
or true
to include the field), valid only in the $project
stage. 1
或true
以包含字段),仅在$project
阶段有效。To avoid treating numeric or boolean literals as projection flags, use the 若要避免将数字或布尔字面量视为投影标志,请使用$literal
expression to wrap the numeric or boolean literals.$literal
表达式包装数字或布尔文本。
Operator Expressions运算符表达式
Operator expressions are similar to functions that take arguments. 运算符表达式类似于接受参数的函数。In general, these expressions take an array of arguments and have the following form:通常,这些表达式采用参数数组,并具有以下形式:
{ <operator>: [ <argument1>, <argument2> ... ] }
If operator accepts a single argument, you can omit the outer array designating the argument list:如果运算符接受单个参数,则可以省略指定参数列表的外部数组:
{ <operator>: <argument> }
To avoid parsing ambiguity if the argument is a literal array, you must wrap the literal array in a 如果参数是字面量数组,为了避免解析歧义,必须将字面量数组包装在$literal
expression or keep the outer array that designates the argument list.$literal
表达式中,或者保留指定参数列表的外部数组。
Arithmetic Expression Operators算术表达式运算符
Arithmetic expressions perform mathematic operations on numbers. 算术表达式对数字进行数学运算。Some arithmetic expressions can also support date arithmetic.一些算术表达式也可以支持日期算术。
$abs | |
$add | |
$ceil | |
$divide | |
$exp | |
$floor | |
$ln | |
$log | |
$log10 | |
$mod | |
$multiply | |
$pow | |
$round | |
$sqrt | |
$subtract | |
$trunc |
Array Expression Operators数组表达式运算符
$arrayElemAt | |
$arrayToObject | |
$concatArrays | |
$filter | |
$firstN | $firstN accumulator.$firstN 累加器不同。 |
$in | |
$indexOfArray | |
$isArray | |
$lastN | $lastN accumulator.$lastN 累加器不同。 |
$map | |
$maxN | n largest values in an array. $maxN accumulator.$maxN 累加器不同。 |
$minN | n smallest values in an array. $minN accumulator.$minN 累加器不同。 |
$objectToArray | |
$range | |
$reduce | |
$reverseArray | |
$size | |
$slice | |
$sortArray | |
$zip |
Boolean Expression Operators布尔表达式运算符
Boolean expressions evaluate their argument expressions as booleans and return a boolean as the result.布尔表达式将其参数表达式计算为布尔值,并返回布尔值作为结果。
In addition to the 除了false
boolean value, Boolean expression evaluates as false
the following: null
, 0
, and undefined
values. false
布尔值之外,布尔表达式还将以下值计算为false
:null
、0
和undefined
值。The Boolean expression evaluates all other values as 布尔表达式将所有其他值计算为true
, including non-zero numeric values and arrays.true
,包括非零数值和数组。
$and | true only when all its expressions evaluate to true . true 时才返回true 。 |
$not | |
$or | true when any of its expressions evaluates to true . true 时,返回true 。 |
Comparison Expression Operators比较表达式运算符
Comparison expressions return a boolean except for 比较表达式返回一个布尔值,但$cmp
which returns a number.$cmp
返回一个数字。
The comparison expressions take two argument expressions and compare both value and type, using the specified BSON comparison order for values of different types.比较表达式采用两个参数表达式,并对不同类型的值使用指定的BSON比较顺序来比较值和类型。
$cmp | 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second.0 ;如果第一个值大于第二个值,则返回1 ;如果第一值小于第二个,则返回-1 。 |
$eq | true if the values are equivalent.true 。 |
$gt | true if the first value is greater than the second.true 。 |
$gte | true if the first value is greater than or equal to the second.true 。 |
$lt | true if the first value is less than the second.true 。 |
$lte | true if the first value is less than or equal to the second.true 。 |
$ne | true if the values are not equivalent.true 。 |
Conditional Expression Operators条件表达式运算符
$cond | |
$ifNull | null 结果,如果第一个表达式导致null 结果,则返回第二个表达式的结果。Null 结果包含未定义值或缺少字段的实例。null 。 |
$switch | true , $switch executes a specified expression and breaks out of the control flow.true 的表达式时,$switch 执行指定的表达式并脱离控制流。 |
Custom Aggregation Expression Operators自定义聚合表达式运算符
$accumulator | |
$function |
Data Size Expression Operators数据大小表达式运算符
The following operators return the size of a data element:以下运算符返回数据元素的大小:
$binarySize | |
$bsonSize | Object ) when encoded as BSON. |
Date Expression Operators日期表达式运算符
The following operators returns date objects or components of a date object:以下运算符返回日期对象或日期对象的组件:
$dateAdd | |
$dateDiff | |
$dateFromParts | |
$dateFromString | |
$dateSubtract | |
$dateToParts | |
$dateToString | |
$dateTrunc | |
$dayOfMonth | |
$dayOfWeek | |
$dayOfYear | |
$hour | |
$isoDayOfWeek | 1 (for Monday) to 7 (for Sunday).1 (周一)到7 (周日)。 |
$isoWeek | 1 to 53 . 1 到53 。1 with the week (Monday through Sunday) that contains the year's first Thursday. |
$isoWeekYear | |
$millisecond | |
$minute | |
$month | |
$second | |
$toDate | |
$week | |
$year |
The following arithmetic operators can take date operands:以下算术运算符可以接受日期操作数:
$add | |
$subtract |
Literal Expression Operator文字表达式运算符
$literal | $literal expression to a string that starts with a dollar sign ($ ) to avoid parsing as a field path.$ )开头的字符串使用$literal 表达式,以避免将其解析为字段路径。 |
Miscellaneous Operators混杂运算符
$getField | $getField to retrieve the value of fields with names that contain periods (. ) or start with dollar signs ($ ). $getField 来检索名称包含句点(. )或以美元符号($ )开头的字段的值。 |
$rand | |
$sampleRate |
Object Expression Operators对象表达式运算符
$mergeObjects | |
$objectToArray | |
$setField | $setField to add, update, or remove fields with names that contain periods (. ) or start with dollar signs ($ ). $setField 添加、更新或删除名称包含句点(. )或以美元符号($ )开头的字段。 |
Set Expression Operators设置表达式运算符
Set expressions performs set operation on arrays, treating arrays as sets. 集合表达式对数组执行集合运算,将数组视为集合。Set expressions ignores the duplicate entries in each input array and the order of the elements.Set表达式会忽略每个输入数组中的重复项和元素的顺序。
If the set operation returns a set, the operation filters out duplicates in the result to output an array that contains only unique entries. 如果set操作返回一个集合,则该操作会筛选出结果中的重复项,以输出仅包含唯一项的数组。The order of the elements in the output array is unspecified.输出数组中元素的顺序未指定。
If a set contains a nested array element, the set expression does not descend into the nested array but evaluates the array at top-level.如果集合包含嵌套数组元素,则集合表达式不会下降到嵌套数组中,而是在顶级计算数组。
$allElementsTrue | true if no element of a set evaluates to false , otherwise, returns false . false ,则返回true ,否则返回false 。 |
$anyElementTrue | true if any elements of a set evaluate to true ; otherwise, returns false . true ,则返回true ;否则,返回false 。 |
$setDifference | |
$setEquals | true if the input sets have the same distinct elements. true 。 |
$setIntersection | |
$setIsSubset | true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subsettrue ;即不是严格的子集 |
$setUnion |
String Expression Operators字符串表达式运算符
String expressions, with the exception of 字符串表达式($concat
, only have a well-defined behavior for strings of ASCII characters.$concat
除外)只对ASCII字符字符串具有定义良好的行为。
$concat
behavior is well-defined regardless of the characters used.无论使用什么字符,行为都是定义良好的。
$concat | |
$dateFromString | |
$dateToString | |
$indexOfBytes | -1 .-1 。 |
$indexOfCP | -1 -1 |
$ltrim | |
$regexFind | |
$regexFindAll | |
$regexMatch | |
$replaceOne | |
$replaceAll | |
$rtrim | |
$split | |
$strLenBytes | |
$strLenCP | |
$strcasecmp | 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second.0 ;如果第一个字符串大于第二个字符串,则返回1 ;如果第一条字符串小于第二个,则返回-1 。 |
$substr | $substrBytes or $substrCP .$substrBytes 或$substrCP 。 |
$substrBytes | |
$substrCP | |
$toLower | |
$toString | |
$trim | |
$toUpper |
Text Expression Operator文本表达式运算符
$meta |
Trigonometry Expression Operators三角表达式运算符
Trigonometry expressions perform trigonometric operations on numbers. 三角表达式对数字执行三角运算。Values that represent angles are always input or output in radians.表示角度的值始终以弧度为单位输入或输出。 Use 使用$degreesToRadians
and $radiansToDegrees
to convert between degree and radian measurements.$degreesToRadians
和$radiansToDegrees
在度数和弧度测量之间转换。
$sin | |
$cos | |
$tan | |
$asin | |
$acos | |
$atan | |
$atan2 | y / x in radians, where y and x are the first and second values passed to the expression respectively.y/x 的反正切(反正切),其中y 和x 分别是传递给表达式的第一个值和第二个值。 |
$asinh | |
$acosh | |
$atanh | |
$sinh | |
$cosh | |
$tanh | |
$degreesToRadians | |
$radiansToDegrees |
Type Expression Operators类型表达式运算符
$convert | |
$isNumber | true if the specified expression resolves to an integer , decimal , double , or long .integer 、decimal 、double 或long ,则返回布尔值true 。false if the expression resolves to any other BSON type, null , or a missing field. null 或缺少字段,则返回布尔值false 。 |
$toBool | boolean 。 |
$toDate | Date 。 |
$toDecimal | Decimal128 。 |
$toDouble | double 。 |
$toInt | integer 。 |
$toLong | long 。 |
$toObjectId | ObjectId 。 |
$toString | string 。 |
$type |
Accumulators 累加器($group, $bucket, $bucketAuto, $setWindowFields
)
Aggregation accumulator operators:聚合累加器运算符:
Maintain their state as documents progress through the aggregation pipeline.在文档通过聚合管道时维护它们的状态。Return totals, maxima, minima, and other values.返回总计、最大值、最小值和其他值。Can be used in these aggregation pipeline stages:可用于以下聚合管道阶段:$bucket
$bucketAuto
$group
$setWindowFields
starting in MongoDB 5.0 (except when you are using the从MongoDB 5.0开始(除非使用$accumulator
or$mergeObjects
operators, which cannot be used with$setWindowFields
)$accumulator
或$mergeObjects
运算符,它们不能与$setWindowFields
一起使用)
Changed in version 5.05.0版更改.
$accumulator | |
$addToSet | $setWindowFields stage. $setWindowFields 阶段中可用。 |
$avg | $setWindowFields stage. $setWindowFields 阶段中可用。 |
$bottom | Available in the $group and $setWindowFields stages. |
$bottomN | n fields within a group, according to the specified sort order. Available in the $group and $setWindowFields stages. |
$count | Distinct from the $count pipeline stage. New in version 5.0: Available in the $group and $setWindowFields stages. |
$first | $setWindowFields stage. |
$firstN | n elements within a group. $firstN array operator. $firstN 数组运算符不同。New in version 5.2: Available in the $group , expression and $setWindowFields stages. |
$last | Returns the result of an expression for the last document in a group. $setWindowFields stage. |
$lastN | Returns an aggregation of the last n elements within a group. Only meaningful when documents are in a defined order. Distinct from the $lastN array operator. New in version 5.2: Available in the $group , expression and $setWindowFields stages. |
$max | Returns the highest expression value for each group. $setWindowFields stage. |
$maxN | Returns an aggregation of the n maximum valued elements in a group. Distinct from the $maxN array operator. Available in $group , $setWindowFields and as an expression. |
$median | Returns an approximation of the median, the 50th percentile, as a scalar value. |
$mergeObjects | |
$min | $setWindowFields stage. |
$percentile | |
$push | Returns an array of expression values for documents in each group. $setWindowFields stage. |
$stdDevPop | Returns the population standard deviation of the input values. $setWindowFields stage. |
$stdDevSamp | Returns the sample standard deviation of the input values. $setWindowFields stage. |
$sum | Returns a sum of numerical values. Ignores non-numeric values. $setWindowFields stage. |
$top | Returns the top element within a group according to the specified sort order. Available in the $group and $setWindowFields stages. |
$topN | Returns an aggregation of the top n fields within a group, according to the specified sort order. Available in the $group and $setWindowFields stages. |
Accumulators (in Other Stages)蓄能器(其他阶段)
Some operators that are available as accumulators for the 一些可作为$group
stage are also available for use in other stages but not as accumulators. $group
阶段的累加器的运算符也可用于其他阶段,但不能用作累加器。When used in these other stages, these operators do not maintain their state and can take as input either a single argument or multiple arguments. For details, refer to the specific operator page.当在这些其他阶段中使用时,这些运算符不维护其状态,可以将单个参数或多个参数作为输入。有关详细信息,请参阅特定的运算符页面。
Changed in version 5.05.0版更改.
The following accumulator operators are also available in the 以下累加器运算符也可用于$project
, $addFields
, $set
, and, starting in MongoDB 5.0, the $setWindowFields
stages.$project
、$addFields
、$set
,以及从MongoDB 5.0开始的$setWindowFields
阶段。
$avg | |
$first | |
$last | Returns the result of an expression for the last document in a group. |
$max | Returns the maximum of the specified expression or list of expressions for each document |
$median | Returns an approximation of the median, the 50th percentile, as a scalar value. |
$min | |
$percentile | |
$stdDevPop | |
$stdDevSamp | |
$sum |
Variable Expression Operators变量表达式运算符
$let |
Window Operators窗口运算符
New in version 5.0.5.0版新增。
Window operators return values from a defined span of documents from a collection, known as a window. 窗口运算符从集合中定义的文档范围(称为窗口)中返回值。A window is defined in the 窗口是在$setWindowFields
stage, available starting in MongoDB 5.0.$setWindowFields
阶段定义的,从MongoDB 5.0开始就可以使用。
The following window operators are available in the 以下窗口运算符在$setWindowFields
stage.$setWindowFields
阶段中可用。
$addToSet | Returns an array of all unique values that results from applying an expression to each document. $setWindowFields stage. |
$avg | Returns the average for the specified expression. Ignores non-numeric values. $setWindowFields stage. |
$bottom | Returns the bottom element within a group according to the specified sort order. Available in the $group and $setWindowFields stages. |
$bottomN | Returns an aggregation of the bottom n fields within a group, according to the specified sort order. Available in the $group and $setWindowFields stages. |
$count | Returns the number of documents in the group or window. Distinct from the $count pipeline stage. |
$covariancePop | Returns the population covariance of two numeric expressions. |
$covarianceSamp | Returns the sample covariance of two numeric expressions. |
$denseRank | Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. There are no gaps in the ranks. Ties receive the same rank. |
$derivative | Returns the average rate of change within the specified window. |
$documentNumber | Returns the position of a document (known as the document number) in the $setWindowFields stage partition. Ties result in different adjacent document numbers. |
$expMovingAvg | Returns the exponential moving average for the numeric expression. |
$first | Returns the result of an expression for the first document in a group or window. $setWindowFields stage. |
$integral | Returns the approximation of the area under a curve. |
$last | Returns the result of an expression for the last document in a group or window. $setWindowFields stage. |
$linearFill | Fills null and missing fields in a window using linear interpolationAvailable in the $setWindowFields stage. |
$locf | Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field.Available in the $setWindowFields stage. |
$max | Returns the maximum value that results from applying an expression to each document. $setWindowFields stage. |
$min | Returns the minimum value that results from applying an expression to each document. $setWindowFields stage. |
$minN | Returns an aggregation of the n minimum valued elements in a group. Distinct from the $minN array operator. Available in $group , $setWindowFields and as an expression. |
$push | Returns an array of values that result from applying an expression to each document. $setWindowFields stage. |
$rank | Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. |
$shift | Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition. |
$stdDevPop | Returns the population standard deviation that results from applying a numeric expression to each document. $setWindowFields stage. |
$stdDevSamp | Returns the sample standard deviation that results from applying a numeric expression to each document. $setWindowFields stage. |
$sum | Returns the sum that results from applying a numeric expression to each document. $setWindowFields stage. |
$top | Returns the top element within a group according to the specified sort order. Available in the $group and $setWindowFields stages. |
$topN | Returns an aggregation of the top n fields within a group, according to the specified sort order. Available in the $group and $setWindowFields stages. |