AWS documentdb: Document $expr index usage and limitations
Summary
Adds documentation that $eq, $lt, $lte, $gt, and $gte comparison operators inside $expr can use an index (including on $lookup 'from' collections), plus limitations: only field-vs-constant comparisons, no multikey/partial/sparse indexes, and full index scan when let resolves to empty/missing.
Security assessment
The added content describes query performance behavior (index usage and fallback to collection scans) for the $expr operator. It is performance/query-planning guidance with no security implications such as access control, data exposure, or encryption.
Evidence
+The `$eq`, `$lt`, `$lte`, `$gt`, and `$gte` comparison operators placed in an `$expr` operator can use an index, including an index on the `from` collection referenced in a `$lookup` stage.
Diff
diff --git a/documentdb/latest/devguide/expr.md b/documentdb/latest/devguide/expr.md index df41e9804..c7e0543b0 100644 --- a//documentdb/latest/devguide/expr.md +++ b//documentdb/latest/devguide/expr.md @@ -16,0 +17,13 @@ The `$expr` operator in Amazon DocumentDB allows you to use aggregation expressi +The `$eq`, `$lt`, `$lte`, `$gt`, and `$gte` comparison operators placed in an `$expr` operator can use an index, including an index on the `from` collection referenced in a `$lookup` stage. + +**Limitations** + + * Indexes can only be used for comparisons between fields and constants, so the operand must resolve to a constant. For example, a comparison between `$a` and a constant value can use an index, but a comparison between `$a` and `$b` cannot. + + * Multikey, partial, or sparse indexes are not used. In those cases the query falls back to a collection scan. + + * When the `let` operand resolves to an empty or missing value, the comparison cannot use a targeted index seek. In this case, Amazon DocumentDB performs a full index scan. + + + +