feat(TRUEREF-0023): add sqlite-vec search pipeline
This commit is contained in:
@@ -148,7 +148,12 @@ export class HybridSearchService {
|
||||
|
||||
const topIds = vectorResults.slice(0, limit).map((r) => r.snippetId);
|
||||
return {
|
||||
results: this.fetchSnippetsByIds(topIds, options.repositoryId, options.type),
|
||||
results: this.fetchSnippetsByIds(
|
||||
topIds,
|
||||
options.repositoryId,
|
||||
options.versionId,
|
||||
options.type
|
||||
),
|
||||
searchModeUsed: 'semantic'
|
||||
};
|
||||
}
|
||||
@@ -194,7 +199,12 @@ export class HybridSearchService {
|
||||
|
||||
const topIds = vectorResults.slice(0, limit).map((r) => r.snippetId);
|
||||
return {
|
||||
results: this.fetchSnippetsByIds(topIds, options.repositoryId, options.type),
|
||||
results: this.fetchSnippetsByIds(
|
||||
topIds,
|
||||
options.repositoryId,
|
||||
options.versionId,
|
||||
options.type
|
||||
),
|
||||
searchModeUsed: 'keyword_fallback'
|
||||
};
|
||||
}
|
||||
@@ -220,7 +230,12 @@ export class HybridSearchService {
|
||||
if (alpha === 1) {
|
||||
const topIds = vectorResults.slice(0, limit).map((r) => r.snippetId);
|
||||
return {
|
||||
results: this.fetchSnippetsByIds(topIds, options.repositoryId, options.type),
|
||||
results: this.fetchSnippetsByIds(
|
||||
topIds,
|
||||
options.repositoryId,
|
||||
options.versionId,
|
||||
options.type
|
||||
),
|
||||
searchModeUsed: 'semantic'
|
||||
};
|
||||
}
|
||||
@@ -234,7 +249,12 @@ export class HybridSearchService {
|
||||
|
||||
const topIds = fused.slice(0, limit).map((r) => r.id);
|
||||
return {
|
||||
results: this.fetchSnippetsByIds(topIds, options.repositoryId, options.type),
|
||||
results: this.fetchSnippetsByIds(
|
||||
topIds,
|
||||
options.repositoryId,
|
||||
options.versionId,
|
||||
options.type
|
||||
),
|
||||
searchModeUsed: 'hybrid'
|
||||
};
|
||||
}
|
||||
@@ -253,13 +273,19 @@ export class HybridSearchService {
|
||||
private fetchSnippetsByIds(
|
||||
ids: string[],
|
||||
repositoryId: string,
|
||||
versionId?: string,
|
||||
type?: 'code' | 'info'
|
||||
): SnippetSearchResult[] {
|
||||
if (ids.length === 0) return [];
|
||||
|
||||
const placeholders = ids.map(() => '?').join(', ');
|
||||
const params: unknown[] = [...ids, repositoryId];
|
||||
let versionClause = '';
|
||||
let typeClause = '';
|
||||
if (versionId !== undefined) {
|
||||
versionClause = ' AND s.version_id = ?';
|
||||
params.push(versionId);
|
||||
}
|
||||
if (type !== undefined) {
|
||||
typeClause = ' AND s.type = ?';
|
||||
params.push(type);
|
||||
@@ -276,7 +302,7 @@ export class HybridSearchService {
|
||||
FROM snippets s
|
||||
JOIN repositories r ON r.id = s.repository_id
|
||||
WHERE s.id IN (${placeholders})
|
||||
AND s.repository_id = ?${typeClause}`
|
||||
AND s.repository_id = ?${versionClause}${typeClause}`
|
||||
)
|
||||
.all(...params) as RawSnippetById[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user