
DocumentDB's vector search feature is a game-changer for efficient data retrieval.
It allows developers to store and query high-dimensional vectors, making it ideal for applications that require similarity-based searches.
Vector search in DocumentDB is powered by the Annoy library, which is an efficient and scalable solution for approximate nearest neighbor search.
This means that you can expect fast query performance, even with large datasets.
DocumentDB's vector search feature supports various query types, including k-nearest neighbors and range queries, making it a versatile tool for various use cases.
This flexibility allows developers to tailor the search functionality to their specific needs.
Check this out: Elasticsearch Vector Db
Vector Search Basics
Vector search is a method that helps you find similar items based on their data characteristics rather than by exact matches on a property field. This technique is useful in applications such as searching for similar text or finding related images.
A vector search feature offers an efficient way to store, index, and search high-dimensional vector data directly alongside other application data. This approach removes the necessity of migrating your data to costlier alternative vector databases and provides a seamless integration of your AI-driven applications.
Embeddings are an information-dense representation of the semantic meaning of a piece of text, represented as a vector of floating-point numbers. The distance between two embeddings in the vector space is correlated with semantic similarity between two inputs in the original format.
For another approach, see: Azure Cognitive Search Vector
IVF Flat
IVF Flat is a vector search algorithm that's been around for a while, and it's still a popular choice for many use cases. It's great for projects with limited resources because it uses low memory and has a fast index build time.
One of the key features of IVF Flat is that it groups similar vector data into clusters, which makes it efficient for similarity searches. This is done by calculating a centroid vector for each cluster, which serves as the entry point for that cluster.
IVF Flat requires a substantial amount of vector data to build the index, with a minimum of several thousand data points recommended. This training step is necessary to ensure the index is accurate and effective.
As vectors are added, deleted, or updated in the database, IVF Flat will adjust the index by adding them to the pre-trained clusters. However, this can lead to a degradation of relevancy over time, especially if the dataset is constantly changing.
See what others are reading: Azure Cognitive Search Index
To maintain quality, you may need to rebuild the index regularly, which can be costly and may interfere with your business operations. However, the good news is that the build time for the index is relatively fast, making it a good choice for projects with tight deadlines.
Here are some key pros and cons of IVF Flat to consider:
- Very fast built time
- Small storage size
- Low memory requirements
- Slower to generate responses
- Quality of results deteriorates easily with data updates
- Needs a substantial amount of data to create the index
Embeddings
Embeddings are a special format of data representation that machine learning models and algorithms can easily use.
Each embedding is a vector of floating-point numbers, representing the semantic meaning of a piece of text. This format is information dense, making it perfect for storing and searching large amounts of text data.
A vector database extension that allows you to store your embeddings with your original data ensures data consistency, scale, and performance. This means you can keep your data in one place, without having to migrate it to a different database.
Embeddings are also correlated with semantic similarity between two inputs in the original format. For example, if two texts are similar, then their vector representations should also be similar. This makes embeddings a powerful tool for finding similar items based on their data characteristics.
Here's an interesting read: Azure Semantic Search
Indexing and Querying
In DocumentDB, creating a vector index is a breeze. All you need to do is choose which type of index you want to create by setting the “type” field in the vector options to either “hnsw” or “ivfflat”.
DocumentDB abstracts away the complexities of IVFFlat and HNSW, making it easy to get started. With a simple setting, you can create a vector index that suits your needs.
To create an IVFFlat index, you can follow the example provided in the documentation. It's as simple as setting the “type” field to “ivfflat”.
Here are the options for creating a vector index in DocumentDB:
To query the index, you'll need to use the `query` method, which takes a `VectorStoreQuery` object as an argument. This method returns a `VectorStoreQueryResult` containing the results of the query.
The `query` method also allows you to specify a `projection` dictionary, which defines which fields to return after the search. This is optional, but can be useful if you only need to retrieve specific fields.
The `query` method is the key to unlocking the power of vector search in DocumentDB. With it, you can retrieve the top k most similar nodes in your database.
Database Fundamentals
A database is a collection of organized data that can be easily accessed, managed, and updated. It's like a digital filing cabinet that stores information in a structured way.
Data is typically stored in tables, which consist of rows and columns. Each row represents a single record, and each column represents a specific field or attribute of that record.
In a database, data is organized using a schema, which defines the structure and relationships between different data elements. This schema is like a blueprint that guides how the data is stored and retrieved.
Additional reading: Vector Database Azure
What is a database?
A database is a collection of organized data that is stored in a way that allows for efficient retrieval and manipulation.
It can be designed to store a wide range of data types, including words, phrases, and documents, which can all be represented as vector embeddings.
Vector embeddings are mathematical representations of data in a high-dimensional space, where each dimension corresponds to a feature of the data.
A vector database is a type of database specifically designed to store and manage these vector embeddings.
Vector databases use vector search algorithms, such as Hierarchical Navigable Small World (HNSW), Inverted File (IVF), and DiskANN, to index and query the embeddings based on their vector distance or similarity.
These algorithms are crucial for identifying the most relevant data in a vector database.
Integrated Database vs Pure Database
When designing a vector database, you have two main options: integrated vector database and pure vector database.
An integrated vector database is a highly performant option that stores and indexes vector embeddings alongside the corresponding original data, eliminating the need for data replication.
For another approach, see: Azure Integrated Vectorization

This approach is optimal for AI agents and facilitates multi-modal data operations, ensuring greater data consistency, scale, and performance.
A pure vector database, on the other hand, is a separate entity that stores vector embeddings with a small amount of metadata.
It's a more straightforward solution, but it requires extra storage and maintenance.
The integrated vector database in a NoSQL or relational database offers additional capabilities and better data consistency, making it a more scalable and efficient choice.
Database Use Cases
Database use cases are incredibly diverse and can be applied to various domains and situations, especially in analytical and generative AI. Vector databases can identify similar images, documents, and songs based on their contents, themes, sentiments, and styles.
One of the most common use cases is identifying similar products based on their characteristics, features, and user groups. This is particularly useful in e-commerce and product recommendation systems.
Vector databases can also be used to recommend contents, products, or services based on individuals' preferences. For example, a music streaming service can use a vector database to suggest songs similar to the ones you've listened to before.
Another key use case is identifying data anomalies or fraudulent activities that are dissimilar from predominant or normal patterns. This can help prevent financial losses and improve overall system security.
Here are some examples of vector database use cases:
- Identify similar images, documents, and songs
- Identify similar products
- Recommend contents, products, or services
- Identify data anomalies or fraudulent activities
- Implement persistent memory for AI agents
These use cases demonstrate the versatility and power of vector databases in various industries and applications. By leveraging vector databases, organizations can unlock new insights and improve their overall performance.
Search Implementation
Vector search is a method that helps you find similar items based on their data characteristics rather than by exact matches on a property field. This technique is useful in applications such as searching for similar text, finding related images, making recommendations, or even detecting anomalies.
You can implement vector search using a machine learning model and an embeddings API, such as Azure OpenAI Embeddings or Hugging Face on Azure. These APIs help create vector representations of your data, which are then used for search.
To implement integrated vector database functionalities, you can use Azure Cosmos DB APIs. This approach offers a seamless integration of your AI-driven applications and removes the necessity of migrating your data to costlier alternative vector databases.
Using a native vector search feature provides an efficient way to store, index, and search high-dimensional vector data directly alongside other application data.
NoSQL and API
Azure Cosmos DB for NoSQL is the world's first serverless NoSQL vector database.
You can store your vectors and data together in Azure Cosmos DB for NoSQL with integrated vector database capabilities.
DiskANN, a suite of high-performance vector indexing algorithms developed by Microsoft Research, enables you to perform highly accurate, low-latency queries at any scale.
Azure Cosmos DB for MongoDB
Azure Cosmos DB for MongoDB is a powerful tool that allows you to store, index, and search high-dimensional vector data directly alongside other application data.
This approach is particularly efficient, as it removes the need to migrate your data to costlier alternative vector databases.
By using Azure Cosmos DB for MongoDB, you can seamlessly integrate your AI-driven applications with your existing data, making it a great option for those who want to streamline their workflow.
If this caught your attention, see: Documentdb Mongodb
NoSql Api
Azure Cosmos DB for NoSQL is the world's first serverless NoSQL vector database.
It stores vectors and data together in one place, making it easy to manage.
With integrated vector database capabilities, you can create a vector index based on DiskANN, a suite of high-performance vector indexing algorithms developed by Microsoft Research.
DiskANN enables highly accurate, low-latency queries at any scale, and it leverages the benefits of Azure Cosmos DB for NoSQL, such as 99.999% SLA with high availability and geo-replication.
This means you can have seamless transition from serverless to provisioned throughput (RU) in one data store.
Featured Images: pexels.com


