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

Hierarchy

  • SaveableVectorStore
    • USearch

Constructors

Properties

FilterType: string | object
embeddings: EmbeddingsInterface

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

    • OptionalkOrFields: number | Partial<VectorStoreRetrieverInput<USearch>>
    • Optionalfilter: string | object
    • Optionalcallbacks: Callbacks
    • Optionaltags: string[]
    • Optionalmetadata: Record<string, unknown>
    • Optionalverbose: boolean

    Returns VectorStoreRetriever<USearch>

  • Parameters

    • Optional_params: Record<string, any>

    Returns Promise<void>

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

    Parameters

    • query: string

      Text to look up documents similar to.

    • options: MaxMarginalRelevanceSearchOptions<string | object>
    • _callbacks: undefined | Callbacks

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

    • List of documents selected by maximal marginal relevance.
  • 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
    • Optionalk: number
    • Optionalfilter: 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
    • Optionalk: number
    • Optionalfilter: string | object
    • Optional_callbacks: Callbacks

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

  • Returns Serialized

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

      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.

    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.

    Returns Promise<USearch>

    A promise that resolves with a new USearch instance.

  • Parameters

    • _directory: string
    • _embeddings: EmbeddingsInterface

    Returns Promise<SaveableVectorStore>