@azure/search-documents 12.0.0-beta.4 → 12.1.0-beta.1
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 +52 -32
- package/dist/index.js +13493 -13180
- package/dist/index.js.map +1 -1
- package/dist-esm/src/constants.js +2 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/errorModels.js +4 -0
- package/dist-esm/src/errorModels.js.map +1 -0
- package/dist-esm/src/generated/data/models/index.js +37 -53
- package/dist-esm/src/generated/data/models/index.js.map +1 -1
- package/dist-esm/src/generated/data/models/mappers.js +398 -331
- package/dist-esm/src/generated/data/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/data/models/parameters.js +195 -195
- package/dist-esm/src/generated/data/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/data/operations/documents.js +41 -41
- package/dist-esm/src/generated/data/operations/documents.js.map +1 -1
- package/dist-esm/src/generated/data/operationsInterfaces/documents.js.map +1 -1
- package/dist-esm/src/generated/data/searchClient.js +30 -4
- package/dist-esm/src/generated/data/searchClient.js.map +1 -1
- package/dist-esm/src/generated/service/models/index.js +138 -69
- package/dist-esm/src/generated/service/models/index.js.map +1 -1
- package/dist-esm/src/generated/service/models/mappers.js +1821 -1663
- package/dist-esm/src/generated/service/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/service/models/parameters.js +64 -64
- package/dist-esm/src/generated/service/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/service/operations/aliases.js +22 -22
- package/dist-esm/src/generated/service/operations/aliases.js.map +1 -1
- package/dist-esm/src/generated/service/operations/dataSources.js +23 -23
- package/dist-esm/src/generated/service/operations/dataSources.js.map +1 -1
- package/dist-esm/src/generated/service/operations/indexers.js +36 -36
- package/dist-esm/src/generated/service/operations/indexers.js.map +1 -1
- package/dist-esm/src/generated/service/operations/indexes.js +30 -30
- package/dist-esm/src/generated/service/operations/indexes.js.map +1 -1
- package/dist-esm/src/generated/service/operations/skillsets.js +26 -26
- package/dist-esm/src/generated/service/operations/skillsets.js.map +1 -1
- package/dist-esm/src/generated/service/operations/synonymMaps.js +22 -22
- package/dist-esm/src/generated/service/operations/synonymMaps.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/aliases.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/dataSources.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/indexers.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/indexes.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/skillsets.js.map +1 -1
- package/dist-esm/src/generated/service/operationsInterfaces/synonymMaps.js.map +1 -1
- package/dist-esm/src/generated/service/searchServiceClient.js +35 -9
- package/dist-esm/src/generated/service/searchServiceClient.js.map +1 -1
- package/dist-esm/src/generatedStringLiteralUnions.js +4 -0
- package/dist-esm/src/generatedStringLiteralUnions.js.map +1 -0
- package/dist-esm/src/index.js +8 -9
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/indexDocumentsBatch.js.map +1 -1
- package/dist-esm/src/indexModels.js.map +1 -1
- package/dist-esm/src/odata.js.map +1 -1
- package/dist-esm/src/odataMetadataPolicy.js.map +1 -1
- package/dist-esm/src/searchApiKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/searchClient.js +36 -27
- package/dist-esm/src/searchClient.js.map +1 -1
- package/dist-esm/src/searchIndexClient.js +15 -29
- package/dist-esm/src/searchIndexClient.js.map +1 -1
- package/dist-esm/src/searchIndexerClient.js +9 -6
- package/dist-esm/src/searchIndexerClient.js.map +1 -1
- package/dist-esm/src/searchIndexingBufferedSender.js +3 -8
- package/dist-esm/src/searchIndexingBufferedSender.js.map +1 -1
- package/dist-esm/src/serialization.js.map +1 -1
- package/dist-esm/src/serviceModels.js.map +1 -1
- package/dist-esm/src/serviceUtils.js +44 -67
- package/dist-esm/src/serviceUtils.js.map +1 -1
- package/dist-esm/src/synonymMapHelper.browser.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 +1 -1
- package/dist-esm/src/tracing.js.map +1 -1
- package/package.json +42 -43
- package/types/search-documents.d.ts +1014 -1458
package/README.md
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
# Azure
|
|
1
|
+
# Azure AI Search client library for JavaScript
|
|
2
2
|
|
|
3
|
-
[Azure
|
|
3
|
+
[Azure AI Search](https://docs.microsoft.com/azure/search/) (formerly known as "Azure Cognitive Search") is an AI-powered information retrieval platform that helps developers build rich search experiences and generative AI apps that combine large language models with enterprise data.
|
|
4
4
|
|
|
5
|
-
The Azure
|
|
5
|
+
The Azure AI Search service is well suited for the following application scenarios:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
* Consolidate varied content types into a single searchable index.
|
|
8
|
+
To populate an index, you can push JSON documents that contain your content,
|
|
9
|
+
or if your data is already in Azure, create an indexer to pull in data
|
|
10
|
+
automatically.
|
|
11
|
+
* Attach skillsets to an indexer to create searchable content from images
|
|
12
|
+
and unstructured documents. A skillset leverages APIs from Azure AI Services
|
|
13
|
+
for built-in OCR, entity recognition, key phrase extraction, language
|
|
14
|
+
detection, text translation, and sentiment analysis. You can also add
|
|
15
|
+
custom skills to integrate external processing of your content during
|
|
16
|
+
data ingestion.
|
|
17
|
+
* In a search client application, implement query logic and user experiences
|
|
18
|
+
similar to commercial web search engines and chat-style apps.
|
|
10
19
|
|
|
11
20
|
Use the @azure/search-documents client library to:
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
* Submit queries using vector, keyword, and hybrid query forms.
|
|
23
|
+
* Implement filtered queries for metadata, geospatial search, faceted navigation,
|
|
24
|
+
or to narrow results based on filter criteria.
|
|
25
|
+
* Create and manage search indexes.
|
|
26
|
+
* Upload and update documents in the search index.
|
|
27
|
+
* Create and manage indexers that pull data from Azure into an index.
|
|
28
|
+
* Create and manage skillsets that add AI enrichment to data ingestion.
|
|
29
|
+
* Create and manage analyzers for advanced text analysis or multi-lingual content.
|
|
30
|
+
* Optimize results through semantic ranking and scoring profiles to factor in business logic or freshness.
|
|
21
31
|
|
|
22
32
|
Key links:
|
|
23
33
|
|
|
@@ -39,7 +49,7 @@ npm install @azure/search-documents
|
|
|
39
49
|
### Currently supported environments
|
|
40
50
|
|
|
41
51
|
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
42
|
-
- Latest versions of Safari, Chrome, Edge, and Firefox.
|
|
52
|
+
- Latest versions of Safari, Chrome, Microsoft Edge, and Firefox.
|
|
43
53
|
|
|
44
54
|
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
|
45
55
|
|
|
@@ -58,16 +68,20 @@ See [choosing a pricing tier](https://docs.microsoft.com/azure/search/search-sku
|
|
|
58
68
|
|
|
59
69
|
### Authenticate the client
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
To interact with the search service, you'll need to create an instance of the appropriate client class: `SearchClient` for searching indexed documents, `SearchIndexClient` for managing indexes, or `SearchIndexerClient` for crawling data sources and loading search documents into an index. To instantiate a client object, you'll need an **endpoint** and **Azure roles** or an **API key**. You can refer to the documentation for more information on [supported authenticating approaches](https://learn.microsoft.com/azure/search/search-security-overview#authentication) with the search service.
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
#### Get an API Key
|
|
64
74
|
|
|
65
|
-
|
|
75
|
+
An API key can be an easier approach to start with because it doesn't require pre-existing role assignments.
|
|
76
|
+
|
|
77
|
+
You can get the **endpoint** and an **API key** from the search service in the [Azure portal](https://portal.azure.com/). Please refer the [documentation](https://docs.microsoft.com/azure/search/search-security-api-keys) for instructions on how to get an API key.
|
|
78
|
+
|
|
79
|
+
Alternatively, you can use the following [Azure CLI](https://learn.microsoft.com/cli/azure/) command to retrieve the API key from the search service:
|
|
80
|
+
|
|
81
|
+
```Powershell
|
|
66
82
|
az search admin-key show --resource-group <your-resource-group-name> --service-name <your-resource-name>
|
|
67
83
|
```
|
|
68
84
|
|
|
69
|
-
Alternatively, you can get the endpoint and Admin Key from the resource information in the [Azure Portal][azure_portal].
|
|
70
|
-
|
|
71
85
|
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.
|
|
72
86
|
|
|
73
87
|
_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._
|
|
@@ -134,17 +148,24 @@ const indexerClient = new SearchIndexerClient("<endpoint>", new AzureKeyCredenti
|
|
|
134
148
|
|
|
135
149
|
## Key concepts
|
|
136
150
|
|
|
137
|
-
An Azure
|
|
151
|
+
An Azure AI 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
|
|
138
152
|
exposes operations on these resources through three main client types.
|
|
139
153
|
|
|
140
154
|
- `SearchClient` helps with:
|
|
141
|
-
- [Searching](https://docs.microsoft.com/azure/search/search-lucene-query-architecture)
|
|
155
|
+
- [Searching](https://docs.microsoft.com/azure/search/search-lucene-query-architecture)
|
|
156
|
+
your indexed documents using [vector queries](https://learn.microsoft.com/azure/search/vector-search-how-to-query),
|
|
157
|
+
[keyword queries](https://learn.microsoft.com/azure/search/search-query-create)
|
|
158
|
+
and [hybrid queries](https://learn.microsoft.com/azure/search/hybrid-search-how-to-query)
|
|
159
|
+
- [Vector query filters](https://learn.microsoft.com/azure/search/vector-search-filters) and [Text query filters](https://learn.microsoft.com/azure/search/search-filters)
|
|
160
|
+
- [Semantic ranking](https://learn.microsoft.com/azure/search/semantic-how-to-query-request) and [scoring profiles](https://learn.microsoft.com/azure/search/index-add-scoring-profiles) for boosting relevance
|
|
142
161
|
- [Autocompleting](https://docs.microsoft.com/rest/api/searchservice/autocomplete) partially typed search terms based on documents in the index
|
|
143
162
|
- [Suggesting](https://docs.microsoft.com/rest/api/searchservice/suggestions) the most likely matching text in documents as a user types
|
|
144
163
|
- [Adding, Updating or Deleting Documents](https://docs.microsoft.com/rest/api/searchservice/addupdate-or-delete-documents) documents from an index
|
|
164
|
+
|
|
145
165
|
- `SearchIndexClient` allows you to:
|
|
146
166
|
- [Create, delete, update, or configure a search index](https://docs.microsoft.com/rest/api/searchservice/index-operations)
|
|
147
167
|
- [Declare custom synonym maps to expand or rewrite queries](https://docs.microsoft.com/rest/api/searchservice/synonym-map-operations)
|
|
168
|
+
|
|
148
169
|
- `SearchIndexerClient` allows you to:
|
|
149
170
|
- [Start indexers to automatically crawl data sources](https://docs.microsoft.com/rest/api/searchservice/indexer-operations)
|
|
150
171
|
- [Define AI powered Skillsets to transform and enrich your data](https://docs.microsoft.com/rest/api/searchservice/skillset-operations)
|
|
@@ -328,14 +349,14 @@ interface Hotel {
|
|
|
328
349
|
hotelId?: string;
|
|
329
350
|
hotelName?: string | null;
|
|
330
351
|
description?: string | null;
|
|
331
|
-
descriptionVector?: Array<number
|
|
352
|
+
descriptionVector?: Array<number>;
|
|
332
353
|
parkingIncluded?: boolean | null;
|
|
333
354
|
lastRenovationDate?: Date | null;
|
|
334
355
|
rating?: number | null;
|
|
335
356
|
rooms?: Array<{
|
|
336
357
|
beds?: number | null;
|
|
337
358
|
description?: string | null;
|
|
338
|
-
}
|
|
359
|
+
}>;
|
|
339
360
|
}
|
|
340
361
|
|
|
341
362
|
const client = new SearchClient<Hotel>(
|
|
@@ -354,7 +375,7 @@ async function main() {
|
|
|
354
375
|
// These are other ways to declare the correct type for `select`.
|
|
355
376
|
const select = ["hotelId", "hotelName", "rooms/beds"] as const;
|
|
356
377
|
// This declaration lets you opt out of narrowing the TypeScript type of your documents,
|
|
357
|
-
// though the
|
|
378
|
+
// though the AI Search service will still only return these fields.
|
|
358
379
|
const selectWide: SelectFields<Hotel>[] = ["hotelId", "hotelName", "rooms/beds"];
|
|
359
380
|
// This is an invalid declaration. Passing this to `select` will result in a compiler error
|
|
360
381
|
// unless you opt out of including the model in the client constructor.
|
|
@@ -385,7 +406,7 @@ async function main() {
|
|
|
385
406
|
const searchResults = await client.search("WiFi", {
|
|
386
407
|
filter: odata`Rooms/any(room: room/BaseRate lt ${baseRateMax}) and Rating ge ${ratingMin}`,
|
|
387
408
|
orderBy: ["Rating desc"],
|
|
388
|
-
select: ["hotelId", "hotelName", "
|
|
409
|
+
select: ["hotelId", "hotelName", "Rating"],
|
|
389
410
|
});
|
|
390
411
|
for await (const result of searchResults.results) {
|
|
391
412
|
// Each result will have "HotelId", "HotelName", and "Rating"
|
|
@@ -399,7 +420,7 @@ main();
|
|
|
399
420
|
|
|
400
421
|
#### Querying with vectors
|
|
401
422
|
|
|
402
|
-
Text embeddings can be queried using the `vector` search parameter.
|
|
423
|
+
Text embeddings can be queried using the `vector` search parameter. See [Query vectors](https://learn.microsoft.com/azure/search/vector-search-how-to-query) and [Filter vector queries](https://learn.microsoft.com/azure/search/vector-search-filters) for more information.
|
|
403
424
|
|
|
404
425
|
```js
|
|
405
426
|
const { SearchClient, AzureKeyCredential, odata } = require("@azure/search-documents");
|
|
@@ -462,7 +483,7 @@ When retrieving results, a `facets` property will be available that will indicat
|
|
|
462
483
|
|
|
463
484
|
### Logging
|
|
464
485
|
|
|
465
|
-
Enabling logging
|
|
486
|
+
Enabling logging can help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
466
487
|
|
|
467
488
|
```javascript
|
|
468
489
|
import { setLogLevel } from "@azure/logger";
|
|
@@ -475,8 +496,7 @@ For more detailed instructions on how to enable logs, you can look at the [@azur
|
|
|
475
496
|
## Next steps
|
|
476
497
|
|
|
477
498
|
- [Go further with search-documents and our samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/search-documents/samples)
|
|
478
|
-
- [
|
|
479
|
-
- [Read more about the Azure Cognitive Search service](https://docs.microsoft.com/azure/search/search-what-is-azure-search)
|
|
499
|
+
- [Read more about the Azure AI Search service](https://docs.microsoft.com/azure/search/search-what-is-azure-search)
|
|
480
500
|
|
|
481
501
|
## Contributing
|
|
482
502
|
|
|
@@ -484,11 +504,11 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
484
504
|
|
|
485
505
|
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].
|
|
486
506
|
|
|
487
|
-
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.
|
|
507
|
+
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.
|
|
488
508
|
|
|
489
509
|
## Related projects
|
|
490
510
|
|
|
491
|
-
- [Microsoft Azure SDK for
|
|
511
|
+
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
|
|
492
512
|
|
|
493
513
|

|
|
494
514
|
|