MCPcopy Index your code
hub / github.com/simstudioai/sim / handleTagAndVectorSearch

Function handleTagAndVectorSearch

apps/sim/app/api/knowledge/search/utils.ts:515–539  ·  view source on GitHub ↗
(params: SearchParams)

Source from the content-addressed store, hash-verified

513}
514
515export async function handleTagAndVectorSearch(params: SearchParams): Promise<SearchResult[]> {
516 const { knowledgeBaseIds, topK, structuredFilters, queryVector, distanceThreshold } = params
517
518 if (!structuredFilters || structuredFilters.length === 0) {
519 throw new Error('Tag filters are required for tag and vector search')
520 }
521 if (!queryVector || !distanceThreshold) {
522 throw new Error('Query vector and distance threshold are required for tag and vector search')
523 }
524
525 // Step 1: Filter by tags first
526 const tagFilteredIds = await executeTagFilterQuery(knowledgeBaseIds, structuredFilters)
527
528 if (tagFilteredIds.length === 0) {
529 return []
530 }
531
532 // Step 2: Perform vector search only on tag-filtered results
533 return await executeVectorSearchOnIds(
534 tagFilteredIds.map((r) => r.id),
535 queryVector,
536 topK,
537 distanceThreshold
538 )
539}

Callers 3

utils.test.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

executeTagFilterQueryFunction · 0.85
executeVectorSearchOnIdsFunction · 0.85

Tested by

no test coverage detected