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): PromiseDescription
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
| Name | Type | Required? | Description |
|---|---|---|---|
params | any | ✓ | The parameters for reindexing |
Returns
PromiseExamples
// 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}`);
},
});ragListWorkspaces( )
Lists all RAG workspaces with their open status. Returns all workspaces that exist on disk. The `open` field indicates whether the workspace is currently loaded in memory and holding active resources (Corestore, HyperDB adapter, and possibly a RAG instance).
ragSaveEmbeddings( )
Saves pre-embedded documents to the RAG vector database. Part of the segregated flow: chunk() → embed() → saveEmbeddings() **Workspace lifecycle:** This operation implicitly opens (or creates) the workspace. The workspace remains open until closed.