@azure/search-documents 11.3.0-alpha.20220520.1 → 11.3.0-alpha.20220908.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,7 @@ Use the @azure/search-documents client library to:
20
20
  - Optimize results through scoring profiles to factor in business logic or freshness.
21
21
 
22
22
  Key links:
23
+
23
24
  - [Source code](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/search/search-documents/)
24
25
  - [Package (NPM)](https://www.npmjs.com/package/@azure/search-documents)
25
26
  - [API reference documentation](https://docs.microsoft.com/javascript/api/@azure/search-documents)
@@ -67,9 +68,9 @@ az search admin-key show --resource-group <your-resource-group-name> --service-n
67
68
 
68
69
  Alternatively, you can get the endpoint and Admin Key from the resource information in the [Azure Portal][azure_portal].
69
70
 
70
- There are two types of keys used to access your search service: **admin** *(read-write)* and **query** *(read-only)* keys. Restricting access and operations in client apps is essential to safeguarding the search assets on your service. Always use a query key rather than an admin key for any query originating from a client app.
71
+ There are two types of keys used to access your search service: **admin** _(read-write)_ and **query** _(read-only)_ keys. Restricting access and operations in client apps is essential to safeguarding the search assets on your service. Always use a query key rather than an admin key for any query originating from a client app.
71
72
 
72
- *Note: The example Azure CLI snippet above retrieves an admin key so it's easier to get started exploring APIs, but it should be managed carefully.*
73
+ _Note: The example Azure CLI snippet above retrieves an admin key so it's easier to get started exploring APIs, but it should be managed carefully._
73
74
 
74
75
  Once you have an api-key, you can use it as follows:
75
76
 
@@ -95,25 +96,63 @@ const indexClient = new SearchIndexClient("<endpoint>", new AzureKeyCredential("
95
96
  const indexerClient = new SearchIndexerClient("<endpoint>", new AzureKeyCredential("<apiKey>"));
96
97
  ```
97
98
 
99
+ ### Authenticate in a National Cloud
100
+
101
+ To authenticate in a [National Cloud](https://docs.microsoft.com/azure/active-directory/develop/authentication-national-cloud), you will need to make the following additions to your client configuration:
102
+
103
+ - Set the `Audience` in `SearchClientOptions`
104
+
105
+ ```js
106
+ const {
107
+ SearchClient,
108
+ SearchIndexClient,
109
+ SearchIndexerClient,
110
+ AzureKeyCredential,
111
+ KnownSearchAudience,
112
+ } = require("@azure/search-documents");
113
+
114
+ // To query and manipulate documents
115
+ const searchClient = new SearchClient(
116
+ "<endpoint>",
117
+ "<indexName>",
118
+ new AzureKeyCredential("<apiKey>"),
119
+ {
120
+ audience: KnownSearchAudience.AzureChina,
121
+ }
122
+ );
123
+
124
+ // To manage indexes and synonymmaps
125
+ const indexClient = new SearchIndexClient("<endpoint>", new AzureKeyCredential("<apiKey>"), {
126
+ audience: KnownSearchAudience.AzureChina,
127
+ });
128
+
129
+ // To manage indexers, datasources and skillsets
130
+ const indexerClient = new SearchIndexerClient("<endpoint>", new AzureKeyCredential("<apiKey>"), {
131
+ audience: KnownSearchAudience.AzureChina,
132
+ });
133
+ ```
134
+
98
135
  ## Key concepts
99
- An Azure Cognitive Search service contains one or more indexes that provide persistent storage of searchable data in the form of JSON documents. _(If you're brand new to search, you can make a very rough analogy between indexes and database tables.)_ The @azure/search-documents client library
136
+
137
+ An Azure Cognitive Search service contains one or more indexes that provide persistent storage of searchable data in the form of JSON documents. _(If you're brand new to search, you can make a very rough analogy between indexes and database tables.)_ The @azure/search-documents client library
100
138
  exposes operations on these resources through three main client types.
101
139
 
102
- * `SearchClient` helps with:
103
- * [Searching](https://docs.microsoft.com/azure/search/search-lucene-query-architecture) your indexed documents using [rich queries](https://docs.microsoft.com/azure/search/search-query-overview) and [powerful data shaping](https://docs.microsoft.com/azure/search/search-filters)
104
- * [Autocompleting](https://docs.microsoft.com/rest/api/searchservice/autocomplete) partially typed search terms based on documents in the index
105
- * [Suggesting](https://docs.microsoft.com/rest/api/searchservice/suggestions) the most likely matching text in documents as a user types
106
- * [Adding, Updating or Deleting Documents](https://docs.microsoft.com/rest/api/searchservice/addupdate-or-delete-documents) documents from an index
107
- * `SearchIndexClient` allows you to:
108
- * [Create, delete, update, or configure a search index](https://docs.microsoft.com/rest/api/searchservice/index-operations)
109
- * [Declare custom synonym maps to expand or rewrite queries](https://docs.microsoft.com/rest/api/searchservice/synonym-map-operations)
110
- * `SearchIndexerClient` allows you to:
111
- * [Start indexers to automatically crawl data sources](https://docs.microsoft.com/rest/api/searchservice/indexer-operations)
112
- * [Define AI powered Skillsets to transform and enrich your data](https://docs.microsoft.com/rest/api/searchservice/skillset-operations)
140
+ - `SearchClient` helps with:
141
+ - [Searching](https://docs.microsoft.com/azure/search/search-lucene-query-architecture) your indexed documents using [rich queries](https://docs.microsoft.com/azure/search/search-query-overview) and [powerful data shaping](https://docs.microsoft.com/azure/search/search-filters)
142
+ - [Autocompleting](https://docs.microsoft.com/rest/api/searchservice/autocomplete) partially typed search terms based on documents in the index
143
+ - [Suggesting](https://docs.microsoft.com/rest/api/searchservice/suggestions) the most likely matching text in documents as a user types
144
+ - [Adding, Updating or Deleting Documents](https://docs.microsoft.com/rest/api/searchservice/addupdate-or-delete-documents) documents from an index
145
+ - `SearchIndexClient` allows you to:
146
+ - [Create, delete, update, or configure a search index](https://docs.microsoft.com/rest/api/searchservice/index-operations)
147
+ - [Declare custom synonym maps to expand or rewrite queries](https://docs.microsoft.com/rest/api/searchservice/synonym-map-operations)
148
+ - `SearchIndexerClient` allows you to:
149
+ - [Start indexers to automatically crawl data sources](https://docs.microsoft.com/rest/api/searchservice/indexer-operations)
150
+ - [Define AI powered Skillsets to transform and enrich your data](https://docs.microsoft.com/rest/api/searchservice/skillset-operations)
113
151
 
114
152
  **Note**: These clients cannot function in the browser because the APIs it calls do not have support for Cross-Origin Resource Sharing (CORS).
115
153
 
116
154
  ## TypeScript/JavaScript specific concepts
155
+
117
156
  ### Documents
118
157
 
119
158
  An item stored inside a search index. The shape of this document is described in the index using `Field`s. Each Field has a name, a datatype, and additional metadata such as if it is searchable or filterable.
@@ -136,13 +175,13 @@ Typically you will only wish to [show a subset of search results](https://docs.m
136
175
 
137
176
  The following examples demonstrate the basics - please [check out our samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples) for much more.
138
177
 
139
- * [Creating an index](#create-an-index)
140
- * [Retrieving a specific document from your index](#retrieve-a-specific-document-from-an-index)
141
- * [Adding documents to your index](#adding-documents-into-an-index)
142
- * [Perform a search on documents](#perform-a-search-on-documents)
143
- * [Querying with TypeScript](#querying-with-typescript)
144
- * [Querying with OData filters](#querying-with-odata-filters)
145
- * [Querying with facets](#querying-with-facets)
178
+ - [Creating an index](#create-an-index)
179
+ - [Retrieving a specific document from your index](#retrieve-a-specific-document-from-an-index)
180
+ - [Adding documents to your index](#adding-documents-into-an-index)
181
+ - [Perform a search on documents](#perform-a-search-on-documents)
182
+ - [Querying with TypeScript](#querying-with-typescript)
183
+ - [Querying with OData filters](#querying-with-odata-filters)
184
+ - [Querying with facets](#querying-with-facets)
146
185
 
147
186
  ### Create an Index
148
187
 
@@ -204,11 +243,7 @@ A specific document can be retrieved by its primary key value:
204
243
  ```js
205
244
  const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
206
245
 
207
- const client = new SearchClient(
208
- "<endpoint>",
209
- "<indexName>",
210
- new AzureKeyCredential("<apiKey>")
211
- );
246
+ const client = new SearchClient("<endpoint>", "<indexName>", new AzureKeyCredential("<apiKey>"));
212
247
 
213
248
  async function main() {
214
249
  const result = await client.getDocument("1234");
@@ -225,11 +260,7 @@ You can upload multiple documents into index inside a batch:
225
260
  ```js
226
261
  const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
227
262
 
228
- const client = new SearchClient(
229
- "<endpoint>",
230
- "<indexName>",
231
- new AzureKeyCredential("<apiKey>")
232
- );
263
+ const client = new SearchClient("<endpoint>", "<indexName>", new AzureKeyCredential("<apiKey>"));
233
264
 
234
265
  async function main() {
235
266
  const uploadResult = await client.uploadDocuments([
@@ -253,11 +284,7 @@ To list all results of a particular query, you can use `search` with a search st
253
284
  ```js
254
285
  const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
255
286
 
256
- const client = new SearchClient(
257
- "<endpoint>",
258
- "<indexName>",
259
- new AzureKeyCredential("<apiKey>")
260
- );
287
+ const client = new SearchClient("<endpoint>", "<indexName>", new AzureKeyCredential("<apiKey>"));
261
288
 
262
289
  async function main() {
263
290
  const searchResults = await client.search("wifi -luxury");
@@ -274,11 +301,7 @@ For a more advanced search that uses [Lucene syntax](https://docs.microsoft.com/
274
301
  ```js
275
302
  const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
276
303
 
277
- const client = new SearchClient(
278
- "<endpoint>",
279
- "<indexName>",
280
- new AzureKeyCredential("<apiKey>")
281
- );
304
+ const client = new SearchClient("<endpoint>", "<indexName>", new AzureKeyCredential("<apiKey>"));
282
305
 
283
306
  async function main() {
284
307
  const searchResults = await client.search('Category:budget AND "recently renovated"^3', {
@@ -340,11 +363,7 @@ Using the `filter` query parameter allows you to query an index using the syntax
340
363
  ```js
341
364
  const { SearchClient, AzureKeyCredential, odata } = require("@azure/search-documents");
342
365
 
343
- const client = new SearchClient(
344
- "<endpoint>",
345
- "<indexName>",
346
- new AzureKeyCredential("<apiKey>")
347
- );
366
+ const client = new SearchClient("<endpoint>", "<indexName>", new AzureKeyCredential("<apiKey>"));
348
367
 
349
368
  async function main() {
350
369
  const baseRateMax = 200;
@@ -371,11 +390,7 @@ main();
371
390
  ```js
372
391
  const { SearchClient, AzureKeyCredential } = require("@azure/search-documents");
373
392
 
374
- const client = new SearchClient(
375
- "<endpoint>",
376
- "<indexName>",
377
- new AzureKeyCredential("<apiKey>")
378
- );
393
+ const client = new SearchClient("<endpoint>", "<indexName>", new AzureKeyCredential("<apiKey>"));
379
394
 
380
395
  async function main() {
381
396
  const searchResults = await client.search("WiFi", {
@@ -417,15 +432,16 @@ setLogLevel("info");
417
432
  For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
418
433
 
419
434
  ## Next steps
420
- * [Go further with search-documents and our samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples)
421
- * [Watch a demo or deep dive video](https://azure.microsoft.com/resources/videos/index/?services=search)
422
- * [Read more about the Azure Cognitive Search service](https://docs.microsoft.com/azure/search/search-what-is-azure-search)
435
+
436
+ - [Go further with search-documents and our samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples)
437
+ - [Watch a demo or deep dive video](https://azure.microsoft.com/resources/videos/index/?services=search)
438
+ - [Read more about the Azure Cognitive Search service](https://docs.microsoft.com/azure/search/search-what-is-azure-search)
423
439
 
424
440
  ## Contributing
425
441
 
426
442
  If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
427
443
 
428
- This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].
444
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].
429
445
 
430
446
  This project has adopted the [Microsoft Open Source Code of Conduct][coc].For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments.
431
447