QVAC Logo

ragReindex( )

Reindexes the RAG database to optimize search performance.

function ragReindex(params): Promise<RagReindexResult>;

For HyperDB, rebalances centroids using k-means clustering. Requires a minimum number of documents (16 by default).

Parameters

NameTypeRequired?DefaultDescription
params.modelIdstringEmbedding model ID (required if no cached RAG instance)
params.workspacestring"default"Workspace to reindex. Must already exist.
params.onProgress(stage, current, total) => voidProgress callback

Returns

FieldTypeDescription
reindexedbooleanWhether reindexing was performed
detailsRecord<string, unknown>Additional details (e.g., reason if skipped) — optional

Throws

ErrorWhen
RAG_SAVE_FAILEDThe reindex operation fails or workspace doesn't exist
STREAM_ENDED_WITHOUT_RESPONSEStreaming ends unexpectedly (when using onProgress)

Example

const result = await ragReindex({ workspace: "my-docs" });

if (!result.reindexed) {
  console.log("Reindex skipped:", result.details?.reason);
}

On this page