Deprecated

use MongoDBAtlasVectorSearch instead.

Hierarchy

Constructors

Properties

client: MongoClient
collection: Collection<Document>
embeddings: Embeddings
indexName: string

Methods

  • Method that adds documents to the MongoDB collection. It first converts the documents into vectors using the embedDocuments method of the embeddings instance, and then adds these vectors to the collection.

    Parameters

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

      Array of Document instances to be added to the MongoDB collection.

    Returns Promise<void>

    Promise that resolves when the documents have been added to the collection.

  • Method that adds vectors to the MongoDB collection. It creates an array of items, each containing the content, embedding, and metadata of a document, and then inserts these items into the collection.

    Parameters

    • vectors: number[][]

      Array of vectors to be added to the MongoDB collection.

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

      Array of Document instances corresponding to the vectors.

    Returns Promise<void>

    Promise that resolves when the vectors have been added to the collection.

  • Parameters

    • Optional _params: Record<string, any>

    Returns Promise<void>

  • Parameters

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

  • Method that performs a similarity search on vectors and returns the documents and their similarity scores. It constructs a MongoDB aggregation pipeline, applies any post-query pipeline steps if provided, and then executes the pipeline to retrieve the results.

    Parameters

    • query: number[]

      Query vector for the similarity search.

    • k: number

      Number of nearest neighbors to return.

    • Optional filter: MongoVectorStoreQueryExtension

      Optional filter for the query, which can include post-query pipeline steps.

    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

    Returns Promise<[Document<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<Document<Record<string, any>>[]>

    • List of documents selected by maximal marginal relevance.
  • Static method that creates a MongoVectorStore instance from an array of Document instances. It creates a new MongoVectorStore instance, adds the documents to it, and then returns the instance.

    Parameters

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

      Array of Document instances to be added to the MongoVectorStore.

    • embeddings: Embeddings

      Embeddings instance used to convert the documents into vectors.

    • dbConfig: MongoLibArgs

      Configuration for the MongoDB database.

    Returns Promise<MongoVectorStore>

    Promise that resolves to a new MongoVectorStore instance.

  • Static method that creates a MongoVectorStore instance from an array of texts. It creates Document instances from the texts and their corresponding metadata, and then calls the fromDocuments method to create the MongoVectorStore instance.

    Parameters

    • texts: string[]

      Array of texts to be converted into Document instances.

    • metadatas: object | object[]

      Array or single object of metadata corresponding to the texts.

    • embeddings: Embeddings

      Embeddings instance used to convert the texts into vectors.

    • dbConfig: MongoLibArgs

      Configuration for the MongoDB database.

    Returns Promise<MongoVectorStore>

    Promise that resolves to a new MongoVectorStore instance.

Generated using TypeDoc