@@ -508,6 +508,12 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
508508 if options .Timeout > 0 {
509509 queryArgs = append (queryArgs , "TIMEOUT" , options .Timeout )
510510 }
511+ for _ , apply := range options .Apply {
512+ queryArgs = append (queryArgs , "APPLY" , apply .Field )
513+ if apply .As != "" {
514+ queryArgs = append (queryArgs , "AS" , apply .As )
515+ }
516+ }
511517 if options .GroupBy != nil {
512518 for _ , groupBy := range options .GroupBy {
513519 queryArgs = append (queryArgs , "GROUPBY" , len (groupBy .Fields ))
@@ -549,12 +555,6 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
549555 if options .SortByMax > 0 {
550556 queryArgs = append (queryArgs , "MAX" , options .SortByMax )
551557 }
552- for _ , apply := range options .Apply {
553- queryArgs = append (queryArgs , "APPLY" , apply .Field )
554- if apply .As != "" {
555- queryArgs = append (queryArgs , "AS" , apply .As )
556- }
557- }
558558 if options .LimitOffset > 0 {
559559 queryArgs = append (queryArgs , "LIMIT" , options .LimitOffset )
560560 }
@@ -661,11 +661,12 @@ func (cmd *AggregateCmd) readReply(rd *proto.Reader) (err error) {
661661 data , err := rd .ReadSlice ()
662662 if err != nil {
663663 cmd .err = err
664- return nil
664+ return err
665665 }
666666 cmd .val , err = ProcessAggregateResult (data )
667667 if err != nil {
668668 cmd .err = err
669+ return err
669670 }
670671 return nil
671672}
@@ -699,6 +700,12 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
699700 if options .Timeout > 0 {
700701 args = append (args , "TIMEOUT" , options .Timeout )
701702 }
703+ for _ , apply := range options .Apply {
704+ args = append (args , "APPLY" , apply .Field )
705+ if apply .As != "" {
706+ args = append (args , "AS" , apply .As )
707+ }
708+ }
702709 if options .GroupBy != nil {
703710 for _ , groupBy := range options .GroupBy {
704711 args = append (args , "GROUPBY" , len (groupBy .Fields ))
@@ -740,12 +747,6 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
740747 if options .SortByMax > 0 {
741748 args = append (args , "MAX" , options .SortByMax )
742749 }
743- for _ , apply := range options .Apply {
744- args = append (args , "APPLY" , apply .Field )
745- if apply .As != "" {
746- args = append (args , "AS" , apply .As )
747- }
748- }
749750 if options .LimitOffset > 0 {
750751 args = append (args , "LIMIT" , options .LimitOffset )
751752 }
@@ -1693,7 +1694,8 @@ func (cmd *FTSearchCmd) readReply(rd *proto.Reader) (err error) {
16931694
16941695// FTSearch - Executes a search query on an index.
16951696// The 'index' parameter specifies the index to search, and the 'query' parameter specifies the search query.
1696- // For more information, please refer to the Redis documentation:
1697+ // For more information, please refer to the Redis documentation about [FT.SEARCH].
1698+ //
16971699// [FT.SEARCH]: (https://redis.io/commands/ft.search/)
16981700func (c cmdable ) FTSearch (ctx context.Context , index string , query string ) * FTSearchCmd {
16991701 args := []interface {}{"FT.SEARCH" , index , query }
@@ -1704,6 +1706,12 @@ func (c cmdable) FTSearch(ctx context.Context, index string, query string) *FTSe
17041706
17051707type SearchQuery []interface {}
17061708
1709+ // FTSearchQuery - Executes a search query on an index with additional options.
1710+ // The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query,
1711+ // and the 'options' parameter specifies additional options for the search.
1712+ // For more information, please refer to the Redis documentation about [FT.SEARCH].
1713+ //
1714+ // [FT.SEARCH]: (https://redis.io/commands/ft.search/)
17071715func FTSearchQuery (query string , options * FTSearchOptions ) SearchQuery {
17081716 queryArgs := []interface {}{query }
17091717 if options != nil {
@@ -1816,7 +1824,8 @@ func FTSearchQuery(query string, options *FTSearchOptions) SearchQuery {
18161824// FTSearchWithArgs - Executes a search query on an index with additional options.
18171825// The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query,
18181826// and the 'options' parameter specifies additional options for the search.
1819- // For more information, please refer to the Redis documentation:
1827+ // For more information, please refer to the Redis documentation about [FT.SEARCH].
1828+ //
18201829// [FT.SEARCH]: (https://redis.io/commands/ft.search/)
18211830func (c cmdable ) FTSearchWithArgs (ctx context.Context , index string , query string , options * FTSearchOptions ) * FTSearchCmd {
18221831 args := []interface {}{"FT.SEARCH" , index , query }
@@ -1908,7 +1917,7 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
19081917 }
19091918 }
19101919 if options .SortByWithCount {
1911- args = append (args , "WITHCOUT " )
1920+ args = append (args , "WITHCOUNT " )
19121921 }
19131922 }
19141923 if options .LimitOffset >= 0 && options .Limit > 0 {
0 commit comments