@@ -18,8 +18,8 @@ type SearchBuilder struct {
18
18
options * FTSearchOptions
19
19
}
20
20
21
- // Search starts building an FT.SEARCH command .
22
- func (c * Client ) Search (ctx context.Context , index , query string ) * SearchBuilder {
21
+ // NewSearchBuilder creates a new SearchBuilder for FT.SEARCH commands .
22
+ func (c * Client ) NewSearchBuilder (ctx context.Context , index , query string ) * SearchBuilder {
23
23
b := & SearchBuilder {c : c , ctx : ctx , index : index , query : query , options : & FTSearchOptions {LimitOffset : - 1 }}
24
24
return b
25
25
}
@@ -215,8 +215,8 @@ type AggregateBuilder struct {
215
215
options * FTAggregateOptions
216
216
}
217
217
218
- // Aggregate starts building an FT.AGGREGATE command .
219
- func (c * Client ) Aggregate (ctx context.Context , index , query string ) * AggregateBuilder {
218
+ // NewAggregateBuilder creates a new AggregateBuilder for FT.AGGREGATE commands .
219
+ func (c * Client ) NewAggregateBuilder (ctx context.Context , index , query string ) * AggregateBuilder {
220
220
return & AggregateBuilder {c : c , ctx : ctx , index : index , query : query , options : & FTAggregateOptions {LimitOffset : - 1 }}
221
221
}
222
222
@@ -367,8 +367,8 @@ type CreateIndexBuilder struct {
367
367
schema []* FieldSchema
368
368
}
369
369
370
- // CreateIndex starts building an FT.CREATE command .
371
- func (c * Client ) CreateIndex (ctx context.Context , index string ) * CreateIndexBuilder {
370
+ // NewCreateIndexBuilder creates a new CreateIndexBuilder for FT.CREATE commands .
371
+ func (c * Client ) NewCreateIndexBuilder (ctx context.Context , index string ) * CreateIndexBuilder {
372
372
return & CreateIndexBuilder {c : c , ctx : ctx , index : index , options : & FTCreateOptions {}}
373
373
}
374
374
@@ -473,8 +473,8 @@ type DropIndexBuilder struct {
473
473
options * FTDropIndexOptions
474
474
}
475
475
476
- // DropIndex starts FT.DROPINDEX builder .
477
- func (c * Client ) DropIndex (ctx context.Context , index string ) * DropIndexBuilder {
476
+ // NewDropIndexBuilder creates a new DropIndexBuilder for FT.DROPINDEX commands .
477
+ func (c * Client ) NewDropIndexBuilder (ctx context.Context , index string ) * DropIndexBuilder {
478
478
return & DropIndexBuilder {c : c , ctx : ctx , index : index }
479
479
}
480
480
@@ -499,19 +499,35 @@ type AliasBuilder struct {
499
499
action string // add|del|update
500
500
}
501
501
502
- // AliasAdd starts FT.ALIASADD builder .
503
- func (c * Client ) AliasAdd (ctx context.Context , alias , index string ) * AliasBuilder {
504
- return & AliasBuilder {c : c , ctx : ctx , alias : alias , index : index , action : "add" }
502
+ // NewAliasBuilder creates a new AliasBuilder for FT.ALIAS* commands .
503
+ func (c * Client ) NewAliasBuilder (ctx context.Context , alias string ) * AliasBuilder {
504
+ return & AliasBuilder {c : c , ctx : ctx , alias : alias }
505
505
}
506
506
507
- // AliasDel starts FT.ALIASDEL builder.
508
- func (c * Client ) AliasDel (ctx context.Context , alias string ) * AliasBuilder {
509
- return & AliasBuilder {c : c , ctx : ctx , alias : alias , action : "del" }
507
+ // Action sets the action for the alias builder.
508
+ func (b * AliasBuilder ) Action (action string ) * AliasBuilder {
509
+ b .action = action
510
+ return b
511
+ }
512
+
513
+ // Add sets the action to "add" and requires an index.
514
+ func (b * AliasBuilder ) Add (index string ) * AliasBuilder {
515
+ b .action = "add"
516
+ b .index = index
517
+ return b
518
+ }
519
+
520
+ // Del sets the action to "del".
521
+ func (b * AliasBuilder ) Del () * AliasBuilder {
522
+ b .action = "del"
523
+ return b
510
524
}
511
525
512
- // AliasUpdate starts FT.ALIASUPDATE builder.
513
- func (c * Client ) AliasUpdate (ctx context.Context , alias , index string ) * AliasBuilder {
514
- return & AliasBuilder {c : c , ctx : ctx , alias : alias , index : index , action : "update" }
526
+ // Update sets the action to "update" and requires an index.
527
+ func (b * AliasBuilder ) Update (index string ) * AliasBuilder {
528
+ b .action = "update"
529
+ b .index = index
530
+ return b
515
531
}
516
532
517
533
// Run executes the configured alias command.
@@ -542,8 +558,8 @@ type ExplainBuilder struct {
542
558
options * FTExplainOptions
543
559
}
544
560
545
- // Explain starts FT.EXPLAIN builder .
546
- func (c * Client ) Explain (ctx context.Context , index , query string ) * ExplainBuilder {
561
+ // NewExplainBuilder creates a new ExplainBuilder for FT.EXPLAIN commands .
562
+ func (c * Client ) NewExplainBuilder (ctx context.Context , index , query string ) * ExplainBuilder {
547
563
return & ExplainBuilder {c : c , ctx : ctx , index : index , query : query , options : & FTExplainOptions {}}
548
564
}
549
565
@@ -566,8 +582,8 @@ type FTInfoBuilder struct {
566
582
index string
567
583
}
568
584
569
- // SearchInfo starts building an FT.INFO command for RediSearch .
570
- func (c * Client ) SearchInfo (ctx context.Context , index string ) * FTInfoBuilder {
585
+ // NewSearchInfoBuilder creates a new FTInfoBuilder for FT.INFO commands .
586
+ func (c * Client ) NewSearchInfoBuilder (ctx context.Context , index string ) * FTInfoBuilder {
571
587
return & FTInfoBuilder {c : c , ctx : ctx , index : index }
572
588
}
573
589
@@ -589,8 +605,8 @@ type SpellCheckBuilder struct {
589
605
options * FTSpellCheckOptions
590
606
}
591
607
592
- // SpellCheck starts FT.SPELLCHECK builder .
593
- func (c * Client ) SpellCheck (ctx context.Context , index , query string ) * SpellCheckBuilder {
608
+ // NewSpellCheckBuilder creates a new SpellCheckBuilder for FT.SPELLCHECK commands .
609
+ func (c * Client ) NewSpellCheckBuilder (ctx context.Context , index , query string ) * SpellCheckBuilder {
594
610
return & SpellCheckBuilder {c : c , ctx : ctx , index : index , query : query , options : & FTSpellCheckOptions {}}
595
611
}
596
612
@@ -633,19 +649,35 @@ type DictBuilder struct {
633
649
action string // add|del|dump
634
650
}
635
651
636
- // DictAdd starts FT.DICTADD builder .
637
- func (c * Client ) DictAdd (ctx context.Context , dict string , terms ... interface {} ) * DictBuilder {
638
- return & DictBuilder {c : c , ctx : ctx , dict : dict , terms : terms , action : "add" }
652
+ // NewDictBuilder creates a new DictBuilder for FT.DICT* commands .
653
+ func (c * Client ) NewDictBuilder (ctx context.Context , dict string ) * DictBuilder {
654
+ return & DictBuilder {c : c , ctx : ctx , dict : dict }
639
655
}
640
656
641
- // DictDel starts FT.DICTDEL builder.
642
- func (c * Client ) DictDel (ctx context.Context , dict string , terms ... interface {}) * DictBuilder {
643
- return & DictBuilder {c : c , ctx : ctx , dict : dict , terms : terms , action : "del" }
657
+ // Action sets the action for the dictionary builder.
658
+ func (b * DictBuilder ) Action (action string ) * DictBuilder {
659
+ b .action = action
660
+ return b
644
661
}
645
662
646
- // DictDump starts FT.DICTDUMP builder.
647
- func (c * Client ) DictDump (ctx context.Context , dict string ) * DictBuilder {
648
- return & DictBuilder {c : c , ctx : ctx , dict : dict , action : "dump" }
663
+ // Add sets the action to "add" and requires terms.
664
+ func (b * DictBuilder ) Add (terms ... interface {}) * DictBuilder {
665
+ b .action = "add"
666
+ b .terms = terms
667
+ return b
668
+ }
669
+
670
+ // Del sets the action to "del" and requires terms.
671
+ func (b * DictBuilder ) Del (terms ... interface {}) * DictBuilder {
672
+ b .action = "del"
673
+ b .terms = terms
674
+ return b
675
+ }
676
+
677
+ // Dump sets the action to "dump".
678
+ func (b * DictBuilder ) Dump () * DictBuilder {
679
+ b .action = "dump"
680
+ return b
649
681
}
650
682
651
683
// Run executes the configured dictionary command.
@@ -675,8 +707,8 @@ type TagValsBuilder struct {
675
707
field string
676
708
}
677
709
678
- // TagVals starts FT.TAGVALS builder .
679
- func (c * Client ) TagVals (ctx context.Context , index , field string ) * TagValsBuilder {
710
+ // NewTagValsBuilder creates a new TagValsBuilder for FT.TAGVALS commands .
711
+ func (c * Client ) NewTagValsBuilder (ctx context.Context , index , field string ) * TagValsBuilder {
680
712
return & TagValsBuilder {c : c , ctx : ctx , index : index , field : field }
681
713
}
682
714
@@ -699,14 +731,27 @@ type CursorBuilder struct {
699
731
action string // read|del
700
732
}
701
733
702
- // CursorRead starts FT.CURSOR READ builder .
703
- func (c * Client ) CursorRead (ctx context.Context , index string , cursorId int64 ) * CursorBuilder {
704
- return & CursorBuilder {c : c , ctx : ctx , index : index , cursorId : cursorId , action : "read" }
734
+ // NewCursorBuilder creates a new CursorBuilder for FT.CURSOR* commands .
735
+ func (c * Client ) NewCursorBuilder (ctx context.Context , index string , cursorId int64 ) * CursorBuilder {
736
+ return & CursorBuilder {c : c , ctx : ctx , index : index , cursorId : cursorId }
705
737
}
706
738
707
- // CursorDel starts FT.CURSOR DEL builder.
708
- func (c * Client ) CursorDel (ctx context.Context , index string , cursorId int64 ) * CursorBuilder {
709
- return & CursorBuilder {c : c , ctx : ctx , index : index , cursorId : cursorId , action : "del" }
739
+ // Action sets the action for the cursor builder.
740
+ func (b * CursorBuilder ) Action (action string ) * CursorBuilder {
741
+ b .action = action
742
+ return b
743
+ }
744
+
745
+ // Read sets the action to "read".
746
+ func (b * CursorBuilder ) Read () * CursorBuilder {
747
+ b .action = "read"
748
+ return b
749
+ }
750
+
751
+ // Del sets the action to "del".
752
+ func (b * CursorBuilder ) Del () * CursorBuilder {
753
+ b .action = "del"
754
+ return b
710
755
}
711
756
712
757
// Count for READ.
@@ -738,8 +783,8 @@ type SynUpdateBuilder struct {
738
783
terms []interface {}
739
784
}
740
785
741
- // SynUpdate starts FT.SYNUPDATE builder .
742
- func (c * Client ) SynUpdate (ctx context.Context , index string , groupId interface {}) * SynUpdateBuilder {
786
+ // NewSynUpdateBuilder creates a new SynUpdateBuilder for FT.SYNUPDATE commands .
787
+ func (c * Client ) NewSynUpdateBuilder (ctx context.Context , index string , groupId interface {}) * SynUpdateBuilder {
743
788
return & SynUpdateBuilder {c : c , ctx : ctx , index : index , groupId : groupId , options : & FTSynUpdateOptions {}}
744
789
}
745
790
0 commit comments