redis-vl-dotnet
HybridSearchQuery
HybridSearchQuery runs a native FT.HYBRID query (Redis 8.4+). The text branch (SEARCH) and the vector branch (VSIM) are scored independently and fused server-side, giving you tunable weighting between lexical and semantic relevance.
|
|
Basic shape
var query = HybridSearchQuery.FromFloat32(
Filter.Text("title").Prefix("He"), // SEARCH branch (must contain a text predicate)
"plot_embedding", // VSIM branch
queryVector,
topK: 3,
combination: new LinearHybridCombination(alpha: 0.7, beta: 0.3),
vectorFilter: Filter.Tag("genre").Eq("crime"),
returnFields: ["title"]);
var results = await index.SearchAsync(query);
var typed = await index.SearchAsync<Movie>(query);
Each returned document exposes the fused score under HybridSearchQuery.ScoreField (__score); the source document key becomes the result Id.
Fusion strategies
The combination argument controls how the two branches are merged:
-
LinearHybridCombination(alpha, beta, window?)— weighted blend wherealphaweights the text score andbetaweights the vector score (COMBINE LINEAR). -
ReciprocalRankFusionHybridCombination(constant?, window?)— reciprocal rank fusion (COMBINE RRF). At least one ofconstantorwindowmust be supplied. -
null(default) — use the server default, which is RRF with a window of 20 and a constant of 60.
Filtering
-
The
textQuery(the first argument) drives the lexicalSEARCHbranch and must contain at least one text predicate, otherwise construction throwsArgumentException. -
vectorFilterapplies an optional pre-filter to the vector branch (VSIM … FILTER), restricting the candidate set considered during nearest-neighbour search.
Paging and runtime behavior
-
topK(theKNN Kcount) must be greater than zero. -
paginationmaps toLIMIT offset numand defaults to the firsttopKresults. -
VectorKnnRuntimeOptions.EfRuntimeemitsEF_RUNTIMEfor HNSW vector fields.
Return-field normalization and typed mapping behave the same way as VectorQuery.