Skip to main content
This notebook shows you how to leverage this integrated vector database to store documents in collections, create indices and perform vector search queries using approximate nearest neighbor algorithms such as COS (cosine distance), L2 (Euclidean distance), and IP (inner product) to locate documents close to the query vectors. Azure Cosmos DB is the database that powers OpenAI’s ChatGPT service. It offers single-digit millisecond response times, automatic and instant scalability, along with guaranteed speed at any scale. Azure Cosmos DB for MongoDB vCore provides developers with a fully managed MongoDB-compatible database service for building modern applications with a familiar architecture. You can apply your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB vCore account’s connection string. Sign Up for lifetime free access to get started today.
We want to use AzureOpenAIEmbeddings so we need to set up our Azure OpenAI API Key alongside other environment variables.
Now, we need to load the documents into the collection, create the index and then run our queries against the index to retrieve matches. Please refer to the documentation if you have questions about certain parameters
The langchain-community package is no longer maintained. Examples that import from langchain_community may be outdated or broken. Use with caution.
Once the documents have been loaded and the index has been created, you can now instantiate the vector store directly and run queries against the index

Filtered vector search (Preview)

Azure Cosmos DB for MongoDB supports pre-filtering with $lt, $lte, $eq, $neq, $gte, $gt, $in, $nin, and $regex. To use this feature, enable "filtering vector search" in the “Preview Features” tab of your Azure Subscription. Learn more about filtered vector search preview features.