@@ -240,13 +240,20 @@ type FTAggregateWithCursor struct {
240240}
241241
242242type  FTAggregateOptions  struct  {
243- 	Verbatim           bool 
244- 	LoadAll            bool 
245- 	Load               []FTAggregateLoad 
246- 	Timeout            int 
247- 	GroupBy            []FTAggregateGroupBy 
248- 	SortBy             []FTAggregateSortBy 
249- 	SortByMax          int 
243+ 	Verbatim   bool 
244+ 	LoadAll    bool 
245+ 	Load       []FTAggregateLoad 
246+ 	Timeout    int 
247+ 	GroupBy    []FTAggregateGroupBy 
248+ 	SortBy     []FTAggregateSortBy 
249+ 	SortByMax  int 
250+ 	// Scorer is used to set scoring function, if not set passed, a default will be used. 
251+ 	// The default scorer depends on the Redis version: 
252+ 	// - `BM25` for Redis >= 8 
253+ 	// - `TFIDF` for Redis < 8 
254+ 	Scorer  string 
255+ 	// AddScores is available in Redis CE 8 
256+ 	AddScores          bool 
250257	Apply              []FTAggregateApply 
251258	LimitOffset        int 
252259	Limit              int 
@@ -490,6 +497,15 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
490497		if  options .Verbatim  {
491498			queryArgs  =  append (queryArgs , "VERBATIM" )
492499		}
500+ 
501+ 		if  options .Scorer  !=  ""  {
502+ 			queryArgs  =  append (queryArgs , "SCORER" , options .Scorer )
503+ 		}
504+ 
505+ 		if  options .AddScores  {
506+ 			queryArgs  =  append (queryArgs , "ADDSCORES" )
507+ 		}
508+ 
493509		if  options .LoadAll  &&  options .Load  !=  nil  {
494510			panic ("FT.AGGREGATE: LOADALL and LOAD are mutually exclusive" )
495511		}
@@ -505,9 +521,18 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
505521				}
506522			}
507523		}
524+ 
508525		if  options .Timeout  >  0  {
509526			queryArgs  =  append (queryArgs , "TIMEOUT" , options .Timeout )
510527		}
528+ 
529+ 		for  _ , apply  :=  range  options .Apply  {
530+ 			queryArgs  =  append (queryArgs , "APPLY" , apply .Field )
531+ 			if  apply .As  !=  ""  {
532+ 				queryArgs  =  append (queryArgs , "AS" , apply .As )
533+ 			}
534+ 		}
535+ 
511536		if  options .GroupBy  !=  nil  {
512537			for  _ , groupBy  :=  range  options .GroupBy  {
513538				queryArgs  =  append (queryArgs , "GROUPBY" , len (groupBy .Fields ))
@@ -549,12 +574,6 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
549574		if  options .SortByMax  >  0  {
550575			queryArgs  =  append (queryArgs , "MAX" , options .SortByMax )
551576		}
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- 		}
558577		if  options .LimitOffset  >  0  {
559578			queryArgs  =  append (queryArgs , "LIMIT" , options .LimitOffset )
560579		}
@@ -581,6 +600,7 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
581600				queryArgs  =  append (queryArgs , key , value )
582601			}
583602		}
603+ 
584604		if  options .DialectVersion  >  0  {
585605			queryArgs  =  append (queryArgs , "DIALECT" , options .DialectVersion )
586606		}
@@ -661,11 +681,12 @@ func (cmd *AggregateCmd) readReply(rd *proto.Reader) (err error) {
661681	data , err  :=  rd .ReadSlice ()
662682	if  err  !=  nil  {
663683		cmd .err  =  err 
664- 		return  nil 
684+ 		return  err 
665685	}
666686	cmd .val , err  =  ProcessAggregateResult (data )
667687	if  err  !=  nil  {
668688		cmd .err  =  err 
689+ 		return  err 
669690	}
670691	return  nil 
671692}
@@ -681,6 +702,12 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
681702		if  options .Verbatim  {
682703			args  =  append (args , "VERBATIM" )
683704		}
705+ 		if  options .Scorer  !=  ""  {
706+ 			args  =  append (args , "SCORER" , options .Scorer )
707+ 		}
708+ 		if  options .AddScores  {
709+ 			args  =  append (args , "ADDSCORES" )
710+ 		}
684711		if  options .LoadAll  &&  options .Load  !=  nil  {
685712			panic ("FT.AGGREGATE: LOADALL and LOAD are mutually exclusive" )
686713		}
@@ -699,6 +726,12 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
699726		if  options .Timeout  >  0  {
700727			args  =  append (args , "TIMEOUT" , options .Timeout )
701728		}
729+ 		for  _ , apply  :=  range  options .Apply  {
730+ 			args  =  append (args , "APPLY" , apply .Field )
731+ 			if  apply .As  !=  ""  {
732+ 				args  =  append (args , "AS" , apply .As )
733+ 			}
734+ 		}
702735		if  options .GroupBy  !=  nil  {
703736			for  _ , groupBy  :=  range  options .GroupBy  {
704737				args  =  append (args , "GROUPBY" , len (groupBy .Fields ))
@@ -740,12 +773,6 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
740773		if  options .SortByMax  >  0  {
741774			args  =  append (args , "MAX" , options .SortByMax )
742775		}
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- 		}
749776		if  options .LimitOffset  >  0  {
750777			args  =  append (args , "LIMIT" , options .LimitOffset )
751778		}
@@ -1693,7 +1720,8 @@ func (cmd *FTSearchCmd) readReply(rd *proto.Reader) (err error) {
16931720
16941721// FTSearch - Executes a search query on an index. 
16951722// 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: 
1723+ // For more information, please refer to the Redis documentation about [FT.SEARCH]. 
1724+ // 
16971725// [FT.SEARCH]: (https://redis.io/commands/ft.search/) 
16981726func  (c  cmdable ) FTSearch (ctx  context.Context , index  string , query  string ) * FTSearchCmd  {
16991727	args  :=  []interface {}{"FT.SEARCH" , index , query }
@@ -1704,6 +1732,12 @@ func (c cmdable) FTSearch(ctx context.Context, index string, query string) *FTSe
17041732
17051733type  SearchQuery  []interface {}
17061734
1735+ // FTSearchQuery - Executes a search query on an index with additional options. 
1736+ // The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query, 
1737+ // and the 'options' parameter specifies additional options for the search. 
1738+ // For more information, please refer to the Redis documentation about [FT.SEARCH]. 
1739+ // 
1740+ // [FT.SEARCH]: (https://redis.io/commands/ft.search/) 
17071741func  FTSearchQuery (query  string , options  * FTSearchOptions ) SearchQuery  {
17081742	queryArgs  :=  []interface {}{query }
17091743	if  options  !=  nil  {
@@ -1816,7 +1850,8 @@ func FTSearchQuery(query string, options *FTSearchOptions) SearchQuery {
18161850// FTSearchWithArgs - Executes a search query on an index with additional options. 
18171851// The 'index' parameter specifies the index to search, the 'query' parameter specifies the search query, 
18181852// and the 'options' parameter specifies additional options for the search. 
1819- // For more information, please refer to the Redis documentation: 
1853+ // For more information, please refer to the Redis documentation about [FT.SEARCH]. 
1854+ // 
18201855// [FT.SEARCH]: (https://redis.io/commands/ft.search/) 
18211856func  (c  cmdable ) FTSearchWithArgs (ctx  context.Context , index  string , query  string , options  * FTSearchOptions ) * FTSearchCmd  {
18221857	args  :=  []interface {}{"FT.SEARCH" , index , query }
@@ -1908,7 +1943,7 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
19081943				}
19091944			}
19101945			if  options .SortByWithCount  {
1911- 				args  =  append (args , "WITHCOUT " )
1946+ 				args  =  append (args , "WITHCOUNT " )
19121947			}
19131948		}
19141949		if  options .LimitOffset  >=  0  &&  options .Limit  >  0  {
0 commit comments