SqliteVectorStore
final class SqliteVectorStore: Sendable, VectorStoreSQLite-backed VectorStore using native SQLite cosine-similarity indexing.
@unchecked Sendable is safe because the lazy SQLite handle cStore and all native database operations are serialized through lock.
-
Default embedding vector dimensionality (
768).Declaration
Swift
static let defaultEmbeddingDimension: Int -
Creates a SQLite vector store whose underlying database connection opens lazily on first use.
Declaration
Swift
init(databasePath: String = ":memory:", embeddingDimension: Int = SqliteVectorStore.defaultEmbeddingDimension) -
Filesystem path to the SQLite database file, or
":memory:"/""for an in-memory store.Declaration
Swift
final let databasePath: String -
Expected vector dimensionality for stored and queried embeddings.
Declaration
Swift
final let embeddingDimension: Int -
Deletes all records matching
ids, along with any associated child rows.Declaration
Swift
final func delete(ids: [String]) throws -
Deletes all records matching every
metadataFilterpair, along with associated child rows.Declaration
Swift
final func delete(metadataFilter: [String: String]) throws -
Deletes every record in the store.
Declaration
Swift
final func deleteAllRecords() throws -
Returns all top-level record identifiers in the store (excluding child chunk or part rows).
Declaration
Swift
final func recordIdentifiers() throws -> [String] -
Returns all stored records matching
ids.Declaration
Swift
final func records(ids: [String]) throws -> [RetrievalRecord] -
Searches for up to
limitrecords whose similarity toembeddingis at leastminSimilarity, optionally restricted to records matching everymetadataFilterpair.Declaration
Swift
final func search(embedding: [Float], limit: Int, minSimilarity: Float, metadataFilter: [String: String]?) throws -> [RetrievalRecord] -
Inserts or replaces
recordsafter validating all inputs upfront.Declaration
Swift
final func upsertRecords(_ records: [RetrievalRecord]) throws