redis/go-redis · error

FT.AGGREGATE: each step must set exactly one of Load, Apply,

Error message

FT.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy (got %d)

What it means

Error "FT.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy (got %d)" thrown in redis/go-redis.

Source

Thrown at search_commands.go:725

// appendFTAggregateStep appends the Redis command arguments for a single
// aggregation pipeline step. Each step must set exactly one of Load, Apply,
// GroupBy or SortBy.
func appendFTAggregateStep(args []interface{}, step FTAggregateStep) ([]interface{}, error) {
	set := 0
	if step.Load != nil {
		set++
	}
	if step.Apply != nil {
		set++
	}
	if step.GroupBy != nil {
		set++
	}
	if step.SortBy != nil {
		set++
	}
	if set != 1 {
		return args, fmt.Errorf("FT.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy (got %d)", set)
	}

	switch {
	case step.Load != nil:
		args = append(args, "LOAD")
		countIdx := len(args)
		args = append(args, 0)
		count := 0
		args = append(args, step.Load.Field)
		count++
		if step.Load.As != "" {
			args = append(args, "AS", step.Load.As)
			count += 2
		}
		args[countIdx] = count
	case step.Apply != nil:
		args = append(args, "APPLY", step.Apply.Field)
		if step.Apply.As != "" {

View on GitHub (pinned to c5cad058c7)

When it happens

Trigger: Thrown at search_commands.go:725 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01). Data as JSON: /api/errors/ce6ef3f5a2e5993e. Report an issue: GitHub.