-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query Execution
-
Fully Compatible
When using $cond in projections, it would be useful to have $match as a boolean expression.
Use Case:
db.objects.aggregate([ { $match: { status: "active" } }, { $project: { name: 1, meta: 1, tags: 1, score: { $add: [ { $cond:[{ $match: { tags: "a tag I like" } }, 100, 0] }, { $cond:[{ $match: { tags: "a tag I really like" } }, 250, 0] }, { $cond:[{ $match: { tags: "a tag I dislike" } }, -100, 0] }, { $cond:[{ $match: { "meta.promoted": true } }, 1000, 0] } ] } } },{ $match: { score: { $gt: 0 } } } ])
This would eliminate the need to add other $cond expressions like $in (SERVER-6146)
- is related to
-
SERVER-34766 Allow $expr or $$field in the $geoNear stage
- Closed
-
SERVER-38198 Remove the requirement that $geoNear needs to be in the first stage of the pipeline
- Closed
- related to
-
SERVER-8582 Extend document expression language in aggregation to support advanced document filtering.
- Closed