|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 | "strconv" |
| 7 | + "strings" |
7 | 8 |
|
8 | 9 | "github.com/redis/go-redis/v9/internal" |
9 | 10 | "github.com/redis/go-redis/v9/internal/proto" |
@@ -363,11 +364,18 @@ type FTHybridSearchExpression struct { |
363 | 364 | YieldScoreAs string |
364 | 365 | } |
365 | 366 |
|
| 367 | +type FTHybridVectorMethod = string |
| 368 | + |
| 369 | +const ( |
| 370 | + KNN FTHybridCombineMethod = "KNN" |
| 371 | + RANGE FTHybridCombineMethod = "RANGE" |
| 372 | +) |
| 373 | + |
366 | 374 | // FTHybridVectorExpression represents a vector expression in hybrid search |
367 | 375 | type FTHybridVectorExpression struct { |
368 | 376 | VectorField string |
369 | 377 | VectorData Vector |
370 | | - Method string // KNN or RANGE |
| 378 | + Method FTHybridVectorMethod |
371 | 379 | MethodParams []interface{} |
372 | 380 | Filter string |
373 | 381 | YieldScoreAs string |
@@ -2585,7 +2593,11 @@ func (c cmdable) FTHybridWithArgs(ctx context.Context, index string, options *FT |
2585 | 2593 | args = append(args, "LOAD", len(options.Load)) |
2586 | 2594 | for _, field := range options.Load { |
2587 | 2595 | // 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 '@' |
2589 | 2601 | args = append(args, "@"+field) |
2590 | 2602 | } |
2591 | 2603 | } |
|
0 commit comments