Class that extends SaveableVectorStore and provides methods for adding documents and vectors to a usearch index, performing similarity searches, and saving the index.

Hierarchy (view full)

Constructors

Properties

docstore: SynchronousInMemoryDocstore

Accessors

Methods

  • Method that adds documents to the usearch index. It generates embeddings for the documents and adds them to the index.

    Parameters

    • documents: Document[]

      An array of Document instances to be added to the index.

    Returns Promise<string[]>

    A promise that resolves with an array of document IDs.

  • Method that adds vectors to the usearch index. It also updates the mapping between vector IDs and document IDs.

    Parameters

    • vectors: number[][]

      An array of vectors to be added to the index.

    • documents: Document[]

      An array of Document instances corresponding to the vectors.

    Returns Promise<string[]>

    A promise that resolves with an array of document IDs.

  • Method that saves the usearch index and the document store to disk.

    Parameters

    • directory: string

      The directory where the index and document store should be saved.

    Returns Promise<void>

    A promise that resolves when the save operation is complete.

  • Method that performs a similarity search in the usearch index. It returns the k most similar documents to a given query vector, along with their similarity scores.

    Parameters

    • query: number[]

      The query vector.

    • k: number

      The number of most similar documents to return.

    Returns Promise<[Document, number][]>

    A promise that resolves with an array of tuples, each containing a Document and its similarity score.

  • Static method that creates a new USearch instance from a list of documents. It generates embeddings for the documents and adds them to the usearch index.

    Parameters

    • docs: Document[]

      An array of Document instances to be added to the index.

    • embeddings: EmbeddingsInterface

      An instance of Embeddings used to generate embeddings for the documents.

    • OptionaldbConfig: {
          docstore?: SynchronousInMemoryDocstore;
      }

      Optional configuration for the document store.

      • Optionaldocstore?: SynchronousInMemoryDocstore

    Returns Promise<USearch>

    A promise that resolves with a new USearch instance.

  • Static method that creates a new USearch instance from a list of texts. It generates embeddings for the texts and adds them to the usearch index.

    Parameters

    • texts: string[]

      An array of texts to be added to the index.

    • metadatas: object | object[]

      Metadata associated with the texts.

    • embeddings: EmbeddingsInterface

      An instance of Embeddings used to generate embeddings for the texts.

    • OptionaldbConfig: {
          docstore?: SynchronousInMemoryDocstore;
      }

      Optional configuration for the document store.

      • Optionaldocstore?: SynchronousInMemoryDocstore

    Returns Promise<USearch>

    A promise that resolves with a new USearch instance.