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: any): Promise

Description

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.

Parameters

NameTypeRequired?Description
paramsanyThe parameters for reindexing

Returns

Promise

Examples

// 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