Class FacetOperation
java.lang.Object
org.springframework.data.mongodb.core.aggregation.FacetOperation
- All Implemented Interfaces:
AggregationOperation,FieldsExposingAggregationOperation
Encapsulates the aggregation framework
Facet of
As of MongoDB 3.4,
We recommend to use the static factory method
$facet-operation. Facet of
AggregationOperations 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:
- 1.10
- Author:
- Mark Paluch, Christoph Strobl
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forFacetOperationby adding existing and the new pipeline ofAggregationOperationto the newFacetOperation.Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand(AggregationOperation... operations) Creates a newFacetOperation.FacetOperationBuilderto append a new facet using operations.Returns the fields exposed by theAggregationOperation.Return the MongoDB operator that is used for thisAggregationOperation.org.bson.DocumenttoDocument(AggregationOperationContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.mongodb.core.aggregation.AggregationOperation
toPipelineStagesMethods inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
inheritsFields
-
Field Details
-
EMPTY
Empty (initial)FacetOperation.
-
-
Constructor Details
-
FacetOperation
public FacetOperation()Creates a newFacetOperation.
-
-
Method Details
-
and
Creates a newFacetOperation.FacetOperationBuilderto append a new facet using operations.
FacetOperation.FacetOperationBuildertakes a pipeline ofAggregationOperationto categorize documents into a single facet.- Parameters:
operations- must not be null or empty.- Returns:
-
toDocument
Description copied from interface:AggregationOperation- Specified by:
toDocumentin interfaceAggregationOperation- Parameters:
context- theAggregationOperationContextto operate within. Must not be null.- Returns:
- the Document
-
getOperator
Description copied from interface:AggregationOperationReturn the MongoDB operator that is used for thisAggregationOperation. Aggregation operations should implement this method to avoid document rendering.- Specified by:
getOperatorin interfaceAggregationOperation- Returns:
- the operator used for this
AggregationOperation.
-
getFields
Description copied from interface:FieldsExposingAggregationOperationReturns the fields exposed by theAggregationOperation.- Specified by:
getFieldsin interfaceFieldsExposingAggregationOperation- Returns:
- will never be null.
-