Skip to content

Commit 9d73332

Browse files
committed
UUF doc fix, readability
1 parent 44f8f0e commit 9d73332

File tree

1 file changed

+49
-19
lines changed

1 file changed

+49
-19
lines changed

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

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

1515
# Create a vector index
1616

17-
In Azure AI Search, a *vector store* has an index schema that defines vector and nonvector fields, a vector configuration for algorithms that create and compress the embedding space, and settings on vector field definitions that are used in query requests.
17+
In Azure AI Search, you can store vectors in a search index. Your vector store has an index schema that defines both vector and nonvector fields, a vector configuration for algorithms used to create and compress the embedding space, and settings on vector field definitions used in query requests.
1818

19-
The [Create or Update Index](/rest/api/searchservice/indexes/create-or-update) API creates the vector store. Follow these steps to index vector data:
19+
The [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"]
22-
> + Define a schema with vector algorithms and optional compression
22+
> + Start with a basic schema definition
23+
> + Add vector algorithms and optional compression
2324
> + Add vector field definitions
2425
> + 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
2526
2627
This article explains the workflow and uses REST 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 these features in test and production code.
2728

2829
> [!TIP]
29-
> Use the Azure portal to [create a vector index](search-get-started-portal-import-vectors.md) and try integrated data chunking and vectorization.
30+
> You can also use the Azure portal to [create a vector index](search-get-started-portal-import-vectors.md) and try out integrated data chunking and vectorization.
3031
3132
## Prerequisites
3233

33-
+ Azure AI Search, in any region and on any tier. On 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. For indexing workloads that include integrated vectorization (skillsets that call Azure AI), Azure AI Search must be in the same region as Azure OpenAI or Azure AI services.
34+
+ Azure AI Search, in any region and on any tier. If you plan to use [integrated vectorization](vector-search-integrated-vectorization.md), Azure AI Search must be in the same region as the embedding models hosted on Azure OpenAI or in Azure AI Vision.
3435

35-
+ You must have [pre-existing vector embeddings](vector-search-how-to-generate-embeddings.md) to upload to the index, or you can use [integrated vectorization](vector-search-integrated-vectorization.md), where embedding models are called from a skillset in an indexer pipeline.
36+
+ If you aren't using integrated vectorization, your source documents must have [vector embeddings](vector-search-how-to-generate-embeddings.md) to upload to the index.
3637

3738
+ 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. Integrated vectorization supports a finite number of embedding models. For **text-embedding-ada-002**, dimensions are fixed at 1536. For **text-embedding-3-small** or **text-embedding-3-large**, the vector length ranges from 1 to 1536 and 3072, respectively.
3839

3940
+ 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).
4041

4142
+ 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.
4243

44+
## Limitations
45+
46+
+ 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.
47+
4348
## Prepare documents for indexing
4449

45-
Prior to 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 index schema.
4651

4752
Make sure your documents:
4853

49-
1. Provide 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 that can uniquely identify it in the index. This source field must be mapped to an index field of type `Edm.String` and `key=true` in the search index.
54+
1. Provide 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. This source field must be mapped to an index field of type `Edm.String` and `key=true` in the search index.
5055

5156
1. Provide vector data (an array of single-precision floating point numbers) in source fields.
5257

53-
Vector fields contain an array generated by embedding models, 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/2023-02-01-preview/image-retrieval/vectorize-image) for images.
58+
Vector fields contain 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 an **text-embedding-3** model for text documents or the [Image Retrieval REST API](/rest/api/computervision/image-retrieval/vectorize-image) for images.
5459

5560
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.
5661

@@ -60,12 +65,35 @@ Your search index should include fields and content for all of the query scenari
6065

6166
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.
6267

68+
## Create a basic index
69+
70+
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).
71+
72+
Notice that it has a required name, a required document key, and human readable content. 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 content, coupled with a vector field equivalent that you add in a later step.
73+
74+
```http
75+
POST https://[servicename].search.windows.net/indexes?api-version=[api-version]
76+
{
77+
"name": "example-index",
78+
"fields": [
79+
{ "name": "documentId", "type": "Edm.String", "key": true, "retrievable": true, "searchable": true, "filterable": true },
80+
{ "name": "humanReadableNameField", "type": "Edm.String", "retrievable": true, "searchable": true, "filterable": false, "sortable": true, "facetable": false },
81+
{ "name": "humanReadableContentField", "type": "Edm.String", "retrievable": true, "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft" },
82+
],
83+
"suggesters": [ ],
84+
"scoringProfiles": [ ],
85+
"analyzers":(optional)[ ... ]
86+
}
87+
```
88+
6389
## Add a vector search configuration
6490

91+
In this step, add a vector search configuration to your schema. In the schema, you might add it after "suggesters", "scoringProfiles", or "analyzers".
92+
6593
A vector configuration specifies the parameters used during indexing to create "nearest neighbor" information among the vector nodes:
6694

6795
+ Hierarchical Navigable Small World (HNSW)
68-
+ Exhaustive KNN
96+
+ Exhaustive k-Nearest Neighbor (KNN)
6997

7098
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, you can’t later request HNSW search because the extra data structures that enable approximate search don’t exist.
7199

@@ -284,7 +312,7 @@ Vector fields are characterized by [their data type](/rest/api/searchservice/sup
284312
+ `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.
285313
+ `vectorSearchProfile` is the name of a profile defined elsewhere in the index.
286314
+ `searchable` must be true.
287-
+ `retrievable` can be true or false. True returns the raw vectors (1536 of them) as plain text and consumes storage space. Set to true if you're passing a vector result to a downstream app.
315+
+ `retrievable` can be true or false. True returns the raw vectors (1,536 of them) as plain text and consumes storage space. Set to true if you're passing a vector result to a downstream app.
288316
+ `stored` can be true or false. It determines whether an extra copy of vectors is stored for retrieval. For more information, see [Reduce vector size](vector-search-how-to-storage-options.md).
289317
+ `filterable`, `facetable`, `sortable` must be false.
290318

@@ -367,8 +395,10 @@ Vector fields are characterized by [their data type](/rest/api/searchservice/sup
367395
368396
### [**2024-05-01-preview**](#tab/rest-2024-05-01-Preview)
369397
398+
[**2024-05-01-preview**](/rest/api/searchservice/search-service-api-versions#2024-05-01-preview) is the most recent preview version.
399+
370400
+ Supports all [vector data types](/rest/api/searchservice/supported-data-types#edm-data-types-for-vector-fields).
371-
+ Inclusive of `2024-03-01-preview`, with new support [indexing binary data for vector search](vector-search-how-to-index-binary-data.md).
401+
+ Inclusive of `2024-03-01-preview`.
372402
373403
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.
374404
@@ -378,7 +408,7 @@ Vector fields are characterized by [their data type](/rest/api/searchservice/sup
378408
+ `dimensions` is the number of dimensions generated by the embedding model. For text-embedding-ada-002, it's 1536.
379409
+ `vectorSearchProfile` is the name of a profile defined elsewhere in the index.
380410
+ `searchable` must be true.
381-
+ `retrievable` can be true or false. True returns the raw vectors (1536 of them) as plain text and consumes storage space. Set to true if you're passing a vector result to a downstream app. False is required if `stored` is false.
411+
+ `retrievable` can be true or false. True returns the raw vectors (1,536 of them) as plain text and consumes storage space. Set to true if you're passing a vector result to a downstream app. False is required if `stored` is false.
382412
+ `stored` is a new boolean property that applies to vector fields only. True stores a copy of vectors returned in search results. False discards that copy during indexing. You can search on vectors, but can't return vectors in results.
383413
+ `filterable`, `facetable`, `sortable` must be false.
384414
@@ -547,7 +577,7 @@ If you're familiar with indexers and skillsets:
547577

548578
---
549579

550-
## Check your index for vector content
580+
## Query your index for vector content
551581

552582
For validation purposes, you can query the index using Search Explorer in the Azure portal or a REST API call. Because Azure AI Search can't convert a vector to human-readable text, try to return fields from the same document that provide evidence of the match. For example, if the vector query targets the "titleVector" field, you could select "title" for the search results.
553583

@@ -565,7 +595,7 @@ Fields must be attributed as "retrievable" to be included in the results.
565595

566596
+ Use the default Query view for a quick confirmation that the index contains vectors. The query view is for full text search. Although you can't use it for vector queries, you can send an empty search (`search=*`) to check for content. The content of all fields, including vector fields, is returned as plain text.
567597

568-
+ See [Create a vector query](vector-search-how-to-query.md) for more details.
598+
For more information, see [Create a vector query](vector-search-how-to-query.md).
569599

570600
### [**REST API**](#tab/rest-check-index)
571601

@@ -595,15 +625,15 @@ api-key: {{admin-api-key}}
595625

596626
## Update a vector store
597627

598-
To update a vector store, modify the schema and if necessary, reload documents to populate new fields. APIs for schema updates include [Create or Update Index (REST)](/rest/api/searchservice/indexes/create-or-update), [CreateOrUpdateIndex](/dotnet/api/azure.search.documents.indexes.searchindexclient.createorupdateindexasync) in the Azure SDK for .NET, [create_or_update_index](/python/api/azure-search-documents/azure.search.documents.indexes.searchindexclient?view=azure-python#azure-search-documents-indexes-searchindexclient-create-or-update-index&preserve-view=true) in the Azure SDK for Python, and similar methods in other Azure SDKs.
628+
To update a vector store, modify the schema and reload documents to populate new fields. APIs for schema updates include [Create or Update Index (REST)](/rest/api/searchservice/indexes/create-or-update), [CreateOrUpdateIndex](/dotnet/api/azure.search.documents.indexes.searchindexclient.createorupdateindexasync) in the Azure SDK for .NET, [create_or_update_index](/python/api/azure-search-documents/azure.search.documents.indexes.searchindexclient?view=azure-python#azure-search-documents-indexes-searchindexclient-create-or-update-index&preserve-view=true) in the Azure SDK for Python, and similar methods in other Azure SDKs.
599629

600630
The standard guidance for updating an index is covered in [Update or rebuild an index](search-howto-reindex.md).
601631

602632
Key points include:
603633

604-
+ Drop and rebuild is often required for updates to and deletion of existing fields.
634+
+ Drop and full index rebuild is often required for updates to and deletion of existing fields.
605635

606-
+ However, you can update an existing schema with the following modifications, with no rebuild required:
636+
+ A few modifications can be made with no rebuild requirement:
607637

608638
+ Add new fields to a fields collection.
609639
+ Add new vector configurations, assigned to new fields but not existing fields that have already been vectorized.

0 commit comments

Comments
 (0)