Single Document
Add one document at a time:src/add-single.ts
Parameters
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
Related
Indexing Basics
Understanding indexing
Updating Documents
Update existing documents
Removing Documents
Remove documents