public static class AggregateArgs.GroupBy extends Object implements AggregateArgs.PipelineOperation
Groups the results in the pipeline based on one or more properties. Each group should have at least one reducer function that handles the group entries, either counting them or performing multiple aggregate operations.
{
@code
// Group by category and count items
GroupBy groupBy = GroupBy.of("category").reduce(Reducer.count().as("item_count"));
// Group by multiple fields with multiple reducers
GroupBy complexGroup = GroupBy.of("category", "brand").reduce(Reducer.count().as("count"))
.reduce(Reducer.avg("@price").as("avg_price")).reduce(Reducer.sum("@quantity").as("total_quantity"));
}
AggregateArgs.Reducer.collect())Performance Note: Properties used in GROUPBY should be stored as SORTABLE in the index for optimal performance.
| Modifier and Type | Method and Description |
|---|---|
void |
build(CommandArgs<?,?> args)
Build the operation arguments into the command args.
|
static AggregateArgs.GroupBy |
of(String... properties)
Static factory method to create a GroupBy instance.
|
AggregateArgs.GroupBy |
reduce(AggregateArgs.Reducer reducer) |
public AggregateArgs.GroupBy reduce(AggregateArgs.Reducer reducer)
@SafeVarargs public static AggregateArgs.GroupBy of(String... properties)
properties - the properties to group bypublic void build(CommandArgs<?,?> args)
AggregateArgs.PipelineOperationbuild in interface AggregateArgs.PipelineOperationargs - the command args to build intoCopyright © 2026 lettuce.io. All rights reserved.