Edit

Share via


Choose an Azure service for vector search

Vector search is a method of finding 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. Vectors are a significant advancement over traditional keyword-based search methods. They provide faster, more accurate results by capturing and comparing semantic relationships within the information.

Azure provides multiple ways to store and search vectorized data. This article helps architects and developers who need to understand and choose the right Azure service for vector search for their application.

This article compares the following services based on their vector search capabilities:

Architects and developers should compare the available services from the perspective of system requirements in Choose a candidate service and in Capability matrix.

Choose a candidate service

This section helps you select the most likely services for your needs. To narrow the choices, start by considering the system requirements.

Key requirements

A flow chart that helps you choose the right Azure service for vector search.

To decide whether to use a traditional database solution or Azure AI Search, consider your requirements and whether you can perform live or real-time vector searching on your data. A traditional relational or NoSQL database is the best fit for your scenario if you change values in vectorized fields frequently and the changes need to be searchable in real time or near real time. Similarly, the best solution for you to meet your performance target might be to use your existing database. However, if your workload doesn't require real-time or near real-time vector searchability, and you can manage an index of vectors, AI Search can be a good choice.

If you choose a traditional database solution, the specific type of database service that you decide to use mostly depends on your team's skill set and the databases that you currently operate. If you already use a specific type of database, like MongoDB for example, then using that same type of database might be the easiest solution for your scenario. As shown in the Capability matrix section, each database service has some unique capabilities and limitations for vector search. Review that information to ensure that your preferred database type supports the functionality that you require.

If cost concerns are a driving factor, maintaining your existing design is likely the best fit for your scenario because introducing new services or other instances of a database service can add new net costs and complexity. Using your current databases for vector search likely affects your costs less than using a dedicated service.

If you choose to use a traditional database instead of AI Search, some advanced search features aren't available by default. For example, if you want to do reranking or hybrid search, enable that functionality through Transact-SQL (T-SQL) or other coding.

Capability matrix

The tables in this section summarize the key differences in capabilities.

Basic features

Native support for vector data types, approximate nearest neighbor (ANN) vector indexes, vector dimension limits, multiple vector fields, and multiple vector indexes is sometimes different between the services. Your workload might depend on some of these specific features. Understand the basic vector features of each Azure service, which are shown in the following table.

Capability Azure Cosmos DB for PostgreSQL Azure Cosmos DB for NoSQL Azure Cosmos DB for MongoDB (vCore) Azure Database for PostgreSQL Flexible Server AI Search Azure SQL Database
Built-in vector search Yes1 Yes Yes2 Yes1 Yes3 Yes
Vector data type Yes Yes Yes Yes Yes Yes8
Dimension limits5 16,0006 or 2,000 5057 or 4,096 16,000 16,0006 or 2,000 4,096 1,998 (preview)4
Multiple vector fields Yes Yes No Yes Yes Yes
Multiple vector indexes Yes Yes No Yes Yes Yes
  1. Support for vector search is provided by pgvector, which is an extension of PostgreSQL.
  2. Vector search on embeddings is supported in Azure Cosmos DB for MongoDB (vCore).
  3. AI Search supports the use of vectors.
  4. Vectors can be stored in a VARBINARY(8000) column or variable in SQL Database.
  5. Embedding models from OpenAI include 1,536 dimensions for both text-embedding-ada-002 and text-embedding-3-small, and 3,072 dimensions for text-embedding-3-large. Azure AI Vision multimodal embedding models have 1,024 dimensions for both image and text.
  6. Vectors can have up to 16,000 dimensions. However, indexing by using inverted file flat (IVFFlat) and hierarchical navigable small world (HNSW) algorithms supports vectors with a maximum of 2,000 dimensions.
  7. Vectors indexed by using the flat index type can have a maximum of 505 dimensions. Vectors indexed by using the quantizedFlat or DiskANN index type can have a maximum of 4,096 dimensions.
  8. SQL Database supports a vector data type.

Search methods

Workloads often need to combine vector search with full-text search or even a hybrid search, which is a full-text search or semantic search plus vector search. The combination of hybrid search and reranking achieves 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 PostgreSQL Azure Cosmos DB for NoSQL Azure Cosmos DB for MongoDB (vCore) Azure Database for PostgreSQL Flexible Server AI Search Azure SQL Database
Full-text search Yes1 Yes9 Yes2 Yes1 Yes3 Yes4
Hybrid search Yes5 Yes11 Yes6 Yes5 Yes7 Yes8
Built-in reranking No Yes10 No No Yes9 No
  1. PostgreSQL supports full-text search.
  2. Azure Cosmos DB for MongoDB (vCore) supports search and query by using text indexes.
  3. Full-text search is supported in SQL Server.
  4. SQL Server supports vector data.
  5. Hybrid search isn't provided as a first-class feature, but sample codes are available.
  6. Hybrid search that combines full-text and vector search with reciprocal rank fusion (RRF) is natively supported in Azure Cosmos DB for MongoDB (vCore).
  7. Hybrid search, which combines full-text search, vector search, and semantic ranking, is provided as a first-class feature in Azure AI Search.
  8. An example of hybrid search for Azure SQL Database and SQL Server is available.
  9. Semantic ranking is a first-class feature that reranks the results of full-text and vector searches.
  10. Cosmos DB NoSQL supports full-text search with full-text scoring.
  11. Cosmos DB NoSQL supports hybrid search.

Vector data indexing algorithms

Vector data indexing is the ability to efficiently store and retrieve vectors. This capability is important because indexing influences speed and accuracy of similarity searches and nearest neighbor queries on data sources.

Indexes are typically based on an exhaustive k-nearest neighbor (Ek-NN) or an ANN algorithm. Ek-NN does an exhaustive search on all data points one by one and returns the accurate k nearest neighbors. Ek-NN works in milliseconds with a small amount of data but can cause latency for large amounts of data.

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 provided types of vector data indexing.

Indexing approach Azure Cosmos DB for PostgreSQL Azure Cosmos DB for NoSQL Azure Cosmos DB for MongoDB (vCore) Azure Database for PostgreSQL Flexible Server AI Search Azure SQL Database
DiskANN Yes Yes Yes2 Yes1 No Yes3
E-kNN Yes Yes Yes Yes Yes Yes
HNSW Yes No Yes2 Yes Yes No
IVFFlat Yes No Yes Yes No No
Other - Flat, quantizedFlat4 Vector field limitation5
Vector index limitation6
- - External libraries are available7
  1. For more information, see DiskANN for Azure Database for PostgreSQL Flexible Server.
  2. For more information, see Azure Cosmos DB for MongoDB - Vector search overview.
  3. DiskANN-based vector indexing is currently available in private preview for Azure SQL.
  4. For more information, see Vector indexing policies.
  5. Only one vector field is available for each container.
  6. Only one vector index is available for each container.
  7. An index can be created by using external libraries like Scikit Learn or FAISS.

Similarity and distance calculation capabilities

There are cosine similarity, dot product, and Euclidean distance calculation methods for vector search. These methods are used to calculate the similarity between two vectors or the distance between two vectors.

Preliminary data analysis benefits from both metrics and Euclidean distances, which allow for the extraction of different insights on data structure. 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 PostgreSQL Azure Cosmos DB for NoSQL Azure Cosmos DB for MongoDB (vCore) Azure Database for PostgreSQL Flexible Server AI Search Azure SQL Database
Cosine similarity Yes Yes1 Yes Yes Yes Yes2
Euclidean distance (L2 distance) Yes Yes1 Yes Yes Yes Yes2
Dot product Yes Yes1 Yes Yes Yes Yes2
  1. For more information, see the vector distance calculation for Azure Cosmos DB for NoSQL.
  2. For more information, see the distance calculation examples for Azure SQL Database and SQL Server.

Integration with Azure OpenAI and other components

When you implement vector search, you can also consider linking with other Microsoft components. For example, Azure OpenAI helps you create vectors for your data and input queries for vector similarity search.

Capability Azure Cosmos DB for PostgreSQL Azure Cosmos DB for NoSQL Azure Cosmos DB for MongoDB (vCore) Azure Database for PostgreSQL Flexible Server AI Search Azure SQL Database
Azure OpenAI - add your own data No No Yes1 No Yes2 No
Vector embedding with Azure OpenAI No No No Yes3 Yes4 Yes5
Integration with Semantic Kernel Yes6 Yes7 Yes8 Yes6 Yes9 Yes10
  1. Azure Cosmos DB for MongoDB (vCore) is supported as a data source for Azure OpenAI on your data.
  2. AI Search is supported as a data source for Azure OpenAI on your data.
  3. The Azure AI extension is available.
  4. AI Search provides a skill to vectorize the chunked text.
  5. You can create a stored procedure for your embedding model deployment.
  6. This service is supported as both a memory connector and a vector database connector. For more information, see the C# documentation.
  7. This service is supported as both a memory connector and a vector database connector. Documentation is available for both C# and Python.
  8. This service is supported as a vector database connector. Documentation is available for both C# and Python.
  9. This service is supported as both a memory connector and a vector database connector. Documentation is available for both C# and Python.
  10. This service is supported as a memory connector.

Contributors

Microsoft maintains this article. The following contributors wrote this article.

Principal authors:

To see nonpublic LinkedIn profiles, sign in to LinkedIn.

Next steps