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
_mapping: Record<number, string>
embeddings: Embeddings
lc_kwargs: SerializedFields
lc_namespace: string[] = ...

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

lc_serializable: boolean = false
_index?: Index

Accessors

  • get lc_aliases(): undefined | {
        [key: string]: string;
    }
  • A map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.

    Returns undefined | {
        [key: string]: string;
    }

  • get lc_attributes(): undefined | SerializedFields
  • A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.

    Returns undefined | SerializedFields

  • get lc_secrets(): undefined | {
        [key: string]: string;
    }
  • A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.

    Returns undefined | {
        [key: string]: string;
    }

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.

  • 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<Record<string, any>>, 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 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: Embeddings

      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