For AI agents: the complete documentation index is available at https://silt-db.dev/llms.txt, the full documentation bundle is available at https://silt-db.dev/llms-full.txt, and this page is available as Markdown at https://silt-db.dev/reference/pipeline.md.

Pipeline stages and accumulators

Use the MongoDB aggregation stage reference for syntax and examples. This inventory lists Silt's 20 stage names and 18 group accumulator names, with supported operand forms and restrictions. Shared data and API limits are in MongoDB compatibility.

Implemented stages

Stage namesSupported forms and relevant limits
$matchSupports query predicates, including $expr.
$projectInclusion/exclusion with Mongo _id exception; expression fields; dotted paths; nested array traversal and reconstruction. Missing inclusion fields are omitted; non-object array elements are omitted for nested inclusion, and preserved/replaced as appropriate for computed projection. Conflicting paths and mixed modes fail. Positional find projection is not implemented.
$set, $addFieldsAll assigned expressions see the original input document. Dotted assignment traverses arbitrarily nested arrays and replaces scalar ancestors with objects, as aggregation does. This is distinct from update-operator $set semantics.
$unsetOne field name or a nonempty list; dotted exclusions traverse nested arrays.
$replaceRoot, $replaceWithReplacement must evaluate to an object; missing/scalar/array replacements fail in SQLite.
$sortNumeric directions 1 and -1; mixed JSON type ordering, ordered objects, lexicographic nested arrays, ascending array minimum and descending maximum, empty-array ordering. Sorting on more than one array-valued path in one document fails explicitly: correlated compound multikey sort keys are not yet supported. $meta and collation are unsupported.
$limit, $skipLiteral safe integers: positive limit and nonnegative skip. Order is explicitly carried between stages.
$countA nonempty simple output field; empty input emits no document, matching MongoDB.
$unwindString or object form; preserveNullAndEmptyArrays, includeArrayIndex; scalar input as singleton; distinction between missing, null, and empty arrays.
$groupExpression group key, including objects/arrays and missing-to-null keys. Deep numeric equality and field-order-sensitive object identity use the common SQL comparator/key representation. Accumulators listed below.
$sortByCountLowers into grouping and descending count sort.
$lookupEquality local/foreign fields; scalar-array and array-array membership; missing/null matches; duplicate join-key suppression; correlated/uncorrelated pipelines; let/$expr; nested lexical variables; equality followed by optional foreign pipeline; per-local-document foreign sort/limit/group/project; dotted as overwrites conflicting ancestors. A from-less pipeline can begin with literal $documents. Only stages/expressions implemented by this compiler are available in its pipeline.
$facetMultiple subpipelines over materialized shared input, including empty-input result arrays. Rejects nested $facet and prohibited administrative/write stages. Does not enforce MongoDB's exact facet/result byte limits.
$unionWithString collection or {coll,pipeline}; a collection-less pipeline may begin with literal $documents. Uses UNION ALL.
$documentsLiteral array of JSON objects; first stage only. Dynamic expression form is not implemented.
$sampleLiteral nonnegative safe integer size; SQL random order without replacement. Does not emulate MongoDB's exact random distribution/algorithm or seed behavior.
$bucketIncreasing homogeneous number or string boundaries, optional default outside the boundary interval, optional supported group accumulators. Lower boundary inclusive, upper exclusive. Other boundary types fail explicitly.

These count aliases separately because they are distinct accepted Mongo stage names: $set/$addFields and $replaceRoot/$replaceWith.

Implemented group accumulators

AccumulatorsSemantics and limitations
$countEmpty object operand only.
$sum, $avgIgnore nonnumeric/missing/null inputs. Sum returns zero if no numeric values; average returns null. Inputs are evaluated as IEEE-754 doubles to avoid SQLite's signed-integer aggregate overflow. BSON int32/int64/Decimal128 promotion and exact decimal arithmetic are outside the data profile. Nonfinite numeric output fails explicitly.
$min, $maxIgnore missing/null; return null when no remaining values. Compare complete JSON values using BSON-style ordered object and array comparison.
$pushPreserves input order and omits missing values; explicit null retained.
$addToSetDeep numeric equality with ordered object identity; missing omitted. Output order is unspecified.
$first, $lastRespect carried pipeline order. Missing selected value becomes null.
$firstN, $lastN, $minN, $maxN{input,n} with a literal positive safe integer n. Per-group/dynamic n expressions are unsupported and rejected; unknown fields fail.
$top, $bottom{sortBy,output}; output may be a supported expression. Returns scalar output as scalar.
$topN, $bottomN{sortBy,output,n} with literal positive safe integer n; same sorting restrictions as $sort.
$mergeObjectsIgnores missing/null, requires objects otherwise; last value wins, null values are retained, nested object values replace rather than recursively merge. Keys retain first-seen order.

Explicitly unimplemented

Stages include $setWindowFields, $graphLookup, $densify, $fill, $bucketAuto, $redact, $out, $merge, $geoNear, server/cluster metadata stages, Atlas search/vector/fusion stages, and other unlisted stages. No JS fallback exists.

Accumulators include $accumulator, $stdDevPop, $stdDevSamp, $median, $percentile, window-specific accumulators, and other unlisted accumulator names. Operator names shared with array expressions do not imply group-accumulator support; for example, an expression $concatArrays does not make the group accumulator $concatArrays available.

Also outside the current profile: BSON-only types, Decimal128, locale collation, timezone database semantics, MongoDB's full error codes/messages and resource limits, and exact query planner/index behavior. Optional native PCRE2 expressions are available when the extension is explicitly enabled. Primitive unsupported syntax is rejected before execution, including on an empty input. Some document-dependent semantic failures are deliberately raised inside SQLite and surface as its JSON validation error, rather than MongoDB's corresponding error code.

Performance limits

SQLite executes every stage, including nested-array projection and joins. Large or deeply nested pipelines remain subject to SQLite's parser, expression, bind-variable, and JSON nesting limits.

Compound-value sorts can require O(n²) ranking to preserve JSON ordering. Generated SQL for these semantic paths is substantially larger than simple scalar SQL. Use representative data to assess these costs.

Without an index-compatible foreign predicate, $lookup can scan the foreign collection for each local document. Group arrays, facets, and lookup output arrays are constructed within SQLite, so persistent storage does not bound the size of one returned document. Streaming the final cursor avoids collecting the entire result in JavaScript; toArray() collects the remaining rows explicitly.

Validation evidence

Pipeline tests and live MongoDB comparisons cover nested projection, arrays, field order, joins, compound sorting, and accumulator edge cases. Offline tests replay captured responses. See testing and compatibility evidence for fixture provenance and recorded results.

Remaining known compatibility caveats

Projection retains source order for included fields, puts _id first, and appends computed fields in specification order. Dedicated tests compare serialized field order against MongoDB; ordinary JavaScript deep equality alone would not catch these differences. More combinations of nested mixed inclusion/computation remain useful conformance work.

Sorting on multiple array-valued paths is deliberately rejected, even where MongoDB can derive a correlated compound key. Scalar/object compound sorts and a single multikey path with other scalar keys are tested.

Very large/deep pipelines can hit SQLite parser, expression depth, compound SELECT, bind-variable, or JSON nesting limits before MongoDB's corresponding limits.