QVAC Logo

ragReindex( )

Reindexes the RAG database to optimize search performance. For HyperDB, this rebalances centroids using k-means clustering. **Workspace lifecycle:** This operation requires an existing workspace. **Note:** Reindex requires a minimum number of documents to perform clustering. For HyperDB, this is 16 documents by default. If there are insufficient documents, `reindexed` will be `false` with `details` explaining the reason.

function ragReindex(params: RagReindexParams, options?: { forceNewConnection?: boolean; profiling?: { enabled?: boolean; includeServerBreakdown?: boolean; mode?: "summary" | "verbose" }; timeout?: number }): Promise

Parameters

NameTypeRequired?Description
paramsRagReindexParamsThe parameters for reindexing
options`{ forceNewConnection?: boolean; profiling?: { enabled?: boolean; includeServerBreakdown?: boolean; mode?: "summary""verbose" }; timeout?: number }`

Returns

Promise

Throws

ErrorWhen
When the operation fails or workspace doesn't exist
When streaming ends unexpectedly (only when using onProgress)

Example

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

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

// With progress tracking
const result = await ragReindex({
  workspace: "my-docs",
  onProgress: (stage, current, total) => {
    console.log(`[${stage}] ${current}/${total}`);
  },
});

On this page