Skip to content

Commit 89cf63f

Browse files
Merge pull request #280092 from HeidiSteen/heidist-june28
[azure search] misc edits
2 parents 18ac314 + 6b5ecca commit 89cf63f

File tree

3 files changed

+103
-39
lines changed

3 files changed

+103
-39
lines changed

articles/search/search-get-started-rest.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Add a second request to your `.rest` file. [Create Index (REST)](/rest/api/searc
160160
### Create a new index
161161
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
162162
Content-Type: application/json
163-
api-key: {{apiKey}}
163+
Authorization: Bearer {{token}}
164164
165165
{
166166
"name": "hotels-quickstart",
@@ -237,7 +237,7 @@ The URI is extended to include the `docs` collections and `index` operation.
237237
### Upload documents
238238
POST {{baseUrl}}/indexes/hotels-quickstart/docs/index?api-version=2023-11-01 HTTP/1.1
239239
Content-Type: application/json
240-
api-key: {{apiKey}}
240+
Authorization: Bearer {{token}}
241241
242242
{
243243
"value": [
@@ -336,15 +336,15 @@ The URI is extended to include a query expression, which is specified by using t
336336
```http
337337
### Run a query
338338
POST {{baseUrl}}/indexes/hotels-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
339-
Content-Type: application/json
340-
api-key: {{apiKey}}
341-
342-
{
343-
"search": "lake view",
344-
"select": "HotelId, HotelName, Tags, Description",
345-
"searchFields": "Description, Tags",
346-
"count": true
347-
}
339+
Content-Type: application/json
340+
Authorization: Bearer {{token}}
341+
342+
{
343+
"search": "lake view",
344+
"select": "HotelId, HotelName, Tags, Description",
345+
"searchFields": "Description, Tags",
346+
"count": true
347+
}
348348
```
349349
350350
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
379379
### Get index statistics
380380
GET {{baseUrl}}/indexes/hotels-quickstart/stats?api-version=2023-11-01 HTTP/1.1
381381
Content-Type: application/json
382-
api-key: {{apiKey}}
382+
Authorization: Bearer {{token}}
383383
```
384384
385385
1. Review the response. This operation is an easy way to get details about index storage.

articles/search/search-get-started-vector.md

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: cognitive-search
88
ms.custom:
99
- ignite-2023
1010
ms.topic: quickstart
11-
ms.date: 03/14/2024
11+
ms.date: 07/04/2024
1212
---
1313

1414
# 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
2525
## Prerequisites
2626

2727
- [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+
2829
- [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.
2930

3031
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.
3132

3233
- 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+
3335
- 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.
3436

3537
## Download files
@@ -38,15 +40,76 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
3840

3941
You can also start a new file on your local system and create requests manually by using the instructions in this article.
4042

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.
4274

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)
4476

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.
4678

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.
4898
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.":::
99+
```azurepowershell
100+
Get-AzAccessToken -ResourceUrl https://search.azure.com
101+
```
102+
103+
#### [Azure portal](#tab/portal)
104+
105+
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.
50113
51114
## Create a vector index
52115
@@ -56,22 +119,22 @@ The index schema is organized around hotel content. Sample data consists of vect
56119
57120
1. Open a new text file in Visual Studio Code.
58121
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.
60123
61124
```http
62125
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
63-
@apiKey = PUT-YOUR-ADMIN-API-KEY-HERE
126+
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
64127
```
65128

66-
1. Save the file with a `.rest` file extension.
129+
1. Save the file with a `.rest` or `.http` file extension.
67130

68131
1. Paste in the following example to create the `hotels-vector-quickstart` index on your search service.
69132

70133
```http
71134
### Create a new index
72135
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
73136
Content-Type: application/json
74-
api-key: {{apiKey}}
137+
Authorization: Bearer {{token}}
75138
76139
{
77140
"name": "hotels-vector-quickstart",
@@ -243,7 +306,7 @@ The URI is extended to include the `docs` collection and the `index` operation.
243306
### Upload documents
244307
POST {{baseUrl}}/indexes/hotels-quickstart-vectors/docs/index?api-version=2023-11-01 HTTP/1.1
245308
Content-Type: application/json
246-
api-key: {{apiKey}}
309+
Authorization: Bearer {{token}}
247310
248311
{
249312
"value": [
@@ -405,7 +468,7 @@ The vector query string is semantically similar to the search string, but it inc
405468
### Run a query
406469
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
407470
Content-Type: application/json
408-
api-key: {{apiKey}}
471+
Authorization: Bearer {{token}}
409472
410473
{
411474
"count": true,
@@ -484,7 +547,7 @@ You can add filters, but the filters are applied to the nonvector content in you
484547
### Run a vector query with a filter
485548
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
486549
Content-Type: application/json
487-
api-key: {{apiKey}}
550+
Authorization: Bearer {{token}}
488551
489552
{
490553
"count": true,
@@ -557,7 +620,7 @@ Hybrid search consists of keyword queries and vector queries in a single search
557620
### Run a hybrid query
558621
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
559622
Content-Type: application/json
560-
api-key: {{apiKey}}
623+
Authorization: Bearer {{token}}
561624
562625
{
563626
"count": true,
@@ -704,7 +767,7 @@ Here's the last query in the collection. This hybrid query with semantic ranking
704767
### Run a hybrid query
705768
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
706769
Content-Type: application/json
707-
api-key: {{apiKey}}
770+
Authorization: Bearer {{token}}
708771
709772
{
710773
"count": true,
@@ -809,7 +872,7 @@ You can also try this `DELETE` command:
809872
### Delete an index
810873
DELETE {{baseUrl}}/indexes/hotels-vector-quickstart?api-version=2023-11-01 HTTP/1.1
811874
Content-Type: application/json
812-
api-key: {{apiKey}}
875+
Authorization: Bearer {{token}}
813876
```
814877

815878
## Next steps

articles/search/search-howto-reindex.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Queries continue to run, but if you're updating or removing existing fields, you
4949

5050
+ 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.
5151

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.
5353

5454
Here's a [REST API example](search-get-started-rest.md) demonstrating these tips:
5555

@@ -59,7 +59,7 @@ GET {{baseUrl}}/indexes/hotels-vector-quickstart/docs('1')?api-version=2023-11-
5959
Content-Type: application/json
6060
api-key: {{apiKey}}
6161
62-
### Change the description and city for Secret Point Hotel
62+
### Change the description, city, and tags for Secret Point Hotel
6363
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search.index?api-version=2023-11-01 HTTP/1.1
6464
Content-Type: application/json
6565
api-key: {{apiKey}}
@@ -69,9 +69,10 @@ POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search.index?api-version=
6969
{
7070
"@search.action": "mergeOrUpload",
7171
"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"],
7374
"Address": {
74-
"City": "Miami"
75+
"City": "Gotham City"
7576
}
7677
}
7778
]
@@ -104,15 +105,15 @@ The order of operations is:
104105

105106
1. [Update index schema](/rest/api/searchservice/indexes/create-or-update) on the search service.
106107

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.
108109

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.
110111

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.
112113

113114
## Drop and rebuild an index
114115

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.
116117

117118
| Action | Description |
118119
|-----------|-------------|
@@ -125,10 +126,12 @@ Some modifications require an index drop and rebuild.
125126

126127
The order of operations is:
127128

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.
129130

130131
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.
131132

133+
If you have capacity on your search service, keep the existing index while creating and testing the new one.
134+
132135
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.
133136

134137
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:
137140

138141
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.
139142

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-
142143
## Balancing workloads
143144

144145
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

Comments
 (0)