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

  • VectorStore
    • AnalyticDBVectorStore

Constructors

Properties

FilterType: Record<string, any>
embeddings: EmbeddingsInterface

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.

  • Parameters

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

    Returns VectorStoreRetriever<AnalyticDBVectorStore>

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

  • 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<Record<string, any>>
    • _callbacks: undefined | Callbacks

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

    • List of documents selected by maximal marginal relevance.
  • Parameters

    • query: string
    • Optionalk: number
    • Optionalfilter: 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.

    • Optionalfilter: 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
    • Optionalk: number
    • Optionalfilter: Record<string, any>
    • Optional_callbacks: Callbacks

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

  • Returns Serialized

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

    Parameters

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

      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.