MemoryVectorStore class

Lightweight, in-memory implementation of VectorStore in TypeScript.

Signature:

export declare class MemoryVectorStore implements VectorStore 

Implements: VectorStore

Methods

Method Modifiers Description
close() Closes the vector store.
delete(ids) Deletes records by their IDs.
deleteAll() Deletes all records.
deleteByMetadata(metadataFilter) Deletes records matching a metadata filter.
get(ids) Retrieves records by IDs.
getAllRecordIds() Gets all unique record IDs.
search(queryEmbedding, topK, metadataFilter) Searches for top-K matching records.
upsert(records) Upserts records into the vector store.

MemoryVectorStore.close()

Closes the vector store.

Signature:

close(): void;

Returns:

void

MemoryVectorStore.delete()

Deletes records by their IDs.

Signature:

delete(ids: readonly string[]): void;

Parameters

Parameter Type Description
ids readonly string[]

Returns:

void

MemoryVectorStore.deleteAll()

Deletes all records.

Signature:

deleteAll(): void;

Returns:

void

MemoryVectorStore.deleteByMetadata()

Deletes records matching a metadata filter.

Signature:

deleteByMetadata(metadataFilter: Record<string, string>): void;

Parameters

Parameter Type Description
metadataFilter Record<string, string>

Returns:

void

MemoryVectorStore.get()

Retrieves records by IDs.

Signature:

get(ids: readonly string[]): RetrievalRecord[];

Parameters

Parameter Type Description
ids readonly string[]

Returns:

RetrievalRecord[]

MemoryVectorStore.getAllRecordIds()

Gets all unique record IDs.

Signature:

getAllRecordIds(): string[];

Returns:

string[]

MemoryVectorStore.search()

Searches for top-K matching records.

Signature:

search(queryEmbedding: Float32Array | readonly number[], topK: number, metadataFilter?: Record<string, string>): RetrievalRecord[];

Parameters

Parameter Type Description
queryEmbedding Float32Array | readonly number[]
topK number
metadataFilter Record<string, string>

Returns:

RetrievalRecord[]

MemoryVectorStore.upsert()

Upserts records into the vector store.

Signature:

upsert(records: readonly RetrievalRecord[]): void;

Parameters

Parameter Type Description
records readonly RetrievalRecord[]

Returns:

void