@azure/search-documents 11.3.0-beta.5 → 11.3.0-beta.8
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 +71 -55
- package/dist/index.js +1178 -601
- package/dist/index.js.map +1 -1
- package/dist-esm/src/constants.js +1 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/generated/data/index.js +0 -1
- package/dist-esm/src/generated/data/index.js.map +1 -1
- package/dist-esm/src/generated/data/models/index.js +2 -2
- package/dist-esm/src/generated/data/models/index.js.map +1 -1
- package/dist-esm/src/generated/data/operations/documents.js.map +1 -1
- package/dist-esm/src/generated/data/searchClient.js +31 -3
- package/dist-esm/src/generated/data/searchClient.js.map +1 -1
- package/dist-esm/src/generated/data/searchClientContext.js +1 -1
- package/dist-esm/src/generated/data/searchClientContext.js.map +1 -1
- package/dist-esm/src/generated/service/index.js +0 -1
- package/dist-esm/src/generated/service/index.js.map +1 -1
- package/dist-esm/src/generated/service/models/index.js +2 -0
- package/dist-esm/src/generated/service/models/index.js.map +1 -1
- package/dist-esm/src/generated/service/models/mappers.js +109 -0
- package/dist-esm/src/generated/service/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/service/models/parameters.js +15 -1
- package/dist-esm/src/generated/service/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/service/operations/aliases.js +166 -0
- package/dist-esm/src/generated/service/operations/aliases.js.map +1 -0
- package/dist-esm/src/generated/service/operations/dataSources.js.map +1 -1
- package/dist-esm/src/generated/service/operations/index.js +1 -0
- package/dist-esm/src/generated/service/operations/index.js.map +1 -1
- package/dist-esm/src/generated/service/operations/indexers.js.map +1 -1
- package/dist-esm/src/generated/service/operations/indexes.js.map +1 -1
- package/dist-esm/src/generated/service/operations/skillsets.js.map +1 -1
- package/dist-esm/src/generated/service/operations/synonymMaps.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/aliases.js +9 -0
- package/dist-esm/src/generated/service/operationsInterfaces/aliases.js.map +1 -0
- package/dist-esm/src/generated/service/operationsInterfaces/index.js +1 -0
- package/dist-esm/src/generated/service/operationsInterfaces/index.js.map +1 -1
- package/dist-esm/src/generated/service/searchServiceClient.js +29 -4
- package/dist-esm/src/generated/service/searchServiceClient.js.map +1 -1
- package/dist-esm/src/generated/service/searchServiceClientContext.js +1 -1
- package/dist-esm/src/generated/service/searchServiceClientContext.js.map +1 -1
- package/dist-esm/src/geographyPoint.js +1 -1
- package/dist-esm/src/geographyPoint.js.map +1 -1
- package/dist-esm/src/index.js +5 -4
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/indexDocumentsBatch.js +1 -1
- package/dist-esm/src/indexDocumentsBatch.js.map +1 -1
- package/dist-esm/src/indexModels.js.map +1 -1
- package/dist-esm/src/odataMetadataPolicy.js +1 -1
- package/dist-esm/src/odataMetadataPolicy.js.map +1 -1
- package/dist-esm/src/searchApiKeyCredentialPolicy.js +1 -1
- package/dist-esm/src/searchApiKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/searchAudience.js +21 -0
- package/dist-esm/src/searchAudience.js.map +1 -0
- package/dist-esm/src/searchClient.js +55 -40
- package/dist-esm/src/searchClient.js.map +1 -1
- package/dist-esm/src/searchIndexClient.js +206 -45
- package/dist-esm/src/searchIndexClient.js.map +1 -1
- package/dist-esm/src/searchIndexerClient.js +72 -57
- package/dist-esm/src/searchIndexerClient.js.map +1 -1
- package/dist-esm/src/searchIndexingBufferedSender.js +15 -16
- package/dist-esm/src/searchIndexingBufferedSender.js.map +1 -1
- package/dist-esm/src/serialization.js +5 -5
- package/dist-esm/src/serialization.js.map +1 -1
- package/dist-esm/src/serviceModels.js.map +1 -1
- package/dist-esm/src/serviceUtils.js +23 -19
- package/dist-esm/src/serviceUtils.js.map +1 -1
- package/dist-esm/src/synonymMapHelper.js +1 -1
- package/dist-esm/src/synonymMapHelper.js.map +1 -1
- package/dist-esm/src/tracing.js +6 -5
- package/dist-esm/src/tracing.js.map +1 -1
- package/package.json +22 -33
- package/types/search-documents.d.ts +195 -17
- package/CHANGELOG.md +0 -188
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**
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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.
|
|
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
|
|