Package dev.morphia.aggregation.stages
Class Facet
java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.Facet
Processes multiple aggregation 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.
The $facet stage allows you to create multi-faceted aggregations which characterize data across multiple dimensions, or facets, within a single aggregation stage. Multi-faceted aggregations provide multiple filters and categorizations to guide data browsing and analysis. Retailers commonly use faceting to narrow search results by creating filters on product price, manufacturer, size, etc.
Input documents are passed to the $facet stage only once. $facet enables various aggregations on the same set of input documents, without needing to retrieve the input documents multiple times.
-
Method Summary
-
Method Details
-
facet
Creates a new facet stage- Returns:
- the new stage
- Since:
- 2.2
- MongoDB documentation
- Aggregration Pipeline Stage: $facet
- Since server release
- 3.4
-
field
Adds a field to the facet- Parameters:
name
- the field namestages
- the pipeline defining the field- Returns:
- this
-