Class UnionWithOperation

java.lang.Object
org.springframework.data.mongodb.core.aggregation.UnionWithOperation
All Implemented Interfaces:
AggregationOperation

public class UnionWithOperation extends Object implements AggregationOperation
The $unionWith aggregation stage (available since MongoDB 4.4) performs a union of two collections by combining pipeline results, potentially containing duplicates, into a single result set that is handed over to the next stage.
In order to remove duplicates it is possible to append a GroupOperation right after UnionWithOperation.
If the UnionWithOperation uses a pipeline to process documents, field names within the pipeline will be treated as is. In order to map domain type property names to actual field names (considering potential Field annotations) make sure the enclosing aggregation is a TypedAggregation and provide the target type for the $unionWith stage via mapFieldsTo(Class).
Since:
3.1
Author:
Christoph Strobl
See Also: