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.util.List<? extends Bson> pipeline,
java.lang.String as)
Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline
|
static Bson |
lookup(java.lang.String from,
java.util.List<Variable<?>> let,
java.util.List<? extends Bson> pipeline,
java.lang.String as)
Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline
|
static Bson |
lookup(java.lang.String from,
java.lang.String localField,
java.lang.String foreignField,
java.lang.String as)
Creates a $lookup pipeline stage, joining the current collection with the one specified in from
using equality match between the local field and the foreign field
|
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)
TExpression
- the groupBy expression typeBoundary
- the boundary typegroupBy
- the criteria to group Byboundaries
- the boundaries of the bucketspublic 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)
field
- the field in which to store the countpublic static Bson match(Bson filter)
filter
- the filter to matchFilters
public static Bson project(Bson projection)
projection
- the projectionProjections
public static Bson sort(Bson sort)
sort
- the sort specificationSorts
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
- the field from the local collection to match values against.foreignField
- 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 Bson lookup(java.lang.String from, java.util.List<? extends Bson> pipeline, java.lang.String as)
from
- the name of the collection in the same database to perform the join with.pipeline
- the pipeline to run on the joined collection.as
- the name of the new array field to add to the input documents.public static Bson lookup(java.lang.String from, @Nullable java.util.List<Variable<?>> let, java.util.List<? extends Bson> pipeline, java.lang.String as)
from
- the name of the collection in the same database to perform the join with.let
- the variables to use in the pipeline field stages.pipeline
- the pipeline to run on the joined collection.as
- the name of the new array field to add to the input documents.public static Bson facet(java.util.List<Facet> facets)
facets
- the facets to usepublic static Bson facet(Facet... facets)
facets
- the facets to usepublic 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(@Nullable TExpression id, BsonField... fieldAccumulators)
TExpression
- the expression typeid
- the id expression for the group, which may be nullfieldAccumulators
- zero or more field accumulator pairspublic static <TExpression> Bson group(@Nullable TExpression id, java.util.List<BsonField> fieldAccumulators)
TExpression
- the expression typeid
- the id expression for the group, which may be nullfieldAccumulators
- 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.fieldName
- the field name, prefixed by a '$' sign
unwindOptions
- options for the unwind pipeline stagepublic static Bson out(java.lang.String collectionName)
collectionName
- the collection namepublic static <TExpression> Bson replaceRoot(TExpression value)
TExpression
- the new root typevalue
- the new root valuepublic static Bson sample(int size)
size
- the sample sizeCopyright © 2010 - 2020 Adobe. All Rights Reserved