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

Hierarchy

Constructors

Properties

FilterType: string | object

Accessors

  • get index(): Index
  • Returns Index

  • set index(value): void
  • Parameters

    • value: Index

    Returns void

Methods

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

    Parameters

    • documents: Document<Record<string, any>>[]

      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<Record<string, any>>[]

      An array of Document instances corresponding to the vectors.

    Returns Promise<string[]>

    A promise that resolves with an array of document IDs.

  • Parameters

    • Optional _params: Record<string, any>

    Returns Promise<void>

  • 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.

  • Parameters

    • query: string
    • Optional k: number
    • Optional filter: string | object
    • Optional _callbacks: Callbacks

    Returns Promise<DocumentInterface<Record<string, any>>[]>

  • 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<Record<string, any>>, number][]>

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

  • Parameters

    • query: string
    • Optional k: number
    • Optional filter: string | object
    • Optional _callbacks: Callbacks

    Returns Promise<[DocumentInterface<Record<string, any>>, number][]>

  • Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.

    Parameters

    Returns Promise<DocumentInterface<Record<string, any>>[]>

    • List of documents selected by maximal marginal relevance.
  • 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

    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.

    • Optional dbConfig: {
          docstore?: SynchronousInMemoryDocstore;
      }

      Optional configuration for the document store.

    Returns Promise<USearch>

    A promise that resolves with a new USearch instance.

Generated using TypeDoc