Merge two aggregation into one

Hi all. I have a two aggregation operation with value count results:
Economy 0
First 0
And second
Economy 50

I need to get final result:
Economy 50
First 0

How to do that, maybe with Merge or something else, thank you

Please post real sample input and output documents. It is easier to work with real documents rather than description of documents. Your current pipeline would also be useful as the optimal solution might involve replacing existing stages.

Thank you for help in advance :slight_smile:

Part of data set looks like this, in projectOperation method

{
_id : 111111,
cabin : "Economy",
fn : 55,
departure : "CDG",
arrival : "BER"
},
{
_id : 111112,
cabin : "First",
fn : 22,
departure : "CDG",
arrival : "BER"
},
{
_id : 111113,
cabin : "Economy",
fn : 11,
departure : "CDG",
arrival : "BER"
},
{
_id : 111114,
cabin : "Business",
fn : 44,
departure : "CDG",
arrival : "BER"
}

I have input query parameter cabin = “Economy”
Count need to be calculated depending input parameter, otherwise 0.

On that case I need to get in result set structure like this

{
value : "Economy",
count : 2
},
{
value : "Business",
count : 0
},
{
value : "First",
count : 0
}

How I need to define Aggregation operation to get this?

List of aggregationOperation:

 new AggregationOperation[]{
        projectOperation(),
        Aggregation.match(cabinClass),
        Aggregation.group(CABIN_CLASS).count().as(COUNT).addToSet(CABIN_CLASS).as(VALUE)
    };

Then simply count Economy and assume all others being 0 in your client code. Why bother producing 0?