Class that provides methods for creating and managing a collection of documents in an AnalyticDB, adding documents or vectors to the collection, performing similarity search on vectors, and creating an instance of AnalyticDBVectorStore from texts or documents.

Hierarchy

Constructors

Properties

FilterType: Record<string, any>

Methods

  • Adds an array of documents to the collection. The documents are first converted to vectors using the embedDocuments method of the embeddings instance.

    Parameters

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

      Array of Document instances to be added to the collection.

    Returns Promise<void>

    Promise that resolves when the documents are added.

  • Adds an array of vectors and corresponding documents to the collection. The vectors and documents are batch inserted into the database.

    Parameters

    • vectors: number[][]

      Array of vectors to be added to the collection.

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

      Array of Document instances corresponding to the vectors.

    Returns Promise<void>

    Promise that resolves when the vectors and documents are added.

  • Creates a new collection in the database. If preDeleteCollection is true, any existing collection with the same name is deleted before the new collection is created.

    Returns Promise<void>

    Promise that resolves when the collection is created.

  • Creates a new table in the database if it does not already exist. The table is created with columns for id, embedding, document, and metadata. An index is also created on the embedding column if it does not already exist.

    Returns Promise<void>

    Promise that resolves when the table and index are created.

  • Parameters

    • Optional _params: Record<string, any>

    Returns Promise<void>

  • Parameters

    • query: string
    • Optional k: number
    • Optional filter: Record<string, any>
    • Optional _callbacks: Callbacks

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

  • Performs a similarity search on the vectors in the collection. The search is performed using the given query vector and returns the top k most similar vectors along with their corresponding documents and similarity scores.

    Parameters

    • query: number[]

      Query vector for the similarity search.

    • k: number

      Number of top similar vectors to return.

    • Optional filter: Record<string, any>

      Optional. Filter to apply on the metadata of the documents.

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

    Promise that resolves to an array of tuples, each containing a Document instance and its similarity score.

  • Parameters

    • query: string
    • Optional k: number
    • Optional filter: Record<string, any>
    • 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.
  • Creates an instance of AnalyticDBVectorStore from an array of texts and corresponding metadata. The texts are first converted to Document instances before being added to the collection.

    Parameters

    • texts: string[]

      Array of texts to be added to the collection.

    • metadatas: object | object[]

      Array or object of metadata corresponding to the texts.

    • embeddings: EmbeddingsInterface

      Embeddings instance used to convert the texts to vectors.

    • dbConfig: AnalyticDBArgs

      Configuration for the AnalyticDB.

    Returns Promise<AnalyticDBVectorStore>

    Promise that resolves to an instance of AnalyticDBVectorStore.

Generated using TypeDoc