I know I could use $unwind $project and $push to do this. But I’m thinking there must be a better way. The end game is to end up with a single document. I’m wondering is $setWindowFields would be a better option? But I can seem to get it to do what I want it to.
You’re right that going from single document to same single document should not involve any unwinding and grouping, just field transformation.
I can tell you that the transformation will probably involve $map expression and you’ll want to use $setUnion of ”$Specs.Group” expression to “seed” your input.
Let me know if you’d like to see the entire solution or if this was enough to get you started in the right direction.