K - Key type.V - Value type.public class AggregateArgs<K,V> extends Object
FT.AGGREGATE command.
FT.AGGREGATE runs a search query on an index and performs aggregate transformations on the results. It provides a powerful aggregation pipeline that can group, sort, apply mathematical expressions, filter, and limit results in a single command.
{
@code
// Simple aggregation with grouping and counting
AggregateArgs args = AggregateArgs. builder().groupBy("category")
.reduce(Reducer.count().as("count")).sortBy("count", SortDirection.DESC).build();
SearchReply result = redis.ftAggregate("myindex", "*", args);
}
{
@code
// Complex aggregation pipeline
AggregateArgs args = AggregateArgs. builder().load("price", "quantity", "category")
.apply("@price * @quantity", "total_value").filter("@total_value > 100").groupBy("category")
.reduce(Reducer.sum("@total_value").as("category_total")).reduce(Reducer.avg("@price").as("avg_price"))
.sortBy("category_total", SortDirection.DESC).limit(0, 10).dialect(QueryDialects.DIALECT2).build();
}
| Modifier and Type | Class and Description |
|---|---|
static class |
AggregateArgs.Apply<K,V>
Represents an APPLY clause in an aggregation pipeline.
|
static class |
AggregateArgs.Builder<K,V>
Builder for
AggregateArgs. |
static class |
AggregateArgs.Filter<K,V>
Represents a FILTER clause in an aggregation pipeline.
|
static class |
AggregateArgs.GroupBy<K,V>
Represents a GROUPBY clause in an aggregation pipeline.
|
static class |
AggregateArgs.Limit<K,V> |
static class |
AggregateArgs.LoadField<K> |
static interface |
AggregateArgs.PipelineOperation<K,V>
Interface for pipeline operations that need to be applied in user-specified order.
|
static class |
AggregateArgs.Reducer<K,V>
Represents a REDUCE function in a GROUPBY clause.
|
static class |
AggregateArgs.SortBy<K>
Represents a SORTBY clause in an aggregation pipeline.
|
static class |
AggregateArgs.SortDirection
Sort direction enumeration.
|
static class |
AggregateArgs.SortProperty<K>
Represents a sort property with direction.
|
static class |
AggregateArgs.WithCursor |
| Constructor and Description |
|---|
AggregateArgs() |
| Modifier and Type | Method and Description |
|---|---|
void |
build(CommandArgs<K,V> args)
Build a
CommandArgs object that contains all the arguments. |
static <K,V> AggregateArgs.Builder<K,V> |
builder()
Creates a new
AggregateArgs instance. |
Optional<AggregateArgs.WithCursor> |
getWithCursor() |
public static <K,V> AggregateArgs.Builder<K,V> builder()
AggregateArgs instance.K - Key type.V - Value type.AggregateArgs.public void build(CommandArgs<K,V> args)
CommandArgs object that contains all the arguments.args - the CommandArgs objectpublic Optional<AggregateArgs.WithCursor> getWithCursor()
Copyright © 2025 lettuce.io. All rights reserved.