Build a semantic search index in just a few lines of code.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.
Basic Example
src/index.ts
You now have a working semantic search index.
initialize() must run before add, search, or update. Calling it twice is safe because VectoriaDB short-circuits if it is already ready.Step-by-Step Breakdown
1. Define Metadata Interface
src/types.ts
2. Create and Initialize
src/setup.ts
3. Add Documents
src/add.ts
4. Search
src/search.ts
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
modelName | string | 'Xenova/all-MiniLM-L6-v2' | Embedding model to use |
cacheDir | string | './.cache/transformers' | Model cache directory |
dimensions | number | Auto-detected | Vector dimensions |
defaultSimilarityThreshold | number | 0.3 | Minimum similarity score |
defaultTopK | number | 10 | Default results limit |
useHNSW | boolean | false | Enable HNSW index |
maxDocuments | number | 100000 | Max documents (DoS protection) |
maxDocumentSize | number | 1000000 | Max document size in chars |
maxBatchSize | number | 1000 | Max batch operation size |
verboseErrors | boolean | true | Enable detailed errors |
Next Steps
Adding Documents
Learn about indexing options
Search
Master search queries
Persistence
Persist embeddings between restarts
HNSW Scaling
Scale to large datasets