redis-vl-dotnet
AggregateHybridQuery
AggregateHybridQuery applies a hybrid text-plus-vector match and then runs an aggregation pipeline over the matched documents.
Basic shape
var aggregateHybridResults = await index.AggregateAsync<GenreHybridSummary>(
AggregateHybridQuery.FromFloat32(
Filter.Text("title").Prefix("He") | Filter.Text("title").Prefix("Ar"),
"plot_embedding",
queryVector,
topK: 3,
groupBy: new AggregationGroupBy(
["genre"],
[
AggregationReducer.Count("matchCount"),
AggregationReducer.Average("vector_distance", "avgDistance")
]),
sortBy: new AggregationSortBy(
[
new AggregationSortField("matchCount", descending: true),
new AggregationSortField("avgDistance")
]),
runtimeOptions: new VectorKnnRuntimeOptions(efRuntime: 90)));
The canonical runnable reference is /examples/VectorSearchExample.
Key behavior
AggregateHybridQuery combines the rules from hybrid search and aggregation:
-
textFiltermust contain at least one text predicate -
topKdefines the hybrid retrieval window before aggregation runs -
loadFieldsare normalized and deduplicated, preserving explicit@fieldsyntax when provided -
scoreAliasdefaults tovector_distance -
VectorKnnRuntimeOptionscontrols the runtimeEF_RUNTIMEparameter
Unlike HybridQuery, aggregate paging applies to the aggregation rows through the normal offset and limit values.
Typed row mapping and batches
Use AggregateAsync<TDocument> to map rows into projection types and AggregateBatchesAsync<TDocument> to stream multi-page result sets. Both behaviors are covered in tests/RedisVL.Tests/Indexes/SearchIndexAsyncTests.cs.