<!-- llms-explorer concept facts · https://llms-explorer.com/tree/aggregation-expressions/ · pack 2026-10-02 · ~12611 tokens -->

# Aggregation Expressions

> Depth-first rabbithole dossier for Aggregation Expressions; source-anchored research pack.

Parent: [MongoDB Aggregation Pipeline](https://llms-explorer.com/tree/mongodb-aggregation-pipeline/) · 7 facets · 72 facts · page: https://llms-explorer.com/tree/aggregation-expressions/

## Structure and components

- 19. Boolean expressions treat `false`, `null`, `0` and `undefined` as false. Everything else is true, including **arrays that contain only falsy values** and the empty string. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ 20. `{ $and: [] }` is `true` and `{ $or: [] }` is `false`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ ; https://www.mongodb.com/docs/manual/reference/operator/aggregation/or.md 21. `$convert`/`$toBool` converts **every** string to `true`, including `"false"` and `""`. — https://www.mongodb.com/docs/manual/reference/op — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#c-truthiness`
- 1. An expression is an MQL component that resolves to a value and does not modify its inputs. — https://www.mongodb.com/docs/manual/reference/mql/expressions/ 2. Expressions appear in some stages (`$project`, `$addFields`, `$group`), in query predicates through `$expr`, and in find-command projections. — https://www.mongodb.com/docs/manual/reference/mql/expressions/ 3. An operator expression has the form `{ <operator>: [ <arg1>, <arg2>, ... ] }`. If the operator takes one argument, you may omit the outer array. — https://www.mongodb.com/docs/manual/reference/mql/expressions/ 4. A field path is — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#definition-and-anatomy`
- 8. A user variable name may contain `[_a-zA-[ticket identifier redacted by repository privacy gate]]` and non-ASCII characters. It must start with a lowercase ASCII letter or a non-ASCII character. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 9. `$$NOW` and `$$CLUSTER_TIME` have the same value on every member of the deployment and stay constant for all stages of one pipeline. `$$CLUSTER_TIME` exists only on replica sets and sharded clusters. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 10. `$$CURRENT` starts equal to `$$ROOT` and can be changed. Changing it changes what a bare `$field` path r — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#variables-and-scope`

## How it works

- https://www.mongodb.com/docs/manual/reference/operator/query/expr/ [M59, E52, P25] 97. [ticket identifier redacted by repository privacy gate] ("$expr does not use multikey index") was closed as *Works as Designed*. A query's plan changes once any document makes the index multikey. MongoDB Jira issue (identifier redacted by repository privacy gate) [P27, E51] 98. From 8.1.0-rc0, `$expr` with `$in` can use non-multikey indexes ([ticket identifier redacted by repository privacy gate]). The restriction exists because aggregation `$in` behaves differently from query `$in` on arrays. MongoDB Jira issue (identifier redacted by repository privacy gate) [M60] 99. Metabase generated every filter as `$match`+`$expr` and hit COLLSCAN — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#i-expr-and-indexes`
- **Left out as inherited from the parent:** "`$expr` unlocks aggregation operators in `$match`", the `$cond`/`$switch` section, the pipeline-optimization page (mechanism report claim 54), and the `$accumulator` page (history report claim 38). The last two are shared-cache sources. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md`
- 13. Before the aggregation framework existed, MongoDB 1.2 (December 2009) added an embedded JavaScript engine and a server-side Map-Reduce API for aggregation. https://www.practical-mongodb-aggregations.com/intro/history.html 14. MongoDB 2.2 introduced the aggregation framework, which runs "aggregation operations without needing to use map-reduce." https://raw.githubusercontent.com/mongodb/docs/v2.4/source/release-notes/2.2.txt 15. MongoDB 2.2 was announced on 29 August 2012. LWN described the aggregation framework as being "in its first production-ready release as of 2.2." https://lwn.net/Art — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#evolution-by-release`

## How-to and procedures

- Run date: 2026-10-02. Parent: MongoDB Aggregation Pipeline. Verdict: `BUDGET_EXHAUSTED` (soft stop after 4 passes; see the pass curve at the end). — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md`
- Run date: 2026-10-02. Parent: MongoDB Aggregation Pipeline. Objective: internal mechanism, parts, invariants, limits. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md`
- Run date: 2026-10-02. Parent: MongoDB Aggregation Pipeline. Mode: brief-constrained `/rabbithole`, one report, no tree or repo edits. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md`

## Measurements and reference values

- **Verdict: BUDGET_EXHAUSTED (soft stop).** This is not depth saturation, because the rate is still above 5%. A pass 3 would likely still pay off. It should cover: date expressions (`$dateFromString` `onError`, time zones, `$dateDiff` boundaries), `$regexMatch` and collation interaction, `$sortArray` and `$reduce` memory limits, and a live test of the `$convert` `onError`-on-input question. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#depth-pass-record`
- | Pass | Focus | New claims | Total claims | New-information rate | |---|---|---|---|---| | 0 | Current manual expressions page | 12 | 12 | 100% | | 1 | Per-release notes (2.2→9.0) | 22 | 34 | 65% | | 2 | `$function`/`$accumulator` status and conflict | 9 | 43 | 21% | | 3 | Independent hosts | 5 | 48 | 10% | — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#pass-curve`
- | Pass | Sources added | New claims | Total | New-info rate | |---|---|---|---|---| | 0 | expressions, operator index, variables, `$literal` | 22 | 22 | — | | 1 | `$let`, `$expr`, `$getField`, `expression.h` | 14 | 36 | 39% | | 2 | `$and`, `$match`, field paths, [ticket identifier redacted by repository privacy gate]/32549/34926/20166, practical book, BSON order, 5.0 notes, `bsontypes.h` | 18 | 54 | 33% | | 3 | `$reduce`, `$convert`, `$function`, `$project`, `$ifNull` | 9 | 63 | 14% | | 4 | `$cmp`, SBE, shared optimization page | 3 | 66 (60 kept after merging duplicates) | 4.5% | — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#depth-pass-curve`

## Problems, failure modes and limitations

- 42. These values are false: `false`, `null`, `0` and `undefined`. Every other value is true, including `[false]`, `[null]` and `""`. https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ [M34, H5, E19, P17] 43. `{$and:[]}` is `true` and `{$or:[]}` is `false`. https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ ; https://www.mongodb.com/docs/manual/reference/operator/aggregation/or.md [M35, E20] 44. `$and` and `$or` do not guarantee short-circuiting: a later operand "may cause an error even if the first expression evaluates to false". https://www.mongodb.co — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#e-evaluation-semantics`
- 1. An expression is an MQL component that "resolve[s] to a value without modifying their inputs." — https://www.mongodb.com/docs/manual/reference/mql/expressions/ 2. Expressions are usable in some pipeline stages (e.g. `$project`, `$addFields`, `$group`), in query predicates through `$expr`, and in find-command projections. — https://www.mongodb.com/docs/manual/reference/mql/expressions/ 3. The manual names three building blocks: constants (`3`), operators (`$add`), and field path expressions (`"$<path.to.field>"`). — https://www.mongodb.com/docs/manual/reference/mql/expressions/ 4. A second t — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#a-definition-and-components`
- 14. Aggregation comparison operators compare values across BSON types using the BSON comparison order. Query-predicate comparison operators apply type bracketing: they match only documents whose field type matches the operand type. — https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/ 15. Consequence: the same `$gt` can return different documents in a plain query and inside `$expr`. The independent guide warns about this directly. — https://www.practical-mongodb-aggregations.com/guides/expressions.html 16. In comparisons, all numeric types (int, long, double, decimal) are — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#evaluation-semantics-the-main-correctness-traps`
- 113. `$function` takes `body`, `args` and `lang:"js"`. It is not allowed in schema-validation predicates. https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ [M46, H35, E60, P30] 114. `$function` needs server-side scripting, which is on by default. You turn it off with `security.javascriptEnabled:false` or `--noscripting`, and the manual recommends turning it off when unused. https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ [H36, E59, P31] 115. The manual warns that JavaScript "may decrease performance". It prefers native `$expr` over `$wher — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#k-javascript-expressions`
- 58. Starting in MongoDB 8.0, server-side JavaScript (`$function`, `$accumulator`, `$where`) is deprecated, and the server logs a warning when these run. — https://www.mongodb.com/docs/v8.0/core/server-side-javascript/ 59. `$function` fails when the deployment disables scripting with `security.javascriptEnabled: false` or `--noscripting`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ 60. `$function` is not allowed in a schema-validation query predicate. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ 61. MongoDB 6.0 moved the engin — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#h-javascript-expressions-function`
- 35. `$function` takes `body`, `args`, and `lang`, and `lang` must be `"js"`. You cannot use `$function` in a schema-validation query predicate. https://www.mongodb.com/docs/manual/reference/operator/aggregation/function.md 36. Both `$function` and `$accumulator` need server-side scripting enabled. Server-side scripting is on by default, and you turn it off with `security.javascriptEnabled` or `--noscripting`. https://www.mongodb.com/docs/manual/reference/operator/aggregation/function.md 37. The manual says `$expr` with native (non-JavaScript) operators "is faster than `$where`" and should be p — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#custom-javascript-expressions-function-accumulator`
- 1. An expression is an MQL component that resolves to a value without modifying its inputs. https://www.mongodb.com/docs/manual/reference/mql/expressions/ [M1, H1, P1] 2. Expressions are used in some stages (`$project`, `$addFields`, `$group`), in query predicates through `$expr`, and in find-command projections. https://www.mongodb.com/docs/manual/reference/mql/expressions/ [M2, H2, P2] 3. The manual names three components: constants, operators and field paths. https://www.mongodb.com/docs/manual/reference/mql/expressions/ [M3, H3] 4. The Practical guide names three different kinds: operators — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#a-definition-and-anatomy`
- 62. On overflow, `$add` promotes int to long and long to double. If the widest type is double or decimal, the result is ±Infinity. `$sum` follows the same rules. https://www.mongodb.com/docs/manual/reference/operator/aggregation/add.md ; https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ [E22, E23] 63. `$add` with a Date is left-associative and rounds each running partial sum. `[1.5,1.6,"$date",1.5,1.5]` adds 7 ms, not 6.1 ms. https://www.mongodb.com/docs/manual/reference/operator/aggregation/add.md [E24] 64. `$add` accepts at most one Date. https://www.mongodb.com/docs/ma — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#f-numerics-and-conversion`
- 1. MongoDB parses any string that starts with `$` as a field path. To use a literal string that starts with `$`, wrap it in `$literal`, for example `{ $eq: ["$price", { $literal: "$1" }] }`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ 2. `$literal` returns its argument unparsed, even when the argument is itself an operator: `{ $literal: { $add: [2, 3] } }` → `{ "$add": [2, 3] }`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ 3. In `$project`, `field: 1` means *include*. To create a new field whose value is the number 1, you must — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#a-parsing-and-syntax-boundaries`
- 22. If `$add` overflows its widest input type, the result is promoted: int → long and long → double. If the widest type is double or decimal, the result becomes ±Infinity with no promotion. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/add.md 23. `$sum` follows the same overflow and promotion rules. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ 24. `$add` with a Date is left-associative. It rounds each running numeric partial sum before adding it to the date. `$add: [1.5, 1.6, "$date", 1.5, 1.5]` adds 7 ms, not 6.1 ms. — https://www.mongodb.co — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#d-numeric-types-overflow-rounding`
- - **Does dividing by zero error or return null?** The MongoDB server source (claim 34) and [ticket identifier redacted by repository privacy gate] (claim 37) say it **errors**. Bobcares (2024-09-21) says "MongoDB doesn't throw an error for division by zero, but it will return null": https://bobcares.com/blog/mongodb-aggregate-divide/ — The primary source wins for numeric zero. The third-party claim is wrong. It may come from confusing this case with a *null* divisor, which does return null (claim 36). - **Is JavaScript really slower than native operators?** The docs say JavaScript execution "may decrease performance" and push users to n — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#unresolved-disagreements-and-gaps`
- - https://www.mongodb.com/docs/manual/reference/mql/expressions/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/getfield/ - https://www.mongodb.com/docs/manual/reference/aggregation-variables/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/size.md - https://www.mongodb.com/docs/manual/reference/operator/aggregation/ro — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#sources`
- 44. The Practical MongoDB Aggregations guide groups expressions into three kinds: operators (`$` prefix on an object key), field paths (a `$`-prefixed string), and variables (a `$$`-prefixed string). It splits variables into context system variables, marker-flag system variables, and bound user variables. https://www.practical-mongodb-aggregations.com/guides/expressions.html 45. The same guide says `$match`, `$limit`, `$skip`, `$sort`, `$count`, `$lookup`, and `$out` do not take expressions. It says `$expr` (added in 3.6) is the way to use expressions inside `$match`. https://www.practical-mon — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#independent-views`
- - https://www.mongodb.com/docs/manual/reference/mql/expressions.md — current Expressions reference (primary) - https://www.mongodb.com/docs/manual/reference/operator/aggregation/function.md — `$function` (primary) - https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/ — `$accumulator` (primary; shared cache) - https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/function/ — v8.0 deprecation notice (primary) - https://www.mongodb.com/docs/manual/core/server-side-javascript.md — current server-side JS page (primary) - https://www.mongodb.com/docs/manual/rel — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#sources`
- 21. Every variable is read with a `$$` prefix (`$$<var>`, or `$$<var>.<field>`). — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 22. A user variable name uses `[_a-zA-[ticket identifier redacted by repository privacy gate]]` plus any non-ASCII character. It must begin with a lowercase ASCII letter or a non-ASCII character. This rule means user names cannot collide with the uppercase system variables. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 23. `$$ROOT` is the top-level document the stage is processing. `$$CURRENT` is the start of field-path resolution. It equals `$$ROOT` unless a stage docu — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#d-variables-binding-scoping`
- **In scope:** what an aggregation expression is and how it is built: field paths, literals, variables, operator expressions. Also covered: evaluation semantics (type comparison, null/missing, truthiness, error behavior), `$expr` as the bridge into query predicates, type conversion, custom JavaScript expressions, and the operational trade-offs of each. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#scope`
- - https://www.mongodb.com/docs/manual/reference/mql/expressions/ - https://www.mongodb.com/docs/manual/reference/aggregation-variables/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/ - https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ - https: — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#sources`
- **Scope.** In scope: what an expression is, literals and parsing, field paths, variables, evaluation semantics, numerics, error behaviour, the server lifecycle, how `$expr` connects to indexes, the history of operators, and JavaScript expressions. Out of scope: stages, window functions, `$densify`/`$fill`, time series and Atlas Search. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md`
- 20. `"$a.b"` is shorthand for `"$$CURRENT.a.b"`. https://www.mongodb.com/docs/manual/reference/aggregation-variables/ [M14, E9] 21. If a dotted path crosses an array of subdocuments, it returns an array of values: `"$instock.warehouse"` returns `["A","C"]`. https://www.mongodb.com/docs/manual/core/field-paths/ [M15] 22. If a path crosses nested arrays, it returns nested arrays. The result is not flattened. https://www.mongodb.com/docs/manual/core/field-paths/ [M16] 23. A field path cannot reach a field name that contains `.` or starts with `$`. `$getField`, `$setField` and `$unsetField` (all 5 — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#c-field-paths`
- 27. Variables are read as `$$var` or `$$var.field`. https://www.mongodb.com/docs/manual/reference/aggregation-variables/ [M21] 28. User variable names use `[_a-zA-[ticket identifier redacted by repository privacy gate]]` plus non-ASCII characters. They must start with a lowercase ASCII letter or a non-ASCII character, so `$$Foo` is illegal. This rule stops them colliding with the uppercase system variables. https://www.mongodb.com/docs/manual/reference/aggregation-variables/ [M22, E8, P8] 29. `$$ROOT` is the top-level document. `$$CURRENT` is where field-path resolution starts, and it equals `$$ROOT` unless the stage says otherwise. Rebinding — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#d-variables-and-scope`
- 73. `$divide` raises `BadValue "can't $divide by zero"` when the divisor is a numeric zero. https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/exec/expression/evaluate_math.cpp [E34] 74. `$mod` by zero raises error code 16610 for doubles and 5733415 for decimals. https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/exec/expression/evaluate_math.cpp [E35] 75. If either operand is null or missing, `$divide` and `$mod` return null and raise no zero error. https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/exec/expression/evaluate_math.cpp [E36] 76. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#g-errors`
- Next passes most likely to add new facts: 1. Per-operator null/error tables for date, string and arithmetic operators. 2. Date expressions: time zones, `$dateFromString` `onError`, and `$dateDiff` boundaries. 3. Memory limits in `$sortArray` and `$reduce`. 4. Live tests to settle D1, D4, D5 and D6. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#saturation`
- 34. `$divide` raises `BadValue: "can't $divide by zero"` when both operands are numeric and the divisor is zero (double `0.0` or decimal zero). — https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/exec/expression/evaluate_math.cpp 35. `$mod` raises `"can't $mod by zero"` with code 16610 for doubles and 5733415 for decimals. — https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/exec/expression/evaluate_math.cpp 36. The null check sits in the non-numeric branch. If either operand of `$divide` or `$mod` is null or missing, the result is `null` and no zero-divisor — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#e-errors-what-raises-them-and-what-catches-them`
- 55. `$$NOW` and `$$CLUSTER_TIME` stay fixed for the whole aggregation and are the same on every member. `$$NOW` therefore cannot measure elapsed time between stages. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 56. `$$CLUSTER_TIME` exists only on replica sets and sharded clusters. It is unavailable on a standalone. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 57. `$$USER_ROLES` (7.0+) is not supported on Atlas M0 or Flex clusters. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#g-variables-and-time`
- 1. The manual defines expressions as "MQL (MongoDB Query Language) components that resolve to a value without modifying their inputs." https://www.mongodb.com/docs/manual/reference/mql/expressions.md 2. Expressions appear in three places: some pipeline stages (`$project`, `$addFields`, `$group`), query predicates that use `$expr`, and find-command projections. https://www.mongodb.com/docs/manual/reference/mql/expressions.md 3. The manual names three building blocks: constants (`3`), operators (`$add`), and field path expressions (`"$<path.to.field>"`). https://www.mongodb.com/docs/manual/refer — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#definition-and-anatomy-current-manual`
- IN: what an aggregation expression is, and its building blocks (constants, field paths, variables, operator objects). Also argument syntax, `$literal`, variable binding and scoping (`$let`, `$$CURRENT`/`$$ROOT`, iterator variables), and evaluation semantics (truthiness, null/missing, cross-type comparison, error handling). Also the server's parse/optimize/evaluate lifecycle, and the bridge into query predicates via `$expr`, including its index limits. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#scope`
- 14. `"$a.b"` is shorthand for `"$$CURRENT.a.b"`. — https://www.mongodb.com/docs/manual/reference/aggregation-variables/ 15. If a dotted field path crosses an array of embedded documents, it returns an array of the nested values. For example, `instock: [{warehouse:"A"},{warehouse:"C"}]` gives `"$instock.warehouse"` → `["A","C"]`. — https://www.mongodb.com/docs/manual/core/field-paths/ 16. If the path crosses nested arrays, the result is an array of nested arrays. The result is not flattened. — https://www.mongodb.com/docs/manual/core/field-paths/ 17. Field paths cannot address field names that — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#c-field-path-resolution`
- 34. Boolean contexts treat `false`, `null`, `0` and `undefined` as false. Every other value is true, including arrays such as `[false]` and `[null]`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ 35. `{ $and: [] }` evaluates to `true`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ 36. Short-circuiting is not guaranteed. An operand of `$and` after the first one "may cause an error even if the first expression evaluates to `false`". A guard such as `$and: [ {$ne:["$d",0]}, {$gt:[{$divide:["$n","$d"]},1]} ]` is therefore not safe. — https:// — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#e-evaluation-semantics`
- 21. `$convert` takes `input` and `to`, plus optional `onError`, `onNull`, `format` and `base`. If you omit `onError`, a failed conversion makes the whole operation fail. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ 22. The shorthand operators (`$toInt`, `$toDecimal`, `$toDate`, `$toUUID` and others) have no `onError`. They raise an error when conversion fails. Use them only on data that is already clean. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ 23. The `$convert` feature set depends on the version. Numeric-to-binData arrived — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#type-conversion`
- 37. Check null/missing propagation for each operator, and wrap sparse fields in `$ifNull` or `$convert` with `onNull` (claims 11, 19, 21). 38. Check whether a comparison mixes types. Aggregation's cross-type ordering can match documents that a plain query would skip (claims 14–16). 39. Check whether any error-prone sub-expression relies on `$and` to guard it (claim 18). 40. Check whether a `$expr` predicate could be rewritten as plain MQL to use an index, especially on multikey fields (claims 25–28). 41. Check whether JavaScript (`$function`/`$accumulator`) is present, and what the target serv — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#evaluation-checklist-how-to-assess-an-expression-in-review`

## Comparisons and alternatives

- **In scope:** what MongoDB aggregation expressions (operators, field paths, variables) do at their limits. This covers missing and null input, type coercion and overflow, error semantics, evaluation order, parsing ambiguity, and the expression-versus-query-predicate boundary that `$expr` creates. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#scope`
- 47. Aggregation-expression comparisons work across BSON types using the total BSON order (Null < Numbers < String < Object < Array < … < Date …). Query-predicate comparisons apply *type bracketing*. — https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/ 48. As a result, `{ $expr: { $gt: ["$a", 5] } }` matches documents where `a` is a string, an object or a date, because those types sort above numbers. `{ a: { $gt: 5 } }` does not match them. (This is an inference from claim 47's BSON order.) — https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/ 49. Al — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#f-comparison-semantics-expressions-vs-query-predicates`
- 30. `$function` runs a JavaScript `body` with `args` and requires `lang: "js"`. The manual warns that JavaScript inside an expression "may decrease performance". Use it only when the built-in operators cannot do the job. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ 31. `$function` needs server-side scripting enabled, which is the default. The manual recommends disabling scripting (`security.javascriptEnabled: false` / `--noscripting`) if you use none of `$function`, `$accumulator`, `$where` or mapReduce. You cannot use `$function` in a schema-validation query — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#custom-javascript-expressions-function`
- | # | Topic | Side A | Side B | Status | |---|---|---|---|---| | D1 | Is missing equal to null in comparisons? | The BSON order page says a missing field "is treated as null in comparisons and sorts". https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/ | The source ranks missing (0) below null (5), and `$eq:["$a",null]` is false for a missing `a`. https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/bson/bsontypes.h , MongoDB Jira issue (identifier redacted by repository privacy gate) | Open. The ticket was closed as Duplicate in 2015 with no fix. Likely reading: sort keys treat mis — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#disagreements-both-sides-kept`
- Source: https://raw.githubusercontent.com/mongodb/docs/v4.2/source/release-notes/4.2.txt 23. MongoDB 4.4 added `$function` ("Defines a custom aggregation expression") and `$accumulator`. The release notes say these let you write custom JavaScript expressions "instead of relying on mapReduce and $where." https://raw.githubusercontent.com/mongodb/docs/v4.4/source/release-notes/4.4.txt 24. MongoDB 4.4 also added the array expressions `$first` and `$last`, plus `$binarySize`, `$bsonSize`, `$isNumber`, `$replaceOne`, and `$replaceAll`. https://raw.githubusercontent.com/mongodb/docs/v4.4/source/rele — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#evolution-by-release`
- - **Is server-side JavaScript in expressions still deprecated?** The v8.0 manual says `$function`, `$accumulator`, and `$where` are deprecated starting in 8.0 (https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/function/), and MongoDB staff confirmed it in 2024 (https://www.mongodb.com/community/forums/t/why-is-function-deprecated-in-mongod-8-0/291213). The current (9.0) manual has no deprecation notice on the `$function` page or the server-side JavaScript page. Those pages still say scripting is enabled by default (https://www.mongodb.com/docs/manual/core/server-side-javascript. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#unresolved-disagreements`
- 1. **Missing vs null in comparisons.** The BSON comparison-order page says "a non-existent field is treated as `null` in comparisons and sorts" (https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/). The server source ranks *missing* (0) below `null` (5) (https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/bson/bsontypes.h), and [ticket identifier redacted by repository privacy gate] shows `$eq: ["$a", null]` returning false for a missing `a` (MongoDB Jira issue (identifier redacted by repository privacy gate)). The likely reconciliation is that sort keys collapse missing to null while expression value comparison does not. N — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#unresolved-disagreements-both-sides-kept`
- 10. `$concat` returns `null` if any argument is null or refers to a missing field. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/ 11. `$substrBytes` returns an **empty string** `""`, not null, when its string argument is null or missing. This is the opposite of `$concat`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/ 12. `$size` **errors** when its argument is missing or not an array. It does not return null. The docs guard it with `$cond` + `$isArray`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/size.md — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#b-null-and-missing-input-no-uniform-rule`
- 56. Before 5.0 (reported on 4.0.8/4.0.9), `$expr` in `$match` produced an IXSCAN only for `$eq`. `$gt`, `$gte`, `$lt`, `$lte` and `$indexOfCP` produced COLLSCAN. — MongoDB Jira issue (identifier redacted by repository privacy gate) 57. The obstacle is type bracketing. `{$and:[{$gte:["$x",0]},{$lt:["$x",100]}]}` cannot simply be rewritten as `{x:{$gte:0,$lt:100}}`, because aggregation comparison crosses types (claim 37). — MongoDB Jira issue (identifier redacted by repository privacy gate) 58. The 5.0 release notes say `$eq`, `$lt`, `$lte`, `$gt` and `$gte` placed in `$expr` "can use indexes to improve performance". — https://www.mongodb.c — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#g-expr-index-limits`
- - Sources: 4 distinct hosts and 18 pages: www.mongodb.com (manual plus v5.0 release notes), jira.mongodb.org, raw.githubusercontent.com (mongodb/mongo source), and www.practical-mongodb-aggregations.com. - Independence caveat: all four hosts are MongoDB-owned or MongoDB-authored (the Practical Aggregations book is by a MongoDB employee). They are independent *evidence types*: documentation, bug tracker, source code and practitioner guide. They are not independent organisations. - Disconfirmation: done. The source code and the Jira tickets contradict the docs on missing-vs-null, and the release — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#quality-gate`
- 24. `$expr` uses expressions to filter documents only. The returned documents are unchanged; computed values are not written into the results. — https://www.mongodb.com/docs/manual/reference/operator/query/expr/ 25. In a `$lookup` sub-pipeline, `$eq`, `$lt`, `$lte`, `$gt` and `$gte` inside `$expr` can use an index on the `from` collection. This works only when the comparison is field-vs-constant (the `let` value resolves to a constant). It does not work for field-vs-field comparisons or for empty/missing `let` values. Multikey, partial and sparse indexes are never used. — https://www.mongodb.c — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#expr-expressions-in-query-predicates-and-index-behavior`
- - **Is server-side JavaScript deprecated?** Yes, according to the v8.0 manual (claim 34). No, according to the 9.0 release notes (claim 35). The current-manual `$function` page has no deprecation banner. All three sources are correct for their version. The answer depends on the server version, so a review must pin the version. A community thread asked why 8.0 deprecated `$function`: https://www.mongodb.com/community/forums/t/why-is-function-deprecated-in-mongod-8-0/291213 - **Which stages "accept expressions"?** The independent guide lists `$lookup` among stages that do not take expressions. H — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#unresolved-disagreements`

## Facts and statements

- Source: https://raw.githubusercontent.com/mongodb/docs/v3.4/source/release-notes/3.4.txt 19. MongoDB 3.6 added `$expr`, which "allows the use of aggregation expressions within the query language." This let expressions be used outside the pipeline for the first time. https://raw.githubusercontent.com/mongodb/docs/v3.6/source/release-notes/3.6.txt 20. MongoDB 3.6 also added the `$$REMOVE` variable for conditionally excluding a field. It also added `$arrayToObject`, `$objectToArray`, `$mergeObjects`, `$dateFromString`, `$dateFromParts`, and `$dateToParts`, plus time-zone support for the date oper — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#evolution-by-release`
- 101. In 1.2 (December 2009), aggregation meant embedded JavaScript and map-reduce. https://www.practical-mongodb-aggregations.com/intro/history.html [H13] 102. 2.2 introduced the aggregation framework, as a way to aggregate without map-reduce. https://raw.githubusercontent.com/mongodb/docs/v2.4/source/release-notes/2.2.txt [H14] 103. LWN reported 2.2 on 2012-08-29 and called it the framework's "first production-ready release". https://lwn.net/Articles/514162/ [H15] 104. 2.6 added the set operators, `$let`, `$map`, `$literal` and `$size`, and let `$cond` take object or array form. https://raw.g — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#j-history`
- https://raw.githubusercontent.com/mongodb/docs/v4.4/source/release-notes/4.4.txt [H23, H24] 110. 5.0 added `$dateAdd`, `$dateDiff`, `$dateSubtract`, `$dateTrunc`, the field operators, `$rand`, `$sampleRate` and the `let` option. https://raw.githubusercontent.com/mongodb/docs/v5.0/source/release-notes/5.0.txt [H25, H26] 111. Later additions by version (https://www.mongodb.com/docs/manual/reference/mql/expressions.md ; https://www.mongodb.com/docs/manual/release-notes/8.0.md ; https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ ; https://www.mongodb.com/docs/manual/releas — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#j-history`
- MongoDB manual (primary): - https://www.mongodb.com/docs/manual/reference/mql/expressions/ (also its `.md` twin) - https://www.mongodb.com/docs/manual/reference/operator/aggregation/ - https://www.mongodb.com/docs/manual/reference/aggregation-variables/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/getfield/ - https://www.mongodb.com/docs/manua — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#sources-deduplicated-inherited-shared-cache-pages-left-out`
- In scope: what a MongoDB aggregation expression is, how the set of expression operators grew from release to release, the custom JavaScript expressions (`$function`, `$accumulator`), and the primary sources for each fact. Out of scope: pipeline stages (`$group`, `$lookup`, `$setWindowFields` as stages), query-predicate operators, Atlas Search, and stream processing. Those belong to sibling frontier items. Window operators appear only where they are also expressions. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#scope`
- - https://www.mongodb.com/docs/manual/reference/mql/expressions/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/ - https://www.mongodb.com/docs/manual/reference/aggregation-variables/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/ - https://www.mongodb.com/docs/manual/reference/operator/query/expr/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/ - https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ - https://www.mongod — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#sources`
- 15. Inside an expression, any string that starts with `$` is parsed as a field path. https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ [M9, E1, P5] 16. `$literal` returns its argument without parsing it. `{$literal:{$add:[2,3]}}` returns `{"$add":[2,3]}`, and `{$literal:{$literal:1}}` returns `{"$literal":1}`. https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ [M10, E2] 17. To compare against the string `"$1"`, write `{$eq:["$price",{$literal:"$1"}]}`. https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ [M11, E1] 18. In — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#b-literals-and-parsing`
- https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/ [M19, E14] 26. Before 7.2, the `field` argument of `$getField` had to be a constant string. From 7.2, it can be any expression that resolves to a string. https://www.mongodb.com/docs/manual/reference/operator/aggregation/getfield/ [M19, E7] — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#c-field-paths`
- https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ [E16] — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#e-evaluation-semantics`
- **Handoffs for concept-family-explorer:** - index planning for `$expr` and `$lookup` sub-pipelines - reading explain plans for `$expr` - how SBE lowers expressions - null/missing semantics across MQL - `$redact` - the server-side JavaScript lifecycle (`$where`, mapReduce, WASM sandboxing) - command-level `let` - pipeline-style updates - Decimal128 arithmetic - date expressions and time zones - collation in expression comparisons - Queryable Encryption string operators - vector-similarity expressions - schema validation with `$expr` - accumulators in `$group` — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#saturation`
- Versioned manuals and release notes (primary): - https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/function/ - https://www.mongodb.com/docs/v8.0/core/server-side-javascript/ - https://www.mongodb.com/docs/v5.0/release-notes/5.0.md - https://www.mongodb.com/docs/manual/release-notes/8.0.md - https://www.mongodb.com/docs/manual/release-notes/9.0/ - https://www.mongodb.com/docs/manual/release-notes/9.0-compatibility.md - https://raw.githubusercontent.com/mongodb/docs/v2.4/source/release-notes/2.2.txt - https://raw.githubusercontent.com/mongodb/docs/v2.6/source/release-notes/2.6.txt — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#sources-deduplicated-inherited-shared-cache-pages-left-out`
- Not counted: - https://www.practical-mongodb-aggregations.com/guides/expressions.html (independence disputed, D10) - https://www.practical-mongodb-aggregations.com/intro/history.html (same site) - https://bobcares.com/blog/mongodb-aggregate-divide/ (refuted, D8) — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/rabbithole-synthesis.md#sources-deduplicated-inherited-shared-cache-pages-left-out`
- Researched 2026-10-02 · /rabbithole depth run · parent: MongoDB Aggregation Pipeline — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md`
- **Handoffs for concept-family-explorer:** `$expr` index planning, Decimal128 arithmetic, date expressions and time zones, server-side JavaScript deprecation and migration, and collation in expression comparison. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/edge-cases.md#depth-pass-record`
- - `$expr` and index use (query-side sibling) - System variables (`$$ROOT`, `$$CURRENT`, `$$NOW`, `$$REMOVE`, `$$USER_ROLES`) - Server-side JavaScript deprecation lifecycle (`$where`, mapReduce) - Pipeline-style updates (4.2) - Queryable Encryption string operators - Vector similarity expressions — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/history.md#handoffs-for-concept-family-explorer-not-researched-here`
- OUT: individual stages (`$group`, `$lookup`, `$setWindowFields`, `$densify`, `$fill`), pipeline-level reordering, `$accumulator`, time series, Atlas Search, and operator-by-operator catalogues. These belong to the parent or to sibling frontier items. Inherited parent claims are not repeated here (e.g. "`$expr` unlocks aggregation operators inside `$match`" and the `$cond`/`$switch` section). — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#scope`
- 9. Inside an expression, any string that begins with `$` is parsed as a field path. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ 10. `$literal` returns its value unparsed. `{ $literal: { $add: [2, 3] } }` yields the document `{ "$add": [2, 3] }`, and `{ $literal: { $literal: 1 } }` yields `{ "$literal": 1 }`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ 11. To compare against the string `"$1"`, the string must be wrapped: `{ $eq: ["$price", { $literal: "$1" }] }`. — https://www.mongodb.com/docs/manual/reference/operator/aggregat — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/mechanism.md#b-literals-and-the-parsing-hazard`
- **Out of scope:** individual pipeline stages, window functions, `$densify`/`$fill`, time-series collections, and general pipeline optimization. These are sibling or parent frontier items. Inherited parent claims are not repeated as new findings; for example, the parent already states that `$expr` unlocks aggregation operators inside `$match`. — source: `~/.global-ai-hub/research-tests/mongodb-full-frontier-20261002/full-frontier-run/aggregation-expressions-8f0bbcd049/reports/practice.md#scope`

## Related concepts

- Aggregation — is a part of Aggregation Expressions
- Expressions — is a part of Aggregation Expressions
