Class GroupOperation
java.lang.Object
org.springframework.data.mongodb.core.aggregation.GroupOperation
- All Implemented Interfaces:
AggregationOperation
,FieldsExposingAggregationOperation
Encapsulates the aggregation framework
$group
-operation.
We recommend to use the static factory method Aggregation.group(Fields)
instead of creating instances of this
class directly.
- Since:
- 1.3
- Author:
- Sebastian Herold, Thomas Darimont, Oliver Gierke, Gustavo de Geus, Christoph Strobl, Mark Paluch, Sergey Shcherbakov
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
-
Constructor Summary
ModifierConstructorDescriptionGroupOperation
(Fields fields) Creates a newGroupOperation
including the givenFields
.protected
GroupOperation
(GroupOperation groupOperation) Creates a newGroupOperation
from the givenGroupOperation
. -
Method Summary
Modifier and TypeMethodDescriptionaccumulate
(ScriptOperators.Accumulator accumulator) Generates anGroupOperation.GroupOperationBuilder
for an$accumulator
-expression.Generates anGroupOperation.GroupOperationBuilder
for an$add_to_set
-expression for the given value.Generates anGroupOperation.GroupOperationBuilder
for an$add_to_set
-expression for the given field-reference.and
(String fieldName, AggregationExpression expression) Adds a computed field to theGroupOperation
.protected GroupOperation
and
(org.springframework.data.mongodb.core.aggregation.GroupOperation.Operation operation) Creates a newGroupOperation
from the current one adding the givenGroupOperation.Operation
.Generates anGroupOperation.GroupOperationBuilder
for an$avg
-expression for the given field-reference.avg
(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilder
for an$avg
-expression for the givenAggregationExpression
.count()
Generates anGroupOperation.GroupOperationBuilder
for a$sum
-expression.Generates anGroupOperation.GroupOperationBuilder
for a$first
-expression for the given field-reference.first
(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilder
for a$first
-expression for the givenAggregationExpression
.Returns the fields exposed by theAggregationOperation
.Return the MongoDB operator that is used for thisAggregationOperation
.Generates anGroupOperation.GroupOperationBuilder
for an$last
-expression for the given field-reference.last
(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilder
for an$last
-expression for the givenAggregationExpression
.Generates anGroupOperation.GroupOperationBuilder
for an$max
-expression that for the given field-reference.max
(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilder
for an$max
-expression that for the givenAggregationExpression
.Generates anGroupOperation.GroupOperationBuilder
for an$min
-expression that for the given field-reference.min
(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilder
for an$min
-expression that for the givenAggregationExpression
.Generates anGroupOperation.GroupOperationBuilder
for an$push
-expression for the given value.Generates anGroupOperation.GroupOperationBuilder
for an$push
-expression for the given field-reference.Generates anGroupOperation.GroupOperationBuilder
for an$stdDevPop
-expression that for the given field-reference.Generates anGroupOperation.GroupOperationBuilder
for an$stdDevPop
-expression that for the givenAggregationExpression
.stdDevSamp
(String reference) Generates anGroupOperation.GroupOperationBuilder
for an$stdDevSamp
-expression that for the given field-reference.Generates anGroupOperation.GroupOperationBuilder
for an$stdDevSamp
-expression that for the givenAggregationExpression
.Generates anGroupOperation.GroupOperationBuilder
for a$sum
-expression for the given field-reference.sum
(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilder
for an$sum
-expression for the givenAggregationExpression
.org.bson.Document
toDocument
(AggregationOperationContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.core.aggregation.AggregationOperation
toPipelineStages
Methods inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
inheritsFields
-
Constructor Details
-
GroupOperation
Creates a newGroupOperation
including the givenFields
.- Parameters:
fields
- must not be null.
-
GroupOperation
Creates a newGroupOperation
from the givenGroupOperation
.- Parameters:
groupOperation
- must not be null.
-
-
Method Details
-
and
protected GroupOperation and(org.springframework.data.mongodb.core.aggregation.GroupOperation.Operation operation) Creates a newGroupOperation
from the current one adding the givenGroupOperation.Operation
.- Parameters:
operation
- must not be null.- Returns:
-
count
Generates anGroupOperation.GroupOperationBuilder
for a$sum
-expression.Count expressions are emulated via
$sum: 1
.- Returns:
-
sum
Generates anGroupOperation.GroupOperationBuilder
for a$sum
-expression for the given field-reference.- Parameters:
reference
-- Returns:
-
sum
Generates anGroupOperation.GroupOperationBuilder
for an$sum
-expression for the givenAggregationExpression
.- Parameters:
expr
- must not be null.- Returns:
- new instance of
GroupOperation.GroupOperationBuilder
. Never null. - Throws:
IllegalArgumentException
- whenexpr
is null.- Since:
- 1.10.8
-
addToSet
Generates anGroupOperation.GroupOperationBuilder
for an$add_to_set
-expression for the given field-reference.- Parameters:
reference
-- Returns:
-
addToSet
Generates anGroupOperation.GroupOperationBuilder
for an$add_to_set
-expression for the given value.- Parameters:
value
-- Returns:
-
last
Generates anGroupOperation.GroupOperationBuilder
for an$last
-expression for the given field-reference.- Parameters:
reference
-- Returns:
-
last
Generates anGroupOperation.GroupOperationBuilder
for an$last
-expression for the givenAggregationExpression
.- Parameters:
expr
-- Returns:
-
first
Generates anGroupOperation.GroupOperationBuilder
for a$first
-expression for the given field-reference.- Parameters:
reference
-- Returns:
-
first
Generates anGroupOperation.GroupOperationBuilder
for a$first
-expression for the givenAggregationExpression
.- Parameters:
expr
-- Returns:
-
avg
Generates anGroupOperation.GroupOperationBuilder
for an$avg
-expression for the given field-reference.- Parameters:
reference
-- Returns:
-
avg
Generates anGroupOperation.GroupOperationBuilder
for an$avg
-expression for the givenAggregationExpression
.- Parameters:
expr
-- Returns:
-
push
Generates anGroupOperation.GroupOperationBuilder
for an$push
-expression for the given field-reference.- Parameters:
reference
-- Returns:
-
push
Generates anGroupOperation.GroupOperationBuilder
for an$push
-expression for the given value.- Parameters:
value
-- Returns:
-
min
Generates anGroupOperation.GroupOperationBuilder
for an$min
-expression that for the given field-reference.- Parameters:
reference
-- Returns:
-
min
Generates anGroupOperation.GroupOperationBuilder
for an$min
-expression that for the givenAggregationExpression
.- Parameters:
expr
-- Returns:
-
max
Generates anGroupOperation.GroupOperationBuilder
for an$max
-expression that for the given field-reference.- Parameters:
reference
-- Returns:
-
max
Generates anGroupOperation.GroupOperationBuilder
for an$max
-expression that for the givenAggregationExpression
.- Parameters:
expr
-- Returns:
-
stdDevSamp
Generates anGroupOperation.GroupOperationBuilder
for an$stdDevSamp
-expression that for the given field-reference.- Parameters:
reference
- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
stdDevSamp
Generates anGroupOperation.GroupOperationBuilder
for an$stdDevSamp
-expression that for the givenAggregationExpression
.- Parameters:
expr
- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
stdDevPop
Generates anGroupOperation.GroupOperationBuilder
for an$stdDevPop
-expression that for the given field-reference.- Parameters:
reference
- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
stdDevPop
Generates anGroupOperation.GroupOperationBuilder
for an$stdDevPop
-expression that for the givenAggregationExpression
.- Parameters:
expr
- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
accumulate
Generates anGroupOperation.GroupOperationBuilder
for an$accumulator
-expression.- Parameters:
accumulator
- must not be null.- Returns:
- never null.
- Since:
- 3.2
-
and
Adds a computed field to theGroupOperation
.- Parameters:
expression
- must not be null.- Returns:
- never null.
- Since:
- 4.0
-
getFields
Description copied from interface:FieldsExposingAggregationOperation
Returns the fields exposed by theAggregationOperation
.- Specified by:
getFields
in interfaceFieldsExposingAggregationOperation
- Returns:
- will never be null.
-
toDocument
Description copied from interface:AggregationOperation
- Specified by:
toDocument
in interfaceAggregationOperation
- Parameters:
context
- theAggregationOperationContext
to operate within. Must not be null.- Returns:
- the Document
-
getOperator
Description copied from interface:AggregationOperation
Return the MongoDB operator that is used for thisAggregationOperation
. Aggregation operations should implement this method to avoid document rendering.- Specified by:
getOperator
in interfaceAggregationOperation
- Returns:
- the operator used for this
AggregationOperation
.
-