Learn how to add documents to your VectoriaDB index.Documentation Index
Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
Use this file to discover all available pages before exploring further.
Single Document
Add one document at a time:src/add-single.ts
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Unique document identifier |
text | string | Natural language text to embed |
metadata | T | Type-safe metadata object |
Validation
idmust be unique (throwsDocumentExistsErrorif duplicate)textcannot be empty or whitespace-onlymetadata.idmust match the documentid
Batch Indexing
Add multiple documents efficiently:src/batch-index.ts
addMany validates every document, enforces maxBatchSize, and prevents duplicates.
Batch Validation
Before processing,addMany checks:
- No duplicate IDs within the batch
- No IDs that already exist in the database
- All texts are non-empty
- All texts are within
maxDocumentSize - Batch size doesn’t exceed
maxBatchSize
Checking for Documents
src/check-documents.ts
Error Handling
src/add-error-handling.ts
Performance Tips
Recommended Batch Sizes
| Documents | Batch Size | Reasoning |
|---|---|---|
| < 100 | All at once | Minimal overhead |
| 100 - 1,000 | 100-500 | Good balance |
| > 1,000 | 500-1,000 | Avoid memory spikes |
Related
Indexing Basics
Understanding indexing
Updating Documents
Update existing documents
Removing Documents
Remove documents