extends Object implements FieldsExposingAggregationOperation
Encapsulates the aggregation framework $facet -operation.
Facet of AggregationOperation s to be used in an Aggregation . Processes multiple AggregationOperation pipelines within a single stage on the same set of input documents. Each sub-pipeline has its own field in the output document where its results are stored as an array of documents. FacetOperation enables various aggregations on the same set of input documents, without needing to retrieve the input documents multiple times.
As of MongoDB 3.4, FacetOperation cannot be used with nested pipelines containing GeoNearOperation , OutOperation and FacetOperation .
We recommend to use the static factory method Aggregation.facet() instead of creating instances of this class directly.
Since:
Author:
Mark Paluch, Christoph Strobl
See Also:
  • MongoDB Aggregation Framework: $facet
  • Builder for FacetOperation by adding existing and the new pipeline of AggregationOperation to the new FacetOperation .

    Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation. FieldsExposingAggregationOperation

    FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
    Description
    and ( AggregationOperation ... operations)
    Creates a new FacetOperation.FacetOperationBuilder to append a new facet using operations.
    Returns the fields exposed by the AggregationOperation .
    Return the MongoDB operator that is used for this AggregationOperation .
    org.bson.Document
    Turns the AggregationOperation into a Document by using the given AggregationOperationContext .

    Methods inherited from class java.lang. Object

    clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait

    Methods inherited from interface org.springframework.data.mongodb.core.aggregation. AggregationOperation

    toPipelineStages

    Methods inherited from interface org.springframework.data.mongodb.core.aggregation. FieldsExposingAggregationOperation

    inheritsFields
    Creates a new FacetOperation.FacetOperationBuilder to append a new facet using operations.
    FacetOperation.FacetOperationBuilder takes a pipeline of AggregationOperation to categorize documents into a single facet.
    Parameters:
    operations - must not be null or empty.
    Returns:

    toDocument

    public org.bson.Document toDocument ( AggregationOperationContext context)
    Description copied from interface: AggregationOperation
    Turns the AggregationOperation into a Document by using the given AggregationOperationContext .
    Specified by:
    toDocument in interface AggregationOperation
    Parameters:
    context - the AggregationOperationContext to operate within. Must not be null.
    Returns:
    the Document

    getOperator

    public String getOperator ()
    Description copied from interface: AggregationOperation
    Return the MongoDB operator that is used for this AggregationOperation . Aggregation operations should implement this method to avoid document rendering.
    Specified by:
    getOperator in interface AggregationOperation
    Returns:
    the operator used for this AggregationOperation .

    getFields

    public ExposedFields getFields ()
    Description copied from interface: FieldsExposingAggregationOperation
    Returns the fields exposed by the AggregationOperation .
    Specified by:
    getFields in interface FieldsExposingAggregationOperation
    Returns:
    will never be null.