Skip to content

Commit

Permalink
Support LOAD * in FT.AGGREGATE (#147)
Browse files Browse the repository at this point in the history
* Support LOAD * in FT.AGGREGATE

* document

* add point
  • Loading branch information
Avital-Fine authored Apr 11, 2022
1 parent 23c6554 commit d5b6b35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion redisearch/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ func (a *AggregateQuery) Limit(offset int, num int) *AggregateQuery {
return a
}

//Load document fields from the document HASH objects (if they are not in the sortables)
//Load document fields from the document HASH objects (if they are not in the sortables).
//Empty array will load all properties.
func (a *AggregateQuery) Load(Properties []string) *AggregateQuery {
nproperties := len(Properties)
if nproperties == 0 {
a.AggregatePlan = a.AggregatePlan.Add("LOAD", "*")
}
if nproperties > 0 {
a.AggregatePlan = a.AggregatePlan.Add("LOAD", nproperties)
for _, property := range Properties {
Expand Down
4 changes: 2 additions & 2 deletions redisearch/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ func TestAggregateQuery_Load(t *testing.T) {
args{[]string{"field1", "field2", "field3", "field4"}},
redis.Args{"*", "LOAD", 4, "@field1", "@field2", "@field3", "@field4"},
},
{"TestAggregateQuery_Load_Empty",
{"TestAggregateQuery_Load_All",
fields{nil, redis.Args{}, nil, 0, false, false, false, nil},
args{[]string{}},
redis.Args{"*"},
redis.Args{"*", "LOAD", "*"},
},
}
for _, tt := range tests {
Expand Down

0 comments on commit d5b6b35

Please sign in to comment.