Store API Reference
Complete API reference for theStore interface and SqliteStore implementation.
Store Interface
Vector store interface for saving and searching embeddings./home/daytona/workspace/source/packages/retrieval/src/lib/stores/store.ts:26-41
Methods
search()
Search for similar content using vector similarity.query- Search query textoptions- Search optionsembedder- Embedding function
sourceExists()
Check if a source has been ingested.sourceId- Source identifier
true if source exists, false otherwise.
sourceExpired()
Check if a source has expired.sourceId- Source identifier
true if source is expired, false otherwise.
setSourceExpiry()
Set expiration date for a source.sourceId- Source identifierexpiryDate- Expiration date
index()
Index a document corpus (called byingest()).
sourceId- Source identifiercorpus- Document corpus to indexexpiryDate- Optional expiry date
Type Definitions
SearchOptions
string
Source to search within.
documentId - string (optional)
Restrict search to specific document.
topN - number (optional)
Number of results to return.
Corpus
Chunk
Embedder
SqliteStore
SQLite-based vector store implementation.Constructor
db- Database instance (better-sqlite3)dimension- Embedding dimensions (must match model)
Database Schema
The store creates these tables: sourcesInternal Methods
These methods are used internally:upsertDoc()
changes property.
insertDoc()
delete()
Vector Operations
vectorToBlob()
Convert vector to SQLite blob.vector- Embedding vector
Normalization
Embeddings are normalized before storage:Search Implementation
Search uses sqlite-vec’s MATCH operator:Transactions
Batch operations use transactions:Complete Example
Performance Considerations
Embedding Dimensions
Dimensions must match between store and embedder:Batch Size
Default batch size (32) balances performance and memory:Index Performance
SQLite-vec uses HNSW indexing for fast similarity search. Performance scales well to millions of vectors.Memory Usage
In-memory databases are fast but limited by RAM:Error Handling
Database Errors
Dimension Mismatch
Transaction Failures
Transactions automatically rollback on error:Best Practices
Match Dimensions Always ensure store dimensions match embedder:SQLite Configuration
Optimize SQLite for better performance:Next Steps
Core API
ingest() and similaritySearch() reference
Connector API
Connector interface reference
Ingestion
Learn about ingestion
Search
Learn about search