[SERVER-32217] Improve $cond or introduce a new pipeline operator for conditional stages Created: 08/Dec/17  Updated: 27/Oct/23  Resolved: 20/Dec/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Andrew Harris Assignee: Backlog - Query Team (Inactive)
Resolution: Gone away Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Participants:

 Description   

As far as I'm aware you can use $cond as if..then..else but only for expressions.

It would be useful if whole pipeline stages could be executed conditionally.

i.e.

if <input document satisifies condition> then
execute $group stage (or whatever)
else
execute a different $group stage (or whatever)



 Comments   
Comment by Andrew Harris [ 20/Dec/17 ]

It does indeed look like $facet serves the required need (in combination with $cond).

Comment by Andrew Harris [ 11/Dec/17 ]

You could very well be right. Thank you for that. I'll take a look.

Comment by Charlie Swanson [ 08/Dec/17 ]

aharris this sounds fairly similar to the $facet stage, would that be useful in achieving the functionality you want?

Comment by Kelsey Schubert [ 08/Dec/17 ]

Thanks for the feature request, aharris. I've marked this ticket for consideration by the Query Team; please continue to watch for updates.

Kind regards,
Kelsey

Comment by Andrew Harris [ 08/Dec/17 ]

This could mean that out of a stage input of multiple documents, some documents will have a different stage path than others and so potentially be transformed differently than others.

Comment by Sagar Bijlwan [X] [ 08/Dec/17 ]

The input document condition can be a document from last stage in pipeline.

Generated at Thu Feb 08 04:29:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.