Skip to content

Commit 288bba4

Browse files
committed
Edits for readability
1 parent ba87baf commit 288bba4

File tree

1 file changed

+52
-53
lines changed

1 file changed

+52
-53
lines changed

articles/search/vector-search-how-to-create-index.md

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ ms.service: azure-ai-search
99
ms.custom:
1010
- ignite-2024
1111
ms.topic: how-to
12-
ms.date: 02/14/2025
12+
ms.date: 04/17/2025
1313
---
1414

1515
# Create a vector index
1616

17-
In Azure AI Search, you can store vectors in a search index and send vector queries to match on semantic similarity. A vector store in Azure AI Search is defined by an index schema that has both vector and nonvector fields. The schema also has a vector configuration for specifying the algorithms used to create and compress the embedding space.
17+
In Azure AI Search, you can store vectors in a search index and send vector queries for matching based on semantic similarity. A vector index is defined by an index schema that has: vector fields, nonvector fields, and a vector configuration section.
1818

1919
[Create or Update Index API](/rest/api/searchservice/indexes/create-or-update) creates the vector store. Follow these steps to index vectors in Azure AI Search:
2020

2121
> [!div class="checklist"]
2222
> + Start with a basic schema definition
2323
> + Add vector algorithms and optional compression
2424
> + Add vector field definitions
25-
> + Load prevectorized data [as a separate step](#load-vector-data-for-indexing), or use [integrated vectorization](vector-search-integrated-vectorization.md) for data chunking and encoding during indexing
25+
> + Load prevectorized data [as a separate step](#load-vector-data-for-indexing), or use [integrated vectorization](vector-search-integrated-vectorization.md) for data chunking and embedding during indexing
2626
2727
This article explains the workflow using the REST API for illustration. Once you understand the basic workflow, continue with the Azure SDK code samples in the [azure-search-vector-samples](https://github.com/Azure/azure-search-vector-samples) repository for guidance on using vectors in test and production code.
2828

@@ -37,35 +37,37 @@ This article explains the workflow using the REST API for illustration. Once you
3737

3838
+ You should know the dimensions limit of the model used to create the embeddings so that you can assign that limit to the vector field. For **text-embedding-ada-002**, dimensions are fixed at 1536. For **text-embedding-3-small** or **text-embedding-3-large**, dimensions range from 1 to 1536 and 3072, respectively.
3939

40-
+ You should also know what similarity metric to use. For embedding models on Azure OpenAI, similarity is [computed using `cosine`](/azure/ai-services/openai/concepts/understand-embeddings#cosine-similarity).
40+
+ You should also know what similarity metric to use. For embedding models on Azure OpenAI, similarity is computed using [`cosine`](/azure/ai-services/openai/concepts/understand-embeddings#cosine-similarity).
4141

42-
+ You should be familiar with [creating an index](search-how-to-create-search-index.md). The schema must include a field for the document key, other fields you want to search or filter, and other configurations for behaviors needed during indexing and queries.
42+
+ You should be familiar with [creating an index](search-how-to-create-search-index.md). A schema always includes a field for the document key, fields used for search or filters, and other configurations for behaviors needed during indexing and queries.
4343

4444
## Limitations
4545

4646
For search services created before January 2019, there's a small subset that can't create a vector index. If this applies to you, create a new service to use vectors.
4747

4848
## Prepare documents for indexing
4949

50-
Before indexing, assemble a document payload that includes fields of vector and nonvector data. The document structure must conform to the index schema.
50+
Before indexing, assemble a document payload that includes fields of vector and nonvector data. The document structure must conform to the fields collection of index schema.
5151

5252
Make sure your source documents provide the following content:
5353

5454
| Content | Description |
5555
|---------|-------------|
5656
| Unique identifier | A field or a metadata property that uniquely identifies each document. All search indexes require a document key. To satisfy document key requirements, a source document must have one field or property uniquely identifies it in the index. If you're indexing blobs, it might be the metadata_storage_path that uniquely identifies each blob. If you're indexing from a database, it might be primary key. This source field must be mapped to an index field of type `Edm.String` and `key=true` in the search index.|
57-
| Non-vector content | Provide other fields with human-readable content. Human readable content is useful for the query response, and for hybrid query scenarios that include full text search or semantic ranking in the same request. If you're using a chat completion model, most models like ChatGPT don't accept raw vectors as input. |
58-
| Vector content| A vectorized version of your non-vector content. A vector is an array of single-precision floating point numbers generated by an embedding model. Each vector field contains an array generated by an embedding model, one embedding per field, where the field is a top-level field (not part of a nested or complex type). For the simplest integration, we recommend the embedding models in [Azure OpenAI](https://aka.ms/oai/access), such as a **text-embedding-3** model for text documents or the [Image Retrieval REST API](/rest/api/computervision/image-retrieval) for images and multimodal embeddings. <br><br>If you can take a dependency on indexers and skillsets, consider using [integrated vectorization](vector-search-integrated-vectorization.md) that encodes images and textual content during indexing. Your field definitions are for vector fields, but incoming source data can be text or images, which are converted to vector arrays during indexing. |
57+
| Non-vector content | Provide other fields with human-readable content. Human readable content is useful for the query response, and for hybrid query scenarios that include full text search or semantic ranking in the same request. If you're using a chat completion model, most models like ChatGPT expect human-readable text and don't accept raw vectors as input. |
58+
| Vector content| A vectorized version of your non-vector content. Vectors are used at query time. A vector is an array of single-precision floating point numbers generated by an embedding model. Each vector field contains an array generated by an embedding model, one embedding per field, where the field is a top-level field (not part of a nested or complex type). For the simplest integration, we recommend the embedding models in [Azure OpenAI](https://aka.ms/oai/access), such as a **text-embedding-3** model for text documents or the [Image Retrieval REST API](/rest/api/computervision/image-retrieval) for images and multimodal embeddings. <br><br>If you can take a dependency on indexers and skillsets, consider using [integrated vectorization](vector-search-integrated-vectorization.md) that encodes images and textual content during indexing. Your field definitions are for vector fields, but incoming source data can be text or images, which are converted to vector arrays during indexing. |
5959

60-
Your search index should include fields and content for all of the query scenarios you want to support. Suppose you want to search or filter over product names, versions, metadata, or addresses. In this case, vector similarity search isn't especially helpful. Keyword search, geo-search, or filters would be a better choice. A search index that includes a comprehensive collection of both vector and nonvector fields provides maximum flexibility for query construction and response composition.
60+
Your search index should include fields and content for all of the query scenarios you want to support. Suppose you want to search or filter over product names, versions, metadata, or addresses. In this case, vector similarity search isn't especially helpful. Keyword search, geo-search, or filters that iterate over verbatim content would be a better choice. A search index that's inclusive of both vector and nonvector fields provides maximum flexibility for query construction and response composition.
6161

6262
A short example of a documents payload that includes vector and nonvector fields is in the [load vector data](#load-vector-data-for-indexing) section of this article.
6363

6464
## Start with a basic index
6565

6666
Start with a minimum schema so that you have a definition to work with before adding a vector configuration and vector fields. A simple index might look the following example. You can learn more about an index schema in [Create a search index](search-how-to-create-search-index.md).
6767

68-
Notice that it has a required name, a required document key (`"key": true`), and fields for human readable content in plain text. It's common to have a human-readable version of whatever content you intend to vectorize. For example, if you have a chunk of text from a PDF file, your index schema should have the plain text equivalent of the vectorized text.
68+
Notice that it has a required name, a required document key (`"key": true`), and fields for human readable content in plain text. It's common to have a human-readable version of whatever content you intend to vectorize. For example, if you have a chunk of text from a PDF file, your index schema should have a field for plain text chunks and a second field for vectorized chunks.
69+
70+
Here's a basic index with a "name", a "fields" collection, and a few other constructs for extra configuration.
6971

7072
```http
7173
POST https://[servicename].search.windows.net/indexes?api-version=[api-version]
@@ -76,35 +78,35 @@ POST https://[servicename].search.windows.net/indexes?api-version=[api-version]
7678
{ "name": "myHumanReadableNameField", "type": "Edm.String", "retrievable": true, "searchable": true, "filterable": false, "sortable": true, "facetable": false },
7779
{ "name": "myHumanReadableContentField", "type": "Edm.String", "retrievable": true, "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft" },
7880
],
79-
"suggesters": [ ],
81+
"analyzers": [ ],
8082
"scoringProfiles": [ ],
81-
"analyzers":(optional)[ ... ]
83+
"suggesters": [ ],
84+
"vectorSearch": [ ]
8285
}
8386
```
8487

8588
## Add a vector search configuration
8689

87-
Next, add a vector search configuration (profile) to your schema. Configuration occurs before field definitions because you specify a profile on each field as part of its definition. In the schema, vector configuration is typically added after the fields collection, perhaps after `"suggesters"`, `"scoringProfiles"`, or `"analyzers"`.
88-
89-
A vector configuration specifies the parameters used during indexing to create "nearest neighbor" information among the vector nodes. Algorithms include:
90-
91-
+ Hierarchical Navigable Small World (HNSW)
92-
+ Exhaustive k-Nearest Neighbor (KNN)
93-
94-
If you choose HNSW on a field, you can opt in for exhaustive KNN at query time. But the other direction doesn’t work: if you choose exhaustive for indexing, you can’t later request HNSW search because the extra data structures that enable approximate search don’t exist.
90+
Next, add a "vectorSearch" configuration to your schema. It's useful to specify a configuration first, before field definitions, because the profiles you define here become part of the vector field's definition. In the schema, vector configuration is typically inserted after the fields collection, perhaps after `"analyzers"`, `"scoringProfiles"`, and `"suggesters"` (although order doesn't matter).
9591

96-
Optionally, a vector configuration also specifies quantization methods for reducing vector size:
92+
A vector configuration includes:
9793

98-
+ Scalar
99-
+ Binary (available in 2024-07-01 only and in newer Azure SDK packages)
94+
+ `vectorSearch.algorithms` used during indexing to create "nearest neighbor" information among the vector nodes.
95+
+ `vectorSearch.compressions` for scalar or binary quantization, oversampling, and for reranking with original vectors.
96+
+ `vectorSearch.profiles` for specifying multiple combinations of algorithm and compression configurations.
10097

10198
### [**2024-07-01**](#tab/config-2024-07-01)
10299

103100
[**2024-07-01**](/rest/api/searchservice/search-service-api-versions#2024-07-01) is generally available. It supports a vector configuration having:
104101

105-
+ `vectorSearch.algorithms` support HNSW and exhaustive KNN.
106-
+ `vectorSearch.compressions` support scalar and binary quantization, oversampling, and reranking with original vectors.
107-
+ `vectorSearch.profiles` for specifying multiple combinations of algorithm and compression configurations.
102+
+ Hierarchical Navigable Small World (HNSW) algorithm
103+
+ Exhaustive k-Nearest Neighbor (KNN) algorithm
104+
+ Scalar compression
105+
+ Binary compression (available in 2024-07-01 only and in newer Azure SDK packages)
106+
+ Oversampling
107+
+ Reranking with original vectors
108+
109+
If you choose HNSW on a field, you can opt in for exhaustive KNN at query time. But the other direction doesn’t work: if you choose exhaustive for indexing, you can’t later request HNSW search because the extra data structures that enable approximate search don’t exist.
108110

109111
Be sure to have a strategy for [vectorizing your content](vector-search-how-to-generate-embeddings.md). We recommend [integrated vectorization](vector-search-integrated-vectorization.md) and [query-time vectorizers](vector-search-how-to-configure-vectorizer.md) for built-in encoding.
110112

@@ -175,7 +177,7 @@ Be sure to have a strategy for [vectorizing your content](vector-search-how-to-g
175177

176178
+ Names for each configuration of compression, algorithm, and profile must be unique for its type within the index.
177179

178-
+ `vectorSearch.compressions` can be `scalarQuantization` or `binaryQuantization`. Scalar quantization compresses float values into narrower data types. Binary quantization converts floats into binary 1 bit values.
180+
+ `vectorSearch.compressions` can be `scalarQuantization` or `binaryQuantization`. Scalar quantization compresses float values into narrower data types. Binary quantization converts floats into binary 1-bit values.
179181

180182
+ `vectorSearch.compressions.rerankWithOriginalVectors` uses the original, uncompressed vectors to recalculate similarity and rerank the top results returned by the initial search query. The uncompressed vectors exist in the search index even if `stored` is false. This property is optional. Default is true.
181183

@@ -197,14 +199,9 @@ Be sure to have a strategy for [vectorizing your content](vector-search-how-to-g
197199

198200
### [**2024-05-01-preview**](#tab/config-2024-05-01-Preview)
199201

200-
[**2024-05-01-preview**](/rest/api/searchservice/search-service-api-versions#2024-05-01-preview) is the most recent preview version.
202+
[**2024-05-01-preview**](/rest/api/searchservice/search-service-api-versions#2024-05-01-preview) is the most recent preview version. It's inclusive of previous preview versions.
201203

202-
+ `vectorSearch.algorithms` with support for HNSW and exhaustive KNN.
203-
+ `vectorSearch.compressions` with properties for scalar (but not binary) quantization, oversampling, and reranking with original vectors.
204-
+ `vectorSearch.profiles` for multiple combinations of algorithm and compression configurations.
205-
+ Inclusive of 2024-03-01-preview.
206-
+ Inclusive of 2023-10-01-preview.
207-
+ Inclusive of 2023-11-01 `vectorSearch.algorithms` and `vectorSearch.profiles`.
204+
Preview and stable API versions support the same `"vectorSearch"` configurations. You would choose the preview over the stable version for other reasons, such as newer [vectorizers](vector-search-how-to-configure-vectorizer.md) invoked at query time.
208205

209206
1. Use the [Create or Update Index Preview REST API](/rest/api/searchservice/indexes/create-or-update?view=rest-searchservice-2024-05-01-preview&preserve-view=true) to create the index.
210207

@@ -278,7 +275,7 @@ Be sure to have a strategy for [vectorizing your content](vector-search-how-to-g
278275

279276
+ `vectorSearch.algorithms.efConstruction` is the number of nearest neighbors used during indexing. Default is 400. The range is 100 to 1,000.
280277

281-
+ `"vectorSearch.algorithms.fSearch` is the number of nearest neighbors used during search. Default is 500. The range is 100 to 1,000.
278+
+ `"vectorSearch.algorithms.efSearch` is the number of nearest neighbors used during search. Default is 500. The range is 100 to 1,000.
282279

283280
+ `vectorSearch.algorithms.metric` should be "cosine" if you're using Azure OpenAI, otherwise use the similarity metric associated with the embedding model you're using. Supported values are `cosine`, `dotProduct`, `euclidean`, `hamming` (used for [indexing binary data](vector-search-how-to-index-binary-data.md)).
284281

@@ -294,25 +291,30 @@ Once you have a vector configuration, you can add a vector field to the fields c
294291

295292
Vector fields are characterized by [their data type](/rest/api/searchservice/supported-data-types#edm-data-types-for-vector-fields), a `dimensions` property based on the embedding model used to output the vectors, and a vector profile that you created in a previous step.
296293

297-
```json
298-
{
299-
"name": "contentVector",
300-
"type": "Collection(Edm.Single)",
301-
"searchable": true,
302-
"retrievable": false,
303-
"stored": false,
304-
"dimensions": 1536,
305-
"vectorSearchProfile": "vector-profile-1"
306-
}
307-
```
308-
309294
### [**2024-07-01**](#tab/rest-2024-07-01)
310295

311296
[**2024-07-01**](/rest/api/searchservice/search-service-api-versions#2024-07-01) is generally available.
312297

313-
1. Use the [Create or Update Index](/rest/api/searchservice/indexes/create-or-update) to create the index.
298+
1. Use the [Create or Update Index](/rest/api/searchservice/indexes/create-or-update) to create the index and add a vector field to the fields collection.
314299

315-
1. Define a vector field with the following attributes. You can store one generated embedding per field. For each vector field:
300+
```json
301+
{
302+
"name": "example-index",
303+
"fields": [
304+
{
305+
"name": "contentVector",
306+
"type": "Collection(Edm.Single)",
307+
"searchable": true,
308+
"retrievable": false,
309+
"stored": false,
310+
"dimensions": 1536,
311+
"vectorSearchProfile": "vector-profile-1"
312+
}
313+
]
314+
}
315+
```
316+
317+
1. Specify a vector field with the following attributes. You can store one generated embedding per field. For each vector field:
316318

317319
+ `type` must be a [vector data types](/rest/api/searchservice/supported-data-types#edm-data-types-for-vector-fields). `Collection(Edm.Single)` is the most common for embedding models.
318320
+ `dimensions` is the number of dimensions generated by the embedding model. For text-embedding-ada-002, it's fixed at 1536. For the text-embedding-3 model series, there's a range of values. If you're using integrated vectorization and an embedding skill to generate vectors, make sure this property is set to the [same dimensions value](cognitive-search-skill-azure-openai-embedding.md#supported-dimensions-by-modelname) used by the embedding skill.
@@ -401,10 +403,7 @@ Vector fields are characterized by [their data type](/rest/api/searchservice/sup
401403

402404
### [**2024-05-01-preview**](#tab/rest-2024-05-01-Preview)
403405

404-
[**2024-05-01-preview**](/rest/api/searchservice/search-service-api-versions#2024-05-01-preview) is the most recent preview version.
405-
406-
+ Supports all [vector data types](/rest/api/searchservice/supported-data-types#edm-data-types-for-vector-fields).
407-
+ Inclusive of `2024-03-01-preview`.
406+
[**2024-05-01-preview**](/rest/api/searchservice/search-service-api-versions#2024-05-01-preview) is the most recent preview version. It supports the same vector field definitions as the stable version, including support for all [vector data types](/rest/api/searchservice/supported-data-types#edm-data-types-for-vector-fields).
408407

409408
1. Use the [Create or Update Index Preview REST API](/rest/api/searchservice/indexes/create-or-update?view=rest-searchservice-2024-05-01-preview&preserve-view=true) to define the fields collection of an index.
410409

0 commit comments

Comments
 (0)