langchain_community.vectorstores.azure_cosmos_db.AzureCosmosDBVectorSearch¶
class langchain_community.vectorstores.azure_cosmos_db.AzureCosmosDBVectorSearch(collection: Collection[CosmosDBDocumentType], embedding: Embeddings, *, index_name: str = 'vectorSearchIndex', text_key: str = 'textContent', embedding_key: str = 'vectorContent')[source]¶
Azure Cosmos DB for MongoDB vCore vector store.
To use, you should have both:
- the pymongo python package installed
- a connection string associated with a MongoDB VCore Cluster
Example
. code-block:: python
from langchain_community.vectorstores import AzureCosmosDBVectorSearch
from langchain_community.embeddings.openai import OpenAIEmbeddings
from pymongo import MongoClient
mongo_client = MongoClient(“<YOUR-CONNECTION-STRING>”)
collection = mongo_client[“<db_name>”][“<collection_name>”]
embeddings = OpenAIEmbeddings()
vectorstore = AzureCosmosDBVectorSearch(collection, embeddings)
Constructor for AzureCosmosDBVectorSearch
Parameters
collection – MongoDB collection to add the texts to.
embedding – Text embedding model to use.
index_name – Name of the Atlas Search index.
text_key – MongoDB field that will contain the text
for each document.
embedding_key – MongoDB field that will contain the embedding
for each document.
Attributes
embeddings
Access the query embedding object if available.
Methods
__init__(collection, embedding, *[, ...])
Constructor for AzureCosmosDBVectorSearch
aadd_documents(documents, **kwargs)
Run more documents through the embeddings and add to the vectorstore.
aadd_texts(texts[, metadatas])
Run more texts through the embeddings and add to the vectorstore.
add_documents(documents, **kwargs)