Class AutoBucket
- java.lang.Object
-
- dev.morphia.aggregation.experimental.stages.Stage
-
- dev.morphia.aggregation.experimental.stages.AutoBucket
-
public class AutoBucket extends Stage
Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets.Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket, and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AutoBucket()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static AutoBucket
autoBucket()
Creates a new auto bucketAutoBucket
buckets(Integer buckets)
A positive 32-bit integer that specifies the number of buckets into which input documents are grouped.Integer
getBuckets()
com.mongodb.client.model.BucketGranularity
getGranularity()
Expression
getGroupBy()
DocumentExpression
getOutput()
AutoBucket
granularity(com.mongodb.client.model.BucketGranularity granularity)
A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10.AutoBucket
groupBy(Expression groupBy)
An expression to group documents by.static AutoBucket
of()
Deprecated, for removal: This API element is subject to removal in a future version.useautoBucket()
AutoBucket
outputField(String name, Expression value)
Adds a field to the document that specifies the fields to include in the output documents in addition to the _id field.-
Methods inherited from class dev.morphia.aggregation.experimental.stages.Stage
aggregation, stageName
-
-
-
-
Method Detail
-
autoBucket
public static AutoBucket autoBucket()
Creates a new auto bucket- Returns:
- the new bucket
- Since:
- 2.2
-
of
@Deprecated(forRemoval=true) public static AutoBucket of()
Deprecated, for removal: This API element is subject to removal in a future version.useautoBucket()
Creates a new auto bucket- Returns:
- the new bucket
-
buckets
public AutoBucket buckets(Integer buckets)
A positive 32-bit integer that specifies the number of buckets into which input documents are grouped.- Parameters:
buckets
- the number of buckets- Returns:
- this
-
getBuckets
public Integer getBuckets()
- Returns:
- the number of buckets
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getGranularity
public com.mongodb.client.model.BucketGranularity getGranularity()
- Returns:
- the granularity
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getGroupBy
public Expression getGroupBy()
- Returns:
- the group by expression
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getOutput
public DocumentExpression getOutput()
- Returns:
- the output document
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
granularity
public AutoBucket granularity(com.mongodb.client.model.BucketGranularity granularity)
A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10.Available only if the all groupBy values are numeric and none of them are NaN.
- Parameters:
granularity
- the granularity- Returns:
- this
-
groupBy
public AutoBucket groupBy(Expression groupBy)
An expression to group documents by.- Parameters:
groupBy
- the expression to use- Returns:
- this
-
outputField
public AutoBucket outputField(String name, Expression value)
Adds a field to the document that specifies the fields to include in the output documents in addition to the _id field. To specify the field to include, you must use accumulator expressions.- Parameters:
name
- the new field namevalue
- the value expression- Returns:
- this
-
-