public final class Aggregates
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static Bson |
addFields(Field<?>... fields)
Creates an $addFields pipeline stage
|
static Bson |
addFields(java.util.List<Field<?>> fields)
Creates an $addFields pipeline stage
|
static <TExpression,Boundary> |
bucket(TExpression groupBy,
java.util.List<Boundary> boundaries)
Creates a $bucket pipeline stage
|
static <TExpression,TBoundary> |
bucket(TExpression groupBy,
java.util.List<TBoundary> boundaries,
BucketOptions options)
Creates a $bucket pipeline stage
|
static <TExpression> |
bucketAuto(TExpression groupBy,
int buckets)
Creates a $bucketAuto pipeline stage
|
static <TExpression> |
bucketAuto(TExpression groupBy,
int buckets,
BucketAutoOptions options)
Creates a $bucketAuto pipeline stage
|
static Bson |
count()
Creates a $count pipeline stage using the field name "count" to store the result
|
static Bson |
count(java.lang.String field)
Creates a $count pipeline stage using the named field to store the result
|
static Bson |
facet(Facet... facets)
Creates a facet pipeline stage
|
static Bson |
facet(java.util.List<Facet> facets)
Creates a facet pipeline stage
|
static <TExpression> |
graphLookup(java.lang.String from,
TExpression startWith,
java.lang.String connectFromField,
java.lang.String connectToField,
java.lang.String as)
Creates a graphLookup pipeline stage for the specified filter
|
static <TExpression> |
graphLookup(java.lang.String from,
TExpression startWith,
java.lang.String connectFromField,
java.lang.String connectToField,
java.lang.String as,
GraphLookupOptions options)
Creates a graphLookup pipeline stage for the specified filter
|
static <TExpression> |
group(TExpression id,
BsonField... fieldAccumulators)
Creates a $group pipeline stage for the specified filter
|
static <TExpression> |
group(TExpression id,
java.util.List<BsonField> fieldAccumulators)
Creates a $group pipeline stage for the specified filter
|
static Bson |
limit(int limit)
Creates a $limit pipeline stage for the specified filter
|
static Bson |
lookup(java.lang.String from,
java.lang.String localField,
java.lang.String foreignField,
java.lang.String as)
Creates a $lookup pipeline stage for the specified filter
|
static Bson |
match(Bson filter)
Creates a $match pipeline stage for the specified filter
|
static Bson |
out(java.lang.String collectionName)
Creates a $out pipeline stage for the specified filter
|
static Bson |
project(Bson projection)
Creates a $project pipeline stage for the specified projection
|
static <TExpression> |
replaceRoot(TExpression value)
Creates a $replaceRoot pipeline stage
|
static Bson |
sample(int size)
Creates a $sample pipeline stage with the specified sample size
|
static Bson |
skip(int skip)
Creates a $skip pipeline stage
|
static Bson |
sort(Bson sort)
Creates a $sort pipeline stage for the specified sort specification
|
static <TExpression> |
sortByCount(TExpression filter)
Creates a $sortByCount pipeline stage for the specified filter
|
static Bson |
unwind(java.lang.String fieldName)
Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a
'$' sign. |
static Bson |
unwind(java.lang.String fieldName,
UnwindOptions unwindOptions)
Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a
'$' sign. |
public static Bson addFields(Field<?>... fields)
fields
- the fields to addpublic static Bson addFields(java.util.List<Field<?>> fields)
fields
- the fields to addpublic static <TExpression,Boundary> Bson bucket(TExpression groupBy, java.util.List<Boundary> boundaries)
public static <TExpression,TBoundary> Bson bucket(TExpression groupBy, java.util.List<TBoundary> boundaries, BucketOptions options)
TExpression
- the groupBy expression typeTBoundary
- the boundary typegroupBy
- the criteria to group Byboundaries
- the boundaries of the bucketsoptions
- the optional values for the $bucket stagepublic static <TExpression> Bson bucketAuto(TExpression groupBy, int buckets)
TExpression
- the groupBy expression typegroupBy
- the criteria to group Bybuckets
- the number of the bucketspublic static <TExpression> Bson bucketAuto(TExpression groupBy, int buckets, BucketAutoOptions options)
TExpression
- the groupBy expression typegroupBy
- the criteria to group Bybuckets
- the number of the bucketsoptions
- the optional values for the $bucketAuto stagepublic static Bson count()
public static Bson count(java.lang.String field)
public static Bson match(Bson filter)
public static Bson project(Bson projection)
projection
- the projectionProjections
public static Bson sort(Bson sort)
public static <TExpression> Bson sortByCount(TExpression filter)
TExpression
- the expression typefilter
- the filter specificationpublic static Bson skip(int skip)
skip
- the number of documents to skippublic static Bson limit(int limit)
limit
- the limitpublic static Bson lookup(java.lang.String from, java.lang.String localField, java.lang.String foreignField, java.lang.String as)
from
- the name of the collection in the same database to perform the join with.localField
- specifies the field from the local collection to match values against.foreignField
- specifies the field in the from collection to match values against.as
- the name of the new array field to add to the input documents.public static <TExpression> Bson graphLookup(java.lang.String from, TExpression startWith, java.lang.String connectFromField, java.lang.String connectToField, java.lang.String as)
TExpression
- the expression typefrom
- the collection to querystartWith
- the expression to start the graph lookup withconnectFromField
- the from fieldconnectToField
- the to fieldas
- name of field in output documentpublic static <TExpression> Bson graphLookup(java.lang.String from, TExpression startWith, java.lang.String connectFromField, java.lang.String connectToField, java.lang.String as, GraphLookupOptions options)
TExpression
- the expression typefrom
- the collection to querystartWith
- the expression to start the graph lookup withconnectFromField
- the from fieldconnectToField
- the to fieldas
- name of field in output documentoptions
- optional values for the graphLookuppublic static <TExpression> Bson group(TExpression id, BsonField... fieldAccumulators)
TExpression
- the expression typeid
- the id expression for the groupfieldAccumulators
- zero or more field accumulator pairspublic static <TExpression> Bson group(TExpression id, java.util.List<BsonField> fieldAccumulators)
TExpression
- the expression typeid
- the id expression for the groupfieldAccumulators
- zero or more field accumulator pairspublic static Bson unwind(java.lang.String fieldName)
'$'
sign.fieldName
- the field name, prefixed by a '$' sign
public static Bson unwind(java.lang.String fieldName, UnwindOptions unwindOptions)
'$'
sign.public static Bson out(java.lang.String collectionName)
public static <TExpression> Bson replaceRoot(TExpression value)
TExpression
- the new root typevalue
- the new root value