Skip to content

Commit faf27d0

Browse files
Ensure that the args are prefixed only if theres no prefix already
1 parent 5d05e3b commit faf27d0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

search_commands.go

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

89
"github.com/redis/go-redis/v9/internal"
910
"github.com/redis/go-redis/v9/internal/proto"
@@ -363,11 +364,18 @@ type FTHybridSearchExpression struct {
363364
YieldScoreAs string
364365
}
365366

367+
type FTHybridVectorMethod = string
368+
369+
const (
370+
KNN FTHybridCombineMethod = "KNN"
371+
RANGE FTHybridCombineMethod = "RANGE"
372+
)
373+
366374
// FTHybridVectorExpression represents a vector expression in hybrid search
367375
type FTHybridVectorExpression struct {
368376
VectorField string
369377
VectorData Vector
370-
Method string // KNN or RANGE
378+
Method FTHybridVectorMethod
371379
MethodParams []interface{}
372380
Filter string
373381
YieldScoreAs string
@@ -2585,7 +2593,11 @@ func (c cmdable) FTHybridWithArgs(ctx context.Context, index string, options *FT
25852593
args = append(args, "LOAD", len(options.Load))
25862594
for _, field := range options.Load {
25872595
// Redis requires field names in LOAD to be prefixed with '@' (or '$' for JSON paths).
2588-
// Tests pass plain field names (e.g. "description"), so add the '@' prefix here.
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 '@'
25892601
args = append(args, "@"+field)
25902602
}
25912603
}

0 commit comments

Comments
 (0)