Skip to main content
Learn how to add documents to your VectoriaDB index.

Single Document

Add one document at a time:
src/add-single.ts

Parameters

Validation

  • id must be unique (throws DocumentExistsError if duplicate)
  • text cannot be empty or whitespace-only
  • metadata.id must match the document id

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

For large imports, use addMany instead of calling add in a loop. Batch operations are significantly faster due to parallel embedding generation.

Indexing Basics

Understanding indexing

Updating Documents

Update existing documents

Removing Documents

Remove documents