searchMeta method
Low-level metadata-first hybrid search lane.
Returns a generation-pinned SearchMetaResult. The returned handle must be disposed when no longer needed.
Implementation
Future<SearchMetaResult> searchMeta(
String query, {
int topK = 10,
double vectorWeight = kDefaultVectorWeight,
double bm25Weight = kDefaultBm25Weight,
List<int>? sourceIds,
int adjacentChunks = 0,
}) async {
final normalizedWeights = normalizeHybridWeights(
vectorWeight: vectorWeight,
bm25Weight: bm25Weight,
context: 'SourceRagService.searchMeta',
);
final queryEmbedding = await EmbeddingService.embed(query);
await rust_rag.activateCollectionForHybridSearch(
collectionId: collectionId,
basePath: _indexPath,
);
try {
final handle = await rust_rag.searchMetaHybrid(
collectionId: collectionId,
queryText: query,
queryEmbedding: queryEmbedding,
options: rust_rag.SearchMetaHybridOptions(
topK: topK,
vectorWeight: normalizedWeights.vectorWeight,
bm25Weight: normalizedWeights.bm25Weight,
sourceIds: sourceIds != null ? _toInt64List(sourceIds) : null,
adjacentChunks: adjacentChunks,
),
);
final hits = await handle.hitMeta();
return SearchMetaResult(handle: handle, hits: hits);
} on RagError catch (e) {
e.when(
databaseError: (msg) =>
debugPrint('[SmartError] searchMeta DB error: $msg'),
ioError: (msg) => debugPrint('[SmartError] searchMeta IO error: $msg'),
modelLoadError: (_) {},
invalidInput: (msg) =>
debugPrint('[SmartError] searchMeta invalid input: $msg'),
staleSearchHandle: (msg) =>
debugPrint('[SmartError] searchMeta stale handle: $msg'),
concurrentMutation: (msg) => debugPrint(
'[SmartError] searchMeta concurrent mutation: $msg',
),
internalError: (msg) =>
debugPrint('[SmartError] searchMeta internal error: $msg'),
unknown: (msg) => debugPrint('[SmartError] searchMeta unknown: $msg'),
);
rethrow;
}
}