Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Vector search is a way to find information stored in a database in the shape of vectors. Vectors are groups of numbers that represent features or characteristics of media, such as text or images. They capture semantic relationships within the information, which enables similarity search beyond exact keyword matching.
Azure provides multiple ways to store and search vectorized data. This article helps you choose the right Azure vector search service for your applications.
This article compares the following services based on their vector search capabilities:
- Azure AI Search
- Azure Cosmos DB for NoSQL
- Azure DocumentDB
- Azure Database for PostgreSQL
- Azure Managed Redis
- Azure SQL Database
To compare the system requirements for each service, see Choose a candidate service and Capability matrix.
Choose a candidate service
This section helps you select the best service or services for your needs. To narrow the choices, start by considering the system requirements.
Key requirements
To decide whether to use a traditional database solution or AI Search, consider your requirements and whether you can perform live or real-time vector searches on your data. If you frequently change values in vectorized fields, and if those changes need to be searchable in real time or near real time, a traditional relational or NoSQL database is the best fit for your scenario. Similarly, your existing database might be the best way to meet your performance target. However, if your workload doesn't require real-time or near-real-time vector searchability, and you can manage an index of vectors, you can use AI Search.
If you choose a traditional database solution, choose a database service based on your team's skill set and your existing databases. If you already use a database service, such as Azure Cosmos DB for NoSQL, that service might be the easiest solution for your scenario.
Azure Cosmos DB for NoSQL is a good fit if you want to keep operational data and vector search in the same system and if you need full-text scoring, hybrid search, or built-in reranking.
AI Search might be a good choice if your workload requires first-class hybrid search and semantic ranking.
Azure Database for PostgreSQL supports horizontal scaling by using elastic clusters, a managed offering of the open-source Citus extension that supports horizontal sharding. This capability distributes vector data across multiple nodes, which can be useful for large vector datasets.
Consider Azure Managed Redis when you need ultra-low-latency, in-memory vector search or when Redis is already deployed for caching or session management.
Each database service has unique capabilities and limitations for vector search. Check that your database type has the required functionality.
New services and extra database instances can increase cost and complexity. To reduce overhead, you can continue to use your existing design. Vector search in your current databases might be more cost effective than a dedicated vector search service. However, some advanced search features aren't available by default in traditional databases. For example, if you need reranking or hybrid search, you can implement these capabilities by using code, such as Transact-SQL (T-SQL).
Capability matrix
The tables in this section summarize Azure vector search service capabilities. Compare the available services with your requirements. Some services are a better fit for specific scenarios, so consider the trade-offs shown in each table.
If you're working in Microsoft Fabric, you can use Real-Time Intelligence for vector similarity search (VSS) by using an eventhouse as a vector database. For more information, see the Fabric documentation.
Basic features
Native support for vector data types, approximate nearest neighbor (ANN) vector indexes, vector dimension limits, multiple vector fields, and multiple vector indexes varies across services. Your workload might require one or more of these features.
The following table shows the vector capabilities of each Azure service.
| Capability | Azure Cosmos DB for NoSQL | Azure DocumentDB | Azure Database for PostgreSQL | Azure Managed Redis | AI Search | SQL Database |
|---|---|---|---|---|---|---|
| Built-in vector search | Yes | Yes1 | Yes2 | Yes3 | Yes4 | Yes |
| Vector data type | Yes | Yes | Yes | Yes | Yes | Yes5 |
| Dimension limits6 | 5057 or 4,096 | 16,0008, 4,000, or 2,000, depending on the configuration | 16,0009 or 2,000 | 32,768 | 4,09610 | 1,998 11 |
| Multiple vector fields | Yes | No | Yes | Yes | Yes | Yes |
| Multiple vector indexes | Yes | No | Yes | Yes | Yes | Yes |
- Azure DocumentDB supports vector search on embeddings.
pgvector, an extension of PostgreSQL, supports vector search. Thepg_diskannextension offers DiskANN-based vector indexing for efficient ANN search at scale.- The RediSearch module in Azure Managed Redis provides vector search.
- AI Search supports vectors.
- SQL Database supports a vector data type.
- OpenAI embedding models include 1,536 dimensions for text-embedding-ada-002 and for text-embedding-3-small, and 3,072 dimensions for text-embedding-3-large. Azure Vision multimodal embedding models have 1,024 dimensions for both image and text.
- Vectors indexed by using the flat index type can have up to 505 dimensions. Vectors indexed by using the quantizedFlat or DiskANN index type can have up to 4,096 dimensions.
- You can index vectors up to 16,000 dimensions by using DiskANN and product quantization. Hierarchical navigable small world (HNSW) or IVFFlat with half-precision supports vector indexes of up to 4,000 dimensions. Without compression, the default maximum vector dimension for indexing is 2,000. For more information, see the vector dimensions for Azure DocumentDB.
- Vectors can have up to 16,000 dimensions. However, indexing by using IVFFlat and HNSW algorithms supports vectors with up to 2,000 dimensions.
- AI Search supports Matryoshka Representation Learning-based dimension truncation. Text-embedding-3 models can reduce vector dimensions. For example, you can use 256 or 512 dimensions.
- SQL Database supports a native vector data type with up to 1,998 dimensions.
Search methods
Workloads often need to combine vector search with full-text search or hybrid search. Hybrid search is a full-text search or semantic search combined with a vector search. When combined, hybrid search and reranking achieve high accuracy for workloads. You can manually implement hybrid search and reranking by using your own code, or you can consider how your vector store supports this workload requirement.
| Search method | Azure Cosmos DB for NoSQL | Azure DocumentDB | Azure Database for PostgreSQL | Azure Managed Redis | AI Search | SQL Database |
|---|---|---|---|---|---|---|
| Full-text search | Yes12 | Yes2 | Yes3 | Yes4 | Yes | Yes5 |
| Hybrid search | Yes6 | Yes7 | Yes8 | Yes9 | Yes10 | Yes11 |
| Built-in reranking | Yes | No | No | No | Yes1 | No |
- Semantic ranking reranks results of full-text and vector searches.
- Azure DocumentDB supports search and query by using text indexes.
- PostgreSQL supports full-text search.
- Azure Managed Redis supports full-text search by using the RediSearch module, including text tokenization, stemming, and ranking.
- SQL Server supports full-text search.
- Azure Cosmos DB for NoSQL supports hybrid search.
- Azure DocumentDB natively supports hybrid search that combines full-text and vector search with reciprocal rank fusion.
- Hybrid search isn't built in, but sample code is available.
- Azure Managed Redis supports hybrid search by using VSS combined with attribute filtering on text, numeric, tag, and geo fields.
- Hybrid search, which combines full-text search, vector search, and semantic ranking, is a feature in AI Search.
- An example of hybrid search for SQL Database and SQL Server is available.
- Azure Cosmos DB for NoSQL supports full-text search and full-text scoring.
Vector data indexing algorithms
Vector data indexing is the ability to efficiently store and retrieve vectors. Indexing influences the speed and accuracy of similarity searches and nearest neighbor queries on data sources.
Indexes typically use either an exhaustive k-nearest neighbor (Ek-NN) algorithm or an ANN algorithm. Ek-NN performs an exhaustive search on all data points and returns the accurate k nearest neighbors. When searching a small amount of data, Ek-NN works in milliseconds. For larger datasets, you might experience latency.
DiskANN, HNSW, and IVFFlat are ANN algorithm indexes. Selecting the appropriate indexing strategy requires careful consideration of various factors such as the nature of the dataset, the specific requirements of the queries, and the available resources. DiskANN can adapt to change in the dataset and save computational resources. HNSW excels in systems that require fast query responses and can adapt to changes in the dataset. IVFFlat is effective in environments where hardware resources are limited or query volumes aren't high.
The following table shows the available vector data indexing types.
| Indexing approach | Azure Cosmos DB for NoSQL | Azure DocumentDB | Azure Database for PostgreSQL | Azure Managed Redis | AI Search | SQL Database |
|---|---|---|---|---|---|---|
| DiskANN | Yes | Yes1 | Yes2 | No | No | Yes3 |
| Ek-NN | Yes | Yes | Yes | Yes4 | Yes | Yes |
| HNSW | No | Yes1 | Yes | Yes5 | Yes | No |
| IVFFlat | No | Yes | Yes | No | No | No |
| Other | Flat, quantizedFlat6 | Vector field limitation,7 vector index limitation8 |
- | - | Scalar quantization, binary quantization9 | - |
- For more information, see Integrated vector store in Azure DocumentDB.
- For more information, see DiskANN for Azure Database for PostgreSQL.
- Native DiskANN vector indexing is in preview. For more information, see Vector search and vector indexes in the SQL Database Engine.
- Azure Managed Redis supports Ek-NN search by using the FLAT index type for brute-force search.
- Azure Managed Redis supports HNSW for ANN search. For more information, see VSS.
- For more information, see Vector indexing policies.
- Indexing applies to only one vector per path.
- You can create only one index per vector path.
- AI Search supports scalar and binary quantization to reduce vector size in a search index.
Similarity and distance calculation capabilities
Vector search supports cosine similarity, dot product, and Euclidean distance calculation methods. Use these methods to calculate the similarity or distance between two vectors.
Preliminary data analysis uses metrics and Euclidean distances so that you can extract a variety of data structure insights. Text classification generally performs better under Euclidean distances. Retrieval of the most similar texts to a given text typically functions better with cosine similarity.
Azure OpenAI embeddings rely on cosine similarity to compute similarity between documents and a query.
| Built-in vector comparison calculation | Azure Cosmos DB for NoSQL | Azure DocumentDB | Azure Database for PostgreSQL | Azure Managed Redis | AI Search | SQL Database |
|---|---|---|---|---|---|---|
| Cosine similarity | Yes1 | Yes | Yes | Yes2 | Yes | Yes3 |
| Euclidean distance | Yes1 | Yes | Yes | Yes2 | Yes | Yes3 |
| Dot product | Yes1 | Yes | Yes | Yes2 | Yes | Yes3 |
- For more information, see the vector distance calculation for Azure Cosmos DB for NoSQL.
- Azure Managed Redis supports cosine similarity, Euclidean distance, and inner product distance metrics. For more information, see VSS.
- For more information, see the distance calculation examples for SQL Database and SQL Server.
Integration with Azure OpenAI and other components
You can link vector search to other Microsoft components. For example, Azure OpenAI helps you create vectors for your data and input queries for VSS.
| Capability | Azure Cosmos DB for NoSQL | Azure DocumentDB | Azure Database for PostgreSQL | Azure Managed Redis | AI Search | SQL Database |
|---|---|---|---|---|---|---|
| Foundry IQ integration | No | No | No | No | Yes | No |
| Foundry Agent Service integration | Yes1 | No | Yes2 | Yes2 | Yes3 | Yes2 |
| Integrated Azure OpenAI embedding generation | No | No | Yes4 | No | Yes5 | Yes6 |
| Semantic Kernel integration | Yes7 | Yes8 | Yes9 | Yes10 | Yes11 | Yes12 |
- Foundry Agent Service integration is provided through agent state storage.
- Foundry Agent Service integration is provided through data, vector search, or tool access.
- Foundry Agent Service integration is provided through knowledge retrieval and vector search.
- The Azure AI extension is available.
- AI Search includes a skill that vectorizes text chunks.
- You can create a stored procedure for your embedding model deployment.
- This service is supported as a memory connector and a vector database connector. For more information, see the C# documentation and the Python documentation.
- This service is supported as a vector database connector. For more information, see the C# documentation and the Python documentation.
- This service is supported as a memory connector and a vector database connector. For more information, see the C# documentation.
- This service is supported as a vector database connector. For more information, see Using the Redis connector.
- This service is supported as a memory connector and a vector database connector. For more information, see the C# documentation and the Python documentation.
- This service is supported as a memory connector.
Contributors
Microsoft maintains this article. The following contributors wrote this article.
Principal authors:
- Yu Saito | Solution Engineer
- Miho Yamamoto | Senior Solution Engineer
Other contributor:
- Keita Onabuta | Senior Solution Engineer
To see nonpublic LinkedIn profiles, sign in to LinkedIn.
Next steps
- Intelligent applications and AI
- VSS by using Azure SQL and Azure OpenAI
- Native vector support in Azure SQL and SQL Server
- Vector database in Azure Cosmos DB
- VSS in Azure Managed Redis
- Azure vector database samples
- Vector search in Azure Cosmos DB for NoSQL