QVAC Logo

ragSearch( )

Searches for similar documents in the RAG vector database.

function ragSearch(params): Promise<RagSearchResult[]>;

Parameters

NameTypeRequired?DefaultDescription
params.modelIdstringThe embedding model identifier
params.querystringThe search query text
params.topKnumber5Number of top results to retrieve
params.nnumber3Number of centroids for IVF index search
params.workspacestring"default"Workspace to search in

Returns

Promise<RagSearchResult[]> — Array of search results. Empty array if workspace doesn't exist.

FieldTypeDescription
idstringDocument identifier
contentstringDocument text content
scorenumberSimilarity score

Throws

ErrorWhen
RAG_SEARCH_FAILEDThe search operation fails

Example

const results = await ragSearch({
  modelId,
  query: "AI and machine learning",
  topK: 5,
  workspace: "my-docs",
});

On this page