@@ -508,6 +508,12 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
508
508
if options .Timeout > 0 {
509
509
queryArgs = append (queryArgs , "TIMEOUT" , options .Timeout )
510
510
}
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
+ }
511
517
if options .GroupBy != nil {
512
518
for _ , groupBy := range options .GroupBy {
513
519
queryArgs = append (queryArgs , "GROUPBY" , len (groupBy .Fields ))
@@ -549,12 +555,6 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
549
555
if options .SortByMax > 0 {
550
556
queryArgs = append (queryArgs , "MAX" , options .SortByMax )
551
557
}
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
- }
558
558
if options .LimitOffset > 0 {
559
559
queryArgs = append (queryArgs , "LIMIT" , options .LimitOffset )
560
560
}
@@ -661,11 +661,12 @@ func (cmd *AggregateCmd) readReply(rd *proto.Reader) (err error) {
661
661
data , err := rd .ReadSlice ()
662
662
if err != nil {
663
663
cmd .err = err
664
- return nil
664
+ return err
665
665
}
666
666
cmd .val , err = ProcessAggregateResult (data )
667
667
if err != nil {
668
668
cmd .err = err
669
+ return err
669
670
}
670
671
return nil
671
672
}
@@ -699,6 +700,12 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
699
700
if options .Timeout > 0 {
700
701
args = append (args , "TIMEOUT" , options .Timeout )
701
702
}
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
+ }
702
709
if options .GroupBy != nil {
703
710
for _ , groupBy := range options .GroupBy {
704
711
args = append (args , "GROUPBY" , len (groupBy .Fields ))
@@ -740,12 +747,6 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
740
747
if options .SortByMax > 0 {
741
748
args = append (args , "MAX" , options .SortByMax )
742
749
}
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
- }
749
750
if options .LimitOffset > 0 {
750
751
args = append (args , "LIMIT" , options .LimitOffset )
751
752
}
@@ -1693,7 +1694,8 @@ func (cmd *FTSearchCmd) readReply(rd *proto.Reader) (err error) {
1693
1694
1694
1695
// FTSearch - Executes a search query on an index.
1695
1696
// 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
+ //
1697
1699
// [FT.SEARCH]: (https://redis.io/commands/ft.search/)
1698
1700
func (c cmdable ) FTSearch (ctx context.Context , index string , query string ) * FTSearchCmd {
1699
1701
args := []interface {}{"FT.SEARCH" , index , query }
@@ -1704,6 +1706,12 @@ func (c cmdable) FTSearch(ctx context.Context, index string, query string) *FTSe
1704
1706
1705
1707
type SearchQuery []interface {}
1706
1708
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/)
1707
1715
func FTSearchQuery (query string , options * FTSearchOptions ) SearchQuery {
1708
1716
queryArgs := []interface {}{query }
1709
1717
if options != nil {
@@ -1816,7 +1824,8 @@ func FTSearchQuery(query string, options *FTSearchOptions) SearchQuery {
1816
1824
// FTSearchWithArgs - Executes a search query on an index with additional options.
1817
1825
// The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query,
1818
1826
// 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
+ //
1820
1829
// [FT.SEARCH]: (https://redis.io/commands/ft.search/)
1821
1830
func (c cmdable ) FTSearchWithArgs (ctx context.Context , index string , query string , options * FTSearchOptions ) * FTSearchCmd {
1822
1831
args := []interface {}{"FT.SEARCH" , index , query }
@@ -1908,7 +1917,7 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
1908
1917
}
1909
1918
}
1910
1919
if options .SortByWithCount {
1911
- args = append (args , "WITHCOUT " )
1920
+ args = append (args , "WITHCOUNT " )
1912
1921
}
1913
1922
}
1914
1923
if options .LimitOffset >= 0 && options .Limit > 0 {
0 commit comments