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 NoSQL now offers vector indexing and search in preview. This feature is designed to handle high-dimensional vectors, enabling efficient and accurate vector search at any scale. You can now store vectors directly in the documents alongside your data. This means that each document in your database can contain not only traditional schema-free data, but also high-dimensional vectors as other properties of the documents. This colocation of data and vectors allows for efficient indexing and searching, as the vectors are stored in the same logical unit as the data they represent. This simplifies data management, AI application architectures, and the efficiency of vector-based operations. Please refer here for more details: Sign Up for lifetime free access to get started today.
As of langchain-azure-cosmosdb v1.0, all Azure Cosmos DB NoSQL integrations (vector store, semantic cache, chat message history, and the LangGraph checkpointer, cache, and store) ship from the standalone langchain-azure-cosmosdb package and import from langchain_azure_cosmosdb. Both sync and async clients, as well as Microsoft Entra ID (DefaultAzureCredential) auth, are supported.

Insert data

The langchain-community package is no longer maintained. Examples that import from langchain_community may be outdated or broken. Use with caution.

Vector search with score

Vector search with filtering

Full text search BM 25 ranking

Hybrid search with filtering

Hybrid search with custom projection