FTHybridWithArgs - Executes a hybrid search with advanced options FTHybridWithArgs is still experimental, the command behaviour and signature may change Vector data is always sent through the PARAMS mechanism, because inline vector blobs are no longer supported by Redis. For every vector expression
(ctx context.Context, index string, options *FTHybridOptions)
| 3729 | // names are also reserved against all explicit VectorParamName values, so they never |
| 3730 | // collide with explicit names (even those following the "__vector_param_N" pattern). |
| 3731 | func (c cmdable) FTHybridWithArgs(ctx context.Context, index string, options *FTHybridOptions) *FTHybridCmd { |
| 3732 | args := []interface{}{"FT.HYBRID", index} |
| 3733 | |
| 3734 | if options != nil { |
| 3735 | // Add search expressions |
| 3736 | for _, searchExpr := range options.SearchExpressions { |
| 3737 | args = append(args, "SEARCH", searchExpr.Query) |
| 3738 | |
| 3739 | if searchExpr.Scorer != "" { |
| 3740 | args = append(args, "SCORER", searchExpr.Scorer) |
| 3741 | if len(searchExpr.ScorerParams) > 0 { |
| 3742 | args = append(args, searchExpr.ScorerParams...) |
| 3743 | } |
| 3744 | } |
| 3745 | |
| 3746 | if searchExpr.YieldScoreAs != "" { |
| 3747 | args = append(args, "YIELD_SCORE_AS", searchExpr.YieldScoreAs) |
| 3748 | } |
| 3749 | } |
| 3750 | |
| 3751 | // Vector data is always passed via the PARAMS mechanism (inline vector blobs |
| 3752 | // are no longer supported by Redis). When vectors are present, build a local |
| 3753 | // copy of the caller-provided params so options.Params is never mutated, and |
| 3754 | // pre-reserve any explicit VectorParamName values so generated names never |
| 3755 | // collide with them. |
| 3756 | params := options.Params |
| 3757 | if len(options.VectorExpressions) > 0 { |
| 3758 | params = make(map[string]interface{}, len(options.Params)+len(options.VectorExpressions)) |
| 3759 | for k, v := range options.Params { |
| 3760 | params[k] = v |
| 3761 | } |
| 3762 | for _, vectorExpr := range options.VectorExpressions { |
| 3763 | if vectorExpr.VectorParamName != "" { |
| 3764 | params[vectorExpr.VectorParamName] = nil |
| 3765 | } |
| 3766 | } |
| 3767 | } |
| 3768 | // Add vector expressions |
| 3769 | for _, vectorExpr := range options.VectorExpressions { |
| 3770 | args = append(args, "VSIM", "@"+vectorExpr.VectorField) |
| 3771 | |
| 3772 | vectorBlob, err := hybridVectorBlob(vectorExpr.VectorData) |
| 3773 | if err != nil { |
| 3774 | cmd := newFTHybridCmd(ctx, options, args...) |
| 3775 | cmd.SetErr(err) |
| 3776 | return cmd |
| 3777 | } |
| 3778 | |
| 3779 | // When VectorParamName is not provided, generate a unique name. Generated |
| 3780 | // names are tracked only in the local params map, never written back to |
| 3781 | // options.Params. |
| 3782 | paramName := vectorExpr.VectorParamName |
| 3783 | if paramName == "" { |
| 3784 | paramName = generateVectorParamName(params) |
| 3785 | } |
| 3786 | args = append(args, "$"+paramName) |
| 3787 | params[paramName] = vectorBlob |
| 3788 |
no test coverage detected