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

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

      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.

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

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

  • Creates an instance of AnalyticDBVectorStore from an array of Document instances. The documents are added to the collection.

    Parameters

    • docs: Document[]

      Array of Document instances to be added to the collection.

    • embeddings: EmbeddingsInterface

      Embeddings instance used to convert the documents to vectors.

    • dbConfig: AnalyticDBArgs

      Configuration for the AnalyticDB.

    Returns Promise<AnalyticDBVectorStore>

    Promise that resolves to an instance of AnalyticDBVectorStore.

  • 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