In-memory vector store implementing cosine-similarity nearest-neighbor search and metadata filtering.
Signature:
export declare class MemoryVectorStore implements VectorStore
Methods
| Method | Description |
|---|---|
| close() | Clears all in-memory records and releases resources. |
| delete(recordIds) | Deletes records by their IDs. |
| deleteAll() | Removes all records from the store. |
| deleteByMetadata(filter) | Deletes all records matching the given metadata key-value filter. |
| get(recordIds) | Retrieves records by their IDs. |
| getAllRecordIds() | Returns all record IDs currently stored. |
| search(queryEmbedding, limit, metadataFilter) | Searches for the top-k most similar records using cosine similarity. |
| upsert(records) | Inserts or updates one or more RetrievalRecord entries. |
MemoryVectorStore.close()
Clears all in-memory records and releases resources.
Signature:
close(): Promise<void>;
Returns:
Promise<void>
MemoryVectorStore.delete()
Deletes records by their IDs.
Signature:
delete(recordIds: string[]): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| recordIds | string[] | Array of record IDs to remove. |
Returns:
Promise<void>
MemoryVectorStore.deleteAll()
Removes all records from the store.
Signature:
deleteAll(): Promise<void>;
Returns:
Promise<void>
MemoryVectorStore.deleteByMetadata()
Deletes all records matching the given metadata key-value filter.
Signature:
deleteByMetadata(filter: Record<string, string>): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| filter | Record<string, string> | Key-value metadata filter. |
Returns:
Promise<void>
MemoryVectorStore.get()
Retrieves records by their IDs.
Signature:
get(recordIds: string[]): Promise<RetrievalRecord[]>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| recordIds | string[] | Array of record IDs to fetch. |
Returns:
Promise<RetrievalRecord[]>
MemoryVectorStore.getAllRecordIds()
Returns all record IDs currently stored.
Signature:
getAllRecordIds(): Promise<string[]>;
Returns:
Promise<string[]>
MemoryVectorStore.search()
Searches for the top-k most similar records using cosine similarity.
Signature:
search(queryEmbedding: Float32Array | number[], limit: number, metadataFilter?: Record<string, string>): Promise<Array<{ record: RetrievalRecord; score: number }>>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| queryEmbedding | Float32Array | number[] | Query embedding vector. |
| limit | number | Maximum number of results to return. |
| metadataFilter | Record<string, string> | Optional key-value metadata filter. |
Returns:
Promise<Array<{ record: RetrievalRecord; score: number }>>
MemoryVectorStore.upsert()
Inserts or updates one or more RetrievalRecord entries.
Signature:
upsert(records: RetrievalRecord[]): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| records | RetrievalRecord[] | Records to insert or update. |
Returns:
Promise<void>