UNPKG

hnswsqlite

Version:

Vector search with HNSWlib and SQLite in TypeScript.

37 lines (36 loc) 1.12 kB
export declare class VectorStore { private db; private index; private dim; private idMap; private preparedStatements; constructor(dbPath: string, dim?: number); private _initTables; private _initPreparedStatements; private _initIndex; private _loadEmbeddings; addDocument(text: string, embedding: number[]): number; /** * Search for similar documents using vector similarity * @param embedding - The query embedding vector * @param k - Number of nearest neighbors to return * @returns Array of matching documents with id and text */ search(embedding: number[], k?: number): Array<{ id: number; text: string; }>; /** * Delete a document by ID * @param id - The ID of the document to delete * @returns boolean indicating success */ deleteDocument(id: number): boolean; /** * Batch delete multiple documents * @param ids - Array of document IDs to delete * @returns number of successfully deleted documents */ deleteDocuments(ids: number[]): number; close(): void; }