searchHybrid method
Hybrid search combining vector and keyword (BM25) search.
Uses Reciprocal Rank Fusion (RRF) to combine semantic and keyword results.
vectorWeight / bm25Weight default to defaultVectorWeight /
defaultBm25Weight.
Implementation
Future<List<hybrid.HybridSearchResult>> searchHybrid(
String query, {
int topK = 10,
double? vectorWeight,
double? bm25Weight,
List<int>? sourceIds,
String? collectionId,
}) async {
_ensureEmbeddingFingerprintUnlocked();
final service = await _serviceForCollection(collectionId);
await _flushIndex(
collectionId: collectionId,
); // Ensure index is up-to-date before searching
return service.searchHybrid(
query,
topK: topK,
vectorWeight: vectorWeight ?? defaultVectorWeight,
bm25Weight: bm25Weight ?? defaultBm25Weight,
sourceIds: sourceIds,
);
}