Class InMemoryVectorStore

Implements the IVectorStore interface using in-memory data structures. Provides a simple, fast vector store primarily for development and testing.

InMemoryVectorStore

Implements

Implements

Constructors

Methods

  • Initializes the vector store provider with its specific configuration. This method must be called before any other operations can be performed. It sets up connections, authenticates, and prepares the store for use.

    Parameters

    • config: VectorStoreProviderConfig

      The configuration object specific to this vector store provider. This is typically a more specific type that extends VectorStoreProviderConfig.

    Returns Promise<void>

    A promise that resolves when initialization is complete.

    Async

    Throws

    If initialization fails (e.g., invalid configuration, connection error, authentication failure).

  • Checks if a collection with the given name exists in the vector store.

    Parameters

    • collectionName: string

      The name of the collection to check.

    Returns Promise<boolean>

    A promise that resolves with true if the collection exists, false otherwise.

    Async

    Throws

    If the check fails for reasons other than existence (e.g., connection issue).

  • Deletes an entire collection from the vector store. This is a destructive operation.

    Parameters

    • collectionName: string

      The name of the collection to delete.

    Returns Promise<void>

    A promise that resolves when the collection is successfully deleted.

    Async

    Throws

    If collection deletion fails.

  • Upserts (inserts or updates) a batch of documents into a specified collection. If a document with the same ID already exists, it is typically updated; otherwise, it's inserted.

    Parameters

    • collectionName: string

      The name of the collection (or index, class, etc.) to upsert documents into.

    • documents: VectorDocument[]

      An array of documents to upsert.

    • Optional options: UpsertOptions

      Optional parameters for the upsert operation.

    Returns Promise<UpsertResult>

    A promise that resolves with the result of the upsert operation.

    Async

    Throws

    If the upsert operation fails critically.

  • Queries a specified collection for documents similar to the provided query embedding.

    Parameters

    • collectionName: string

      The name of the collection to query.

    • queryEmbedding: number[]

      The query vector embedding.

    • Optional options: QueryOptions

      Optional parameters for the query operation, including filters and topK.

    Returns Promise<QueryResult>

    A promise that resolves with the query results.

    Async

    Throws

    If the query operation fails.

  • Deletes documents from a specified collection by their IDs or by a metadata filter.

    Parameters

    • collectionName: string

      The name of the collection to delete documents from.

    • Optional ids: string[]

      An array of document IDs to delete.

    • Optional options: DeleteOptions

      Optional parameters, including metadata filters or a deleteAll flag. If ids are provided, options.filter might be ignored or combined, depending on store behavior. Use with caution.

    Returns Promise<DeleteResult>

    A promise that resolves with the result of the delete operation.

    Async

    Throws

    If the delete operation fails.

  • Checks the operational health of the vector store provider. This might involve pinging the service, checking connection status, or verifying authentication.

    Returns Promise<{
        isHealthy: boolean;
        details?: any;
    }>

    A promise that resolves with the health status. details can include specific error messages or status information.

    Async

  • Optional: Retrieves statistics about a specific collection or the store itself. The structure of the returned statistics is provider-dependent.

    Parameters

    • Optional collectionName: string

      Optional: The name of the collection to get stats for. If omitted, may return store-wide stats if supported.

    Returns Promise<Record<string, any>>

    A promise that resolves with a statistics object.

    Async

    Throws

    If fetching statistics fails.