Skip to content

Commit 1ae8313

Browse files
Removed automatic args prefixing
1 parent e780ef0 commit 1ae8313

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

search_commands.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"strconv"
7-
"strings"
87

98
"github.com/redis/go-redis/v9/internal"
109
"github.com/redis/go-redis/v9/internal/proto"
@@ -2592,13 +2591,7 @@ func (c cmdable) FTHybridWithArgs(ctx context.Context, index string, options *FT
25922591
if len(options.Load) > 0 {
25932592
args = append(args, "LOAD", len(options.Load))
25942593
for _, field := range options.Load {
2595-
// Redis requires field names in LOAD to be prefixed with '@' (or '$' for JSON paths).
2596-
if strings.HasPrefix(field, "@") || strings.HasPrefix(field, "&") {
2597-
args = append(args, field)
2598-
continue
2599-
}
2600-
// If the field doesn't have a preffix, asume its a string and add '@'
2601-
args = append(args, "@"+field)
2594+
args = append(args, field)
26022595
}
26032596
}
26042597

@@ -2623,12 +2616,7 @@ func (c cmdable) FTHybridWithArgs(ctx context.Context, index string, options *FT
26232616
if len(options.SortBy) > 0 {
26242617
sortByOptions := []interface{}{}
26252618
for _, sortBy := range options.SortBy {
2626-
// Redis requires field names in SORTBY to be prefixed with '@' (or '$' for JSON paths)
2627-
fieldName := sortBy.FieldName
2628-
if fieldName != "" && fieldName[0] != '@' && fieldName[0] != '$' {
2629-
fieldName = "@" + fieldName
2630-
}
2631-
sortByOptions = append(sortByOptions, fieldName)
2619+
sortByOptions = append(sortByOptions, sortBy.FieldName)
26322620
if sortBy.Asc && sortBy.Desc {
26332621
cmd := newFTHybridCmd(ctx, options, args...)
26342622
cmd.SetErr(fmt.Errorf("FT.HYBRID: ASC and DESC are mutually exclusive"))

search_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,7 +3429,7 @@ var _ = Describe("FT.HYBRID Commands", func() {
34293429
VectorData: &redis.VectorFP32{Val: encodeFloat32Vector([]float32{1, 2, 2, 3})},
34303430
},
34313431
},
3432-
Load: []string{"description", "color", "price", "size", "__score"},
3432+
Load: []string{"@description", "@color", "@price", "@size", "@__score"},
34333433
LimitOffset: 0,
34343434
Limit: 3,
34353435
}
@@ -3463,7 +3463,7 @@ var _ = Describe("FT.HYBRID Commands", func() {
34633463
Filter: "@price:[15 16] @size:[10 11]",
34643464
},
34653465
},
3466-
Load: []string{"description", "color", "price", "size", "__score"},
3466+
Load: []string{"@description", "@color", "@price", "@size", "@__score"},
34673467
}
34683468

34693469
cmd := client.FTHybridWithArgs(ctx, "hybrid_idx", options)
@@ -3614,7 +3614,7 @@ var _ = Describe("FT.HYBRID Commands", func() {
36143614
VectorData: &redis.VectorFP32{Val: encodeFloat32Vector([]float32{1, 2, 7, 6})},
36153615
},
36163616
},
3617-
Load: []string{"description", "color", "price", "size", "__score"},
3617+
Load: []string{"@description", "@color", "@price", "@size", "@__score"},
36183618
Apply: []redis.FTHybridApply{
36193619
{
36203620
Expression: "@price - (@price * 0.1)",
@@ -3680,16 +3680,16 @@ var _ = Describe("FT.HYBRID Commands", func() {
36803680
VectorData: &redis.VectorFP32{Val: encodeFloat32Vector([]float32{1, 2, 7, 6})},
36813681
},
36823682
},
3683-
Load: []string{"color", "price"},
3683+
Load: []string{"@color", "@price"},
36843684
Apply: []redis.FTHybridApply{
36853685
{
36863686
Expression: "@price - (@price * 0.1)",
36873687
AsField: "price_discount",
36883688
},
36893689
},
36903690
SortBy: []redis.FTSearchSortBy{
3691-
{FieldName: "price_discount", Desc: true},
3692-
{FieldName: "color", Asc: true},
3691+
{FieldName: "@price_discount", Desc: true},
3692+
{FieldName: "@color", Asc: true},
36933693
},
36943694
LimitOffset: 0,
36953695
Limit: 5,

0 commit comments

Comments
 (0)