You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Review the response in the adjacent pane. You should have a count that indicates the number of matches found in the index, a search score that indicates relevance, and values for each field listed in the `select` statement.
@@ -379,7 +379,7 @@ You can also use [Get Statistics](/rest/api/searchservice/indexes/get-statistics
379
379
### Get index statistics
380
380
GET {{baseUrl}}/indexes/hotels-quickstart/stats?api-version=2023-11-01 HTTP/1.1
381
381
Content-Type: application/json
382
-
api-key: {{apiKey}}
382
+
Authorization: Bearer {{token}}
383
383
```
384
384
385
385
1. Review the response. This operation is an easy way to get details about index storage.
Copy file name to clipboardExpand all lines: articles/search/search-get-started-vector.md
+79-16Lines changed: 79 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ms.service: cognitive-search
8
8
ms.custom:
9
9
- ignite-2023
10
10
ms.topic: quickstart
11
-
ms.date: 03/14/2024
11
+
ms.date: 07/04/2024
12
12
---
13
13
14
14
# Quickstart: Vector search by using REST
@@ -25,11 +25,13 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
25
25
## Prerequisites
26
26
27
27
-[Visual Studio Code](https://code.visualstudio.com/download) with a [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client). If you need help with getting started, see [Quickstart: Text search using REST](search-get-started-rest.md).
28
+
28
29
-[Azure AI Search](search-what-is-azure-search.md), in any region and on any tier. You can use the Free tier for this quickstart, but Basic or higher is recommended for larger data files. [Create](search-create-service-portal.md) or [find an existing Azure AI Search resource](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices) under your current subscription.
29
30
30
31
Most existing services support vector search. For a small subset of services created prior to January 2019, an index that contains vector fields fails on creation. In this situation, a new service must be created.
31
32
32
33
- Optionally, to run the query example that invokes [semantic reranking](semantic-search-overview.md), your search service must be the Basic tier or higher, with [semantic ranking enabled](semantic-how-to-enable-disable.md).
34
+
33
35
- Optionally, an [Azure OpenAI](https://aka.ms/oai/access) resource with a deployment of `text-embedding-ada-002`. The source `.rest` file includes an optional step for generating new text embeddings, but we provide pregenerated embeddings so that you can omit this dependency.
34
36
35
37
## Download files
@@ -38,15 +40,76 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
38
40
39
41
You can also start a new file on your local system and create requests manually by using the instructions in this article.
40
42
41
-
## Copy a search service key and URL
43
+
## Get a search service endpoint
44
+
45
+
You can find the search service endpoint in the Azure portal.
46
+
47
+
1. Sign in to the [Azure portal](https://portal.azure.com) and [find your search service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices).
48
+
49
+
1. On the **Overview** home page, find the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
50
+
51
+
:::image type="content" source="media/search-get-started-rest/get-endpoint.png" lightbox="media/search-get-started-rest/get-endpoint.png" alt-text="Screenshot of the URL property on the overview page.":::
52
+
53
+
You're pasting this endpoint into the `.rest` or `.http` file in a later step.
54
+
55
+
## Configure access
56
+
57
+
Requests to the search endpoint must be authenticated and authorized. You can use API keys or roles for this task. Keys are easier to start with, but roles are more secure.
58
+
59
+
For a role-based connection, the following instructions have you connecting to Azure AI Search under your identity, not the identity of a client app.
60
+
61
+
### Option 1: Use keys
62
+
63
+
Select **Settings** > **Keys** and then copy an admin key. Admin keys are used to add, modify, and delete objects. There are two interchangeable admin keys. Copy either one. For more information, see [Connect to Azure AI Search using key authentication](search-security-api-keys.md).
64
+
65
+
:::image type="content" source="media/search-get-started-rest/get-api-key.png" lightbox="media/search-get-started-rest/get-api-key.png" alt-text="Screenshot that shows the API keys in the Azure portal.":::
66
+
67
+
You're pasting this key into the `.rest` or `.http` file in a later step.
68
+
69
+
### Option 2: Use roles
70
+
71
+
Make sure your search service is [configured for role-based access](search-security-enable-roles.md). You must have preconfigured [role-assignments for developer access](search-security-rbac.md#assign-roles-for-development). Your role assignments must grant permission to create, load, and query a search index.
72
+
73
+
In this section, obtain your personal identity token using either the Azure CLI, Azure PowerShell, or the Azure portal.
42
74
43
-
REST calls require the search service endpoint and an API key on every request. You can get these values from the Azure portal.
75
+
#### [Azure CLI](#tab/azure-cli)
44
76
45
-
1. Sign in to the [Azure portal](https://portal.azure.com). Go to the **Overview** page and copy the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
77
+
1. Sign in to Azure CLI.
46
78
47
-
1. Select **Settings** > **Keys** and copy an admin key. Admin keys are used to add, modify, and delete objects. There are two interchangeable admin keys. Copy either one.
79
+
```azurecli
80
+
az login
81
+
```
82
+
83
+
1. Get your personal identity token.
84
+
85
+
```azurecli
86
+
az account get-access-token --scope https://search.azure.com/.default
87
+
```
88
+
89
+
#### [Azure PowerShell](#tab/azure-powershell)
90
+
91
+
1. Sign in with PowerShell.
92
+
93
+
```azurepowershell
94
+
Connect-AzAccount
95
+
```
96
+
97
+
1. Get your personal identity token.
48
98
49
-
:::image type="content" source="media/search-get-started-rest/get-url-key.png" alt-text="Screenshot that shows the URL and API keys in the Azure portal.":::
Use the steps found here: [find the user object ID](/partner-center/find-ids-and-domain-names#find-the-user-object-id) in the Azure portal.
106
+
107
+
---
108
+
109
+
You're pasting your personal identity token into the `.rest` or `.http` file in a later step.
110
+
111
+
> [!NOTE]
112
+
> This section assumes you're using a local client that connects to Azure AI Search on your behalf. An alternative approach is [getting a token for the client app](/entra/identity-platform/v2-oauth2-client-creds-grant-flow), assuming your application is [registered](/entra/identity-platform/quickstart-register-app) with Microsoft Entra ID.
50
113
51
114
## Create a vector index
52
115
@@ -56,22 +119,22 @@ The index schema is organized around hotel content. Sample data consists of vect
56
119
57
120
1. Open a new text file in Visual Studio Code.
58
121
59
-
1. Set variables to the search endpoint and the API key that you collected earlier.
122
+
1. Set variables to the values you collected earlier. This example uses a personal identity token.
60
123
61
124
```http
62
125
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
63
-
@apiKey = PUT-YOUR-ADMIN-API-KEY-HERE
126
+
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
64
127
```
65
128
66
-
1. Save the file with a `.rest` file extension.
129
+
1. Save the file with a `.rest`or `.http`file extension.
67
130
68
131
1. Paste in the following example to create the `hotels-vector-quickstart` index on your search service.
69
132
70
133
```http
71
134
### Create a new index
72
135
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
73
136
Content-Type: application/json
74
-
api-key: {{apiKey}}
137
+
Authorization: Bearer {{token}}
75
138
76
139
{
77
140
"name": "hotels-vector-quickstart",
@@ -243,7 +306,7 @@ The URI is extended to include the `docs` collection and the `index` operation.
243
306
### Upload documents
244
307
POST {{baseUrl}}/indexes/hotels-quickstart-vectors/docs/index?api-version=2023-11-01 HTTP/1.1
245
308
Content-Type: application/json
246
-
api-key: {{apiKey}}
309
+
Authorization: Bearer {{token}}
247
310
248
311
{
249
312
"value": [
@@ -405,7 +468,7 @@ The vector query string is semantically similar to the search string, but it inc
405
468
### Run a query
406
469
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
407
470
Content-Type: application/json
408
-
api-key: {{apiKey}}
471
+
Authorization: Bearer {{token}}
409
472
410
473
{
411
474
"count": true,
@@ -484,7 +547,7 @@ You can add filters, but the filters are applied to the nonvector content in you
484
547
### Run a vector query with a filter
485
548
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
486
549
Content-Type: application/json
487
-
api-key: {{apiKey}}
550
+
Authorization: Bearer {{token}}
488
551
489
552
{
490
553
"count": true,
@@ -557,7 +620,7 @@ Hybrid search consists of keyword queries and vector queries in a single search
557
620
### Run a hybrid query
558
621
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
559
622
Content-Type: application/json
560
-
api-key: {{apiKey}}
623
+
Authorization: Bearer {{token}}
561
624
562
625
{
563
626
"count": true,
@@ -704,7 +767,7 @@ Here's the last query in the collection. This hybrid query with semantic ranking
704
767
### Run a hybrid query
705
768
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
706
769
Content-Type: application/json
707
-
api-key: {{apiKey}}
770
+
Authorization: Bearer {{token}}
708
771
709
772
{
710
773
"count": true,
@@ -809,7 +872,7 @@ You can also try this `DELETE` command:
Copy file name to clipboardExpand all lines: articles/search/search-howto-reindex.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ Queries continue to run, but if you're updating or removing existing fields, you
49
49
50
50
+ To update the contents of simple fields and subfields in complex types, list only the fields you want to change. For example, if you only need to update a description field, the payload should consist of the document key and the modified description. Omitting other fields retains their existing values.
51
51
52
-
+ To merge the inline changes into string collection, provide the entire value. Recall the `tags` field example from the previous section. New values overwrite the old values, and there's no merging at the field content level.
52
+
+ To merge inline changes into string collection, provide the entire value. Recall the `tags` field example from the previous section. New values overwrite the old values for an entire field, and there's no merging within the content of a field.
53
53
54
54
Here's a [REST API example](search-get-started-rest.md) demonstrating these tips:
55
55
@@ -59,7 +59,7 @@ GET {{baseUrl}}/indexes/hotels-vector-quickstart/docs('1')?api-version=2023-11-
59
59
Content-Type: application/json
60
60
api-key: {{apiKey}}
61
61
62
-
### Change the descriptionand city for Secret Point Hotel
62
+
### Change the description, city, and tags for Secret Point Hotel
63
63
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search.index?api-version=2023-11-01 HTTP/1.1
64
64
Content-Type: application/json
65
65
api-key: {{apiKey}}
@@ -69,9 +69,10 @@ POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search.index?api-version=
69
69
{
70
70
"@search.action": "mergeOrUpload",
71
71
"HotelId": "1",
72
-
"Description": "Change the description and city for Secret Point Hotel. Keep everything else."
72
+
"Description": "I'm overwriting the description for Secret Point Hotel.",
73
+
"Tags": ["my old item", "my new item"],
73
74
"Address": {
74
-
"City": "Miami"
75
+
"City": "Gotham City"
75
76
}
76
77
}
77
78
]
@@ -104,15 +105,15 @@ The order of operations is:
104
105
105
106
1.[Update index schema](/rest/api/searchservice/indexes/create-or-update) on the search service.
106
107
107
-
1.[Update index content](#update-content) to match your revised schema if you added a new field. For all other changes, the existing content is used as-is.
108
+
1.[Update index content](#update-content) to match your revised schema if you added a new field. For all other changes, the existing indexed content is used as-is.
108
109
109
-
When you update the index schema, existing documents in the index are given a null value for the new field. On the next index documents job, values from external source data replace the nulls added by Azure AI Search.
110
+
When you update an index schema to include a new field, existing documents in the index are given a null value for that field. On the next indexing job, values from external source data replace the nulls added by Azure AI Search.
110
111
111
-
There should be no query disruptions during the updates, but query results will change as the updates take effect.
112
+
There should be no query disruptions during the updates, but query results will vary as the updates take effect.
112
113
113
114
## Drop and rebuild an index
114
115
115
-
Some modifications require an index drop and rebuild.
116
+
Some modifications require an index drop and rebuild, replacing a current index with a new one.
116
117
117
118
| Action | Description |
118
119
|-----------|-------------|
@@ -125,10 +126,12 @@ Some modifications require an index drop and rebuild.
125
126
126
127
The order of operations is:
127
128
128
-
1.[Get an index definition](/rest/api/searchservice/indexes/get) in case you need it for future reference.
129
+
1.[Get an index definition](/rest/api/searchservice/indexes/get) in case you need it for future reference, or to use as the basis for a new version.
129
130
130
131
1. Consider using a backup and restore solution to preserve a copy of index content. There are solutions in [C#](https://github.com/liamca/azure-search-backup-restore/blob/master/README.md) and in [Python](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-python/code/index-backup-restore). We recommend the Python version because it's more up to date.
131
132
133
+
If you have capacity on your search service, keep the existing index while creating and testing the new one.
134
+
132
135
1.[Drop the existing index](/rest/api/searchservice/indexes/delete). Queries targeting the index are immediately dropped. Remember that deleting an index is irreversible, destroying physical storage for the fields collection and other constructs.
133
136
134
137
1.[Post a revised index](/rest/api/searchservice/indexes/create), where the body of the request includes changed or modified field definitions and configurations.
@@ -137,8 +140,6 @@ The order of operations is:
137
140
138
141
When you create the index, physical storage is allocated for each field in the index schema, with an inverted index created for each searchable field and a vector index created for each vector field. Fields that aren't searchable can be used in filters or expressions, but don't have inverted indexes and aren't full-text or fuzzy searchable. On an index rebuild, these inverted indexes and vector indexes are deleted and recreated based on the index schema you provide.
139
142
140
-
If your index is in production or under active development, consider pushing, loading, and testing the new index before dropping the old one.
141
-
142
143
## Balancing workloads
143
144
144
145
Indexing doesn't run in the background, but the search service will balance any indexing jobs against ongoing queries. During indexing, you can [monitor query requests](search-monitor-queries.md) in the portal to ensure queries are completing in a timely manner.
0 commit comments