@azure/search-documents 11.3.1 → 12.0.0-alpha.20230306.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.
Files changed (96) hide show
  1. package/README.md +19 -41
  2. package/dist/index.js +3887 -997
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/constants.js +1 -1
  5. package/dist-esm/src/constants.js.map +1 -1
  6. package/dist-esm/src/generated/data/index.js +1 -1
  7. package/dist-esm/src/generated/data/index.js.map +1 -1
  8. package/dist-esm/src/generated/data/models/index.js +202 -1
  9. package/dist-esm/src/generated/data/models/index.js.map +1 -1
  10. package/dist-esm/src/generated/data/models/mappers.js +138 -1
  11. package/dist-esm/src/generated/data/models/mappers.js.map +1 -1
  12. package/dist-esm/src/generated/data/models/parameters.js +72 -22
  13. package/dist-esm/src/generated/data/models/parameters.js.map +1 -1
  14. package/dist-esm/src/generated/data/operations/documents.js +32 -76
  15. package/dist-esm/src/generated/data/operations/documents.js.map +1 -1
  16. package/dist-esm/src/generated/data/operationsInterfaces/documents.js +9 -0
  17. package/dist-esm/src/generated/data/operationsInterfaces/documents.js.map +1 -0
  18. package/dist-esm/src/generated/data/operationsInterfaces/index.js +9 -0
  19. package/dist-esm/src/generated/data/operationsInterfaces/index.js.map +1 -0
  20. package/dist-esm/src/generated/data/searchClient.js +33 -5
  21. package/dist-esm/src/generated/data/searchClient.js.map +1 -1
  22. package/dist-esm/src/generated/data/searchClientContext.js +13 -11
  23. package/dist-esm/src/generated/data/searchClientContext.js.map +1 -1
  24. package/dist-esm/src/generated/service/index.js +1 -1
  25. package/dist-esm/src/generated/service/index.js.map +1 -1
  26. package/dist-esm/src/generated/service/models/index.js +1284 -1
  27. package/dist-esm/src/generated/service/models/index.js.map +1 -1
  28. package/dist-esm/src/generated/service/models/mappers.js +741 -16
  29. package/dist-esm/src/generated/service/models/mappers.js.map +1 -1
  30. package/dist-esm/src/generated/service/models/parameters.js +51 -10
  31. package/dist-esm/src/generated/service/models/parameters.js.map +1 -1
  32. package/dist-esm/src/generated/service/operations/aliases.js +160 -0
  33. package/dist-esm/src/generated/service/operations/aliases.js.map +1 -0
  34. package/dist-esm/src/generated/service/operations/dataSources.js +16 -39
  35. package/dist-esm/src/generated/service/operations/dataSources.js.map +1 -1
  36. package/dist-esm/src/generated/service/operations/index.js +1 -0
  37. package/dist-esm/src/generated/service/operations/index.js.map +1 -1
  38. package/dist-esm/src/generated/service/operations/indexers.js +47 -57
  39. package/dist-esm/src/generated/service/operations/indexers.js.map +1 -1
  40. package/dist-esm/src/generated/service/operations/indexes.js +16 -55
  41. package/dist-esm/src/generated/service/operations/indexes.js.map +1 -1
  42. package/dist-esm/src/generated/service/operations/skillsets.js +42 -39
  43. package/dist-esm/src/generated/service/operations/skillsets.js.map +1 -1
  44. package/dist-esm/src/generated/service/operations/synonymMaps.js +12 -38
  45. package/dist-esm/src/generated/service/operations/synonymMaps.js.map +1 -1
  46. package/dist-esm/src/generated/service/operationsInterfaces/aliases.js +9 -0
  47. package/dist-esm/src/generated/service/operationsInterfaces/aliases.js.map +1 -0
  48. package/dist-esm/src/generated/service/operationsInterfaces/dataSources.js +9 -0
  49. package/dist-esm/src/generated/service/operationsInterfaces/dataSources.js.map +1 -0
  50. package/dist-esm/src/generated/service/operationsInterfaces/index.js +14 -0
  51. package/dist-esm/src/generated/service/operationsInterfaces/index.js.map +1 -0
  52. package/dist-esm/src/generated/service/operationsInterfaces/indexers.js +9 -0
  53. package/dist-esm/src/generated/service/operationsInterfaces/indexers.js.map +1 -0
  54. package/dist-esm/src/generated/service/operationsInterfaces/indexes.js +9 -0
  55. package/dist-esm/src/generated/service/operationsInterfaces/indexes.js.map +1 -0
  56. package/dist-esm/src/generated/service/operationsInterfaces/skillsets.js +9 -0
  57. package/dist-esm/src/generated/service/operationsInterfaces/skillsets.js.map +1 -0
  58. package/dist-esm/src/generated/service/operationsInterfaces/synonymMaps.js +9 -0
  59. package/dist-esm/src/generated/service/operationsInterfaces/synonymMaps.js.map +1 -0
  60. package/dist-esm/src/generated/service/searchServiceClient.js +38 -16
  61. package/dist-esm/src/generated/service/searchServiceClient.js.map +1 -1
  62. package/dist-esm/src/generated/service/searchServiceClientContext.js +13 -11
  63. package/dist-esm/src/generated/service/searchServiceClientContext.js.map +1 -1
  64. package/dist-esm/src/geographyPoint.js +1 -1
  65. package/dist-esm/src/geographyPoint.js.map +1 -1
  66. package/dist-esm/src/index.js +4 -2
  67. package/dist-esm/src/index.js.map +1 -1
  68. package/dist-esm/src/indexDocumentsBatch.js +1 -1
  69. package/dist-esm/src/indexDocumentsBatch.js.map +1 -1
  70. package/dist-esm/src/indexModels.js +0 -1
  71. package/dist-esm/src/indexModels.js.map +1 -1
  72. package/dist-esm/src/odataMetadataPolicy.js +7 -15
  73. package/dist-esm/src/odataMetadataPolicy.js.map +1 -1
  74. package/dist-esm/src/searchApiKeyCredentialPolicy.js +8 -21
  75. package/dist-esm/src/searchApiKeyCredentialPolicy.js.map +1 -1
  76. package/dist-esm/src/searchAudience.js.map +1 -1
  77. package/dist-esm/src/searchClient.js +200 -70
  78. package/dist-esm/src/searchClient.js.map +1 -1
  79. package/dist-esm/src/searchIndexClient.js +240 -74
  80. package/dist-esm/src/searchIndexClient.js.map +1 -1
  81. package/dist-esm/src/searchIndexerClient.js +143 -86
  82. package/dist-esm/src/searchIndexerClient.js.map +1 -1
  83. package/dist-esm/src/searchIndexingBufferedSender.js +16 -17
  84. package/dist-esm/src/searchIndexingBufferedSender.js.map +1 -1
  85. package/dist-esm/src/serialization.js +5 -5
  86. package/dist-esm/src/serialization.js.map +1 -1
  87. package/dist-esm/src/serviceModels.js.map +1 -1
  88. package/dist-esm/src/serviceUtils.js +68 -31
  89. package/dist-esm/src/serviceUtils.js.map +1 -1
  90. package/dist-esm/src/synonymMapHelper.js +6 -2
  91. package/dist-esm/src/synonymMapHelper.js.map +1 -1
  92. package/dist-esm/src/tracing.js +6 -5
  93. package/dist-esm/src/tracing.js.map +1 -1
  94. package/package.json +48 -49
  95. package/types/search-documents.d.ts +1935 -235
  96. package/CHANGELOG.md +0 -233
@@ -1,19 +1,17 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
  import { __asyncDelegator, __asyncGenerator, __asyncValues, __await, __rest } from "tslib";
4
- /// <reference lib="esnext.asynciterable" />
5
- import { createPipelineFromOptions, operationOptionsToRequestOptionsBase, bearerTokenAuthenticationPolicy } from "@azure/core-http";
4
+ import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
6
5
  import { SearchClient as GeneratedClient } from "./generated/data/searchClient";
7
6
  import { isTokenCredential } from "@azure/core-auth";
8
7
  import { createSearchApiKeyCredentialPolicy } from "./searchApiKeyCredentialPolicy";
9
8
  import { SDK_VERSION } from "./constants";
10
9
  import { logger } from "./logger";
11
10
  import { createSpan } from "./tracing";
12
- import { SpanStatusCode } from "@azure/core-tracing";
13
11
  import { deserialize, serialize } from "./serialization";
14
- import { odataMetadataPolicy } from "./odataMetadataPolicy";
12
+ import { createOdataMetadataPolicy } from "./odataMetadataPolicy";
15
13
  import { IndexDocumentsBatch } from "./indexDocumentsBatch";
16
- import { encode, decode } from "./base64";
14
+ import { decode, encode } from "./base64";
17
15
  import * as utils from "./serviceUtils";
18
16
  import { KnownSearchAudience } from "./searchAudience";
19
17
  /**
@@ -32,21 +30,45 @@ export class SearchClient {
32
30
  * const client = new SearchClient(
33
31
  * "<endpoint>",
34
32
  * "<indexName>",
35
- * new AzureKeyCredential("<Admin Key>");
33
+ * new AzureKeyCredential("<Admin Key>")
36
34
  * );
37
35
  * ```
36
+ *
37
+ * Optionally, the type of the model can be used to enable strong typing and type hints:
38
+ * ```ts
39
+ * type Model = {
40
+ * keyName: string;
41
+ * field1?: string | null;
42
+ * field2?: { anotherField?: string | null } | null;
43
+ * };
44
+ *
45
+ * const client = new SearchClient<Model>(
46
+ * ...
47
+ * );
48
+ * ```
49
+ *
38
50
  * @param endpoint - The endpoint of the search service
39
51
  * @param indexName - The name of the index
40
52
  * @param credential - Used to authenticate requests to the service.
41
53
  * @param options - Used to configure the Search client.
54
+ *
55
+ * @typeParam Model - An optional type that represents the documents stored in
56
+ * the search index. For the best typing experience, all non-key fields should
57
+ * be marked optional and nullable, and the key property should have the
58
+ * non-nullable type `string`.
42
59
  */
43
60
  constructor(endpoint, indexName, credential, options = {}) {
44
61
  /// Maintenance note: when updating supported API versions,
45
62
  /// the ContinuationToken logic will need to be updated below.
63
+ /**
64
+ * The service version to use when communicating with the service.
65
+ */
66
+ this.serviceVersion = utils.defaultServiceVersion;
46
67
  /**
47
68
  * The API version to use when communicating with the service.
69
+ * @deprecated use {@Link serviceVersion} instead
48
70
  */
49
- this.apiVersion = "2020-06-30-Preview";
71
+ this.apiVersion = utils.defaultServiceVersion;
50
72
  this.endpoint = endpoint;
51
73
  this.indexName = indexName;
52
74
  const libInfo = `azsdk-js-search-documents/${SDK_VERSION}`;
@@ -59,37 +81,44 @@ export class SearchClient {
59
81
  else {
60
82
  options.userAgentOptions.userAgentPrefix = libInfo;
61
83
  }
62
- const internalPipelineOptions = Object.assign(Object.assign({}, options), {
84
+ const internalClientPipelineOptions = Object.assign(Object.assign({}, options), {
63
85
  loggingOptions: {
64
86
  logger: logger.info,
65
- allowedHeaderNames: [
87
+ additionalAllowedHeaderNames: [
66
88
  "elapsed-time",
67
89
  "Location",
68
90
  "OData-MaxVersion",
69
91
  "OData-Version",
70
92
  "Prefer",
71
- "throttle-reason"
72
- ]
73
- }
93
+ "throttle-reason",
94
+ ],
95
+ },
74
96
  });
75
- const scope = options.audience
76
- ? `${options.audience}/.default`
77
- : `${KnownSearchAudience.AzurePublicCloud}/.default`;
78
- const requestPolicyFactory = isTokenCredential(credential)
79
- ? bearerTokenAuthenticationPolicy(credential, scope)
80
- : createSearchApiKeyCredentialPolicy(credential);
81
- const pipeline = createPipelineFromOptions(internalPipelineOptions, requestPolicyFactory);
82
- if (Array.isArray(pipeline.requestPolicyFactories)) {
83
- pipeline.requestPolicyFactories.unshift(odataMetadataPolicy("none"));
84
- }
85
- let apiVersion = this.apiVersion;
86
97
  if (options.apiVersion) {
87
- if (!["2020-06-30-Preview", "2020-06-30"].includes(options.apiVersion)) {
98
+ if (!utils.serviceVersions.includes(options.apiVersion)) {
88
99
  throw new Error(`Invalid Api Version: ${options.apiVersion}`);
89
100
  }
90
- apiVersion = options.apiVersion;
101
+ this.serviceVersion = options.apiVersion;
102
+ this.apiVersion = options.apiVersion;
91
103
  }
92
- this.client = new GeneratedClient(this.endpoint, this.indexName, apiVersion, pipeline);
104
+ if (options.serviceVersion) {
105
+ if (!utils.serviceVersions.includes(options.serviceVersion)) {
106
+ throw new Error(`Invalid Service Version: ${options.serviceVersion}`);
107
+ }
108
+ this.serviceVersion = options.serviceVersion;
109
+ this.apiVersion = options.serviceVersion;
110
+ }
111
+ this.client = new GeneratedClient(this.endpoint, this.indexName, this.serviceVersion, internalClientPipelineOptions);
112
+ if (isTokenCredential(credential)) {
113
+ const scope = options.audience
114
+ ? `${options.audience}/.default`
115
+ : `${KnownSearchAudience.AzurePublicCloud}/.default`;
116
+ this.client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({ credential, scopes: scope }));
117
+ }
118
+ else {
119
+ this.client.pipeline.addPolicy(createSearchApiKeyCredentialPolicy(credential));
120
+ }
121
+ this.client.pipeline.addPolicy(createOdataMetadataPolicy("none"));
93
122
  }
94
123
  /**
95
124
  * Retrieves the number of documents in the index.
@@ -98,13 +127,19 @@ export class SearchClient {
98
127
  async getDocumentsCount(options = {}) {
99
128
  const { span, updatedOptions } = createSpan("SearchClient-getDocumentsCount", options);
100
129
  try {
101
- const result = await this.client.documents.count(operationOptionsToRequestOptionsBase(updatedOptions));
102
- return Number(result._response.bodyAsText);
130
+ let documentsCount = 0;
131
+ await this.client.documents.count(Object.assign(Object.assign({}, updatedOptions), { onResponse: (rawResponse, flatResponse) => {
132
+ documentsCount = Number(rawResponse.bodyAsText);
133
+ if (updatedOptions.onResponse) {
134
+ updatedOptions.onResponse(rawResponse, flatResponse);
135
+ }
136
+ } }));
137
+ return documentsCount;
103
138
  }
104
139
  catch (e) {
105
140
  span.setStatus({
106
- code: SpanStatusCode.ERROR,
107
- message: e.message
141
+ status: "error",
142
+ error: e.message,
108
143
  });
109
144
  throw e;
110
145
  }
@@ -118,6 +153,33 @@ export class SearchClient {
118
153
  * @param searchText - The search text on which to base autocomplete results.
119
154
  * @param suggesterName - The name of the suggester as specified in the suggesters collection that's part of the index definition.
120
155
  * @param options - Options to the autocomplete operation.
156
+ * @example
157
+ * ```ts
158
+ * import {
159
+ * AzureKeyCredential,
160
+ * SearchClient,
161
+ * SelectFields,
162
+ * } from "@azure/search-documents";
163
+ *
164
+ * type Model = {
165
+ * key: string;
166
+ * azure?: { sdk: string | null } | null;
167
+ * };
168
+ *
169
+ * const client = new SearchClient<Model>(
170
+ * "endpoint.azure",
171
+ * "indexName",
172
+ * new AzureKeyCredential("key")
173
+ * );
174
+ *
175
+ * const searchFields: SelectFields<Model>[] = ["azure/sdk"];
176
+ *
177
+ * const autocompleteResult = await client.autocomplete(
178
+ * "searchText",
179
+ * "suggesterName",
180
+ * { searchFields }
181
+ * );
182
+ * ```
121
183
  */
122
184
  async autocomplete(searchText, suggesterName, options = {}) {
123
185
  const { operationOptions, restOptions } = this.extractOperationOptions(Object.assign({}, options));
@@ -131,13 +193,13 @@ export class SearchClient {
131
193
  }
132
194
  const { span, updatedOptions } = createSpan("SearchClient-autocomplete", operationOptions);
133
195
  try {
134
- const result = await this.client.documents.autocompletePost(fullOptions, operationOptionsToRequestOptionsBase(updatedOptions));
196
+ const result = await this.client.documents.autocompletePost(fullOptions, updatedOptions);
135
197
  return result;
136
198
  }
137
199
  catch (e) {
138
200
  span.setStatus({
139
- code: SpanStatusCode.ERROR,
140
- message: e.message
201
+ status: "error",
202
+ error: e.message,
141
203
  });
142
204
  throw e;
143
205
  }
@@ -147,26 +209,27 @@ export class SearchClient {
147
209
  }
148
210
  async searchDocuments(searchText, options = {}, nextPageParameters = {}) {
149
211
  const { operationOptions, restOptions } = this.extractOperationOptions(Object.assign({}, options));
150
- const { select, searchFields, orderBy } = restOptions, nonFieldOptions = __rest(restOptions, ["select", "searchFields", "orderBy"]);
151
- const fullOptions = Object.assign(Object.assign({ searchFields: this.convertSearchFields(searchFields), select: this.convertSelect(select), orderBy: this.convertOrderBy(orderBy) }, nonFieldOptions), nextPageParameters);
212
+ const { select, searchFields, orderBy, semanticFields } = restOptions, nonFieldOptions = __rest(restOptions, ["select", "searchFields", "orderBy", "semanticFields"]);
213
+ const fullOptions = Object.assign(Object.assign({ searchFields: this.convertSearchFields(searchFields), semanticFields: this.convertSemanticFields(semanticFields), select: this.convertSelect(select) || "*", orderBy: this.convertOrderBy(orderBy) }, nonFieldOptions), nextPageParameters);
152
214
  const { span, updatedOptions } = createSpan("SearchClient-searchDocuments", operationOptions);
153
215
  try {
154
- const result = await this.client.documents.searchPost(Object.assign(Object.assign({}, fullOptions), { includeTotalResultCount: fullOptions.includeTotalCount, searchText: searchText }), operationOptionsToRequestOptionsBase(updatedOptions));
155
- const { results, count, coverage, facets, nextLink } = result;
216
+ const result = await this.client.documents.searchPost(Object.assign(Object.assign({}, fullOptions), { includeTotalResultCount: fullOptions.includeTotalCount, searchText: searchText }), updatedOptions);
217
+ const { results, count, coverage, facets, answers, nextLink } = result;
156
218
  const modifiedResults = utils.generatedSearchResultToPublicSearchResult(results);
157
219
  const converted = {
158
220
  results: modifiedResults,
159
221
  count,
160
222
  coverage,
161
223
  facets,
162
- continuationToken: this.encodeContinuationToken(nextLink, result.nextPageParameters)
224
+ answers,
225
+ continuationToken: this.encodeContinuationToken(nextLink, result.nextPageParameters),
163
226
  };
164
227
  return deserialize(converted);
165
228
  }
166
229
  catch (e) {
167
230
  span.setStatus({
168
- code: SpanStatusCode.ERROR,
169
- message: e.message
231
+ status: "error",
232
+ error: e.message,
170
233
  });
171
234
  throw e;
172
235
  }
@@ -195,7 +258,7 @@ export class SearchClient {
195
258
  if (firstPage.continuationToken) {
196
259
  try {
197
260
  for (var _b = __asyncValues(this.listSearchResultsPage(searchText, options, {
198
- continuationToken: firstPage.continuationToken
261
+ continuationToken: firstPage.continuationToken,
199
262
  })), _c; _c = yield __await(_b.next()), !_c.done;) {
200
263
  const page = _c.value;
201
264
  yield __await(yield* __asyncDelegator(__asyncValues(page.results)));
@@ -222,7 +285,7 @@ export class SearchClient {
222
285
  },
223
286
  byPage: (settings = {}) => {
224
287
  return this.listSearchResultsPage(searchText, options, settings);
225
- }
288
+ },
226
289
  };
227
290
  }
228
291
  /**
@@ -230,23 +293,51 @@ export class SearchClient {
230
293
  * the specified arguments.
231
294
  * @param searchText - Text to search
232
295
  * @param options - Options for the search operation.
296
+ * @example
297
+ * ```ts
298
+ * import {
299
+ * AzureKeyCredential,
300
+ * SearchClient,
301
+ * SelectFields,
302
+ * } from "@azure/search-documents";
303
+ *
304
+ * type Model = {
305
+ * key: string;
306
+ * azure?: { sdk: string | null } | null;
307
+ * };
308
+ *
309
+ * const client = new SearchClient<Model>(
310
+ * "endpoint.azure",
311
+ * "indexName",
312
+ * new AzureKeyCredential("key")
313
+ * );
314
+ *
315
+ * const select = ["azure/sdk"] as const;
316
+ * const searchFields: SelectFields<Model>[] = ["azure/sdk"];
317
+ *
318
+ * const searchResult = await client.search("searchText", {
319
+ * select,
320
+ * searchFields,
321
+ * });
322
+ * ```
233
323
  */
234
- async search(searchText, options = {}) {
324
+ async search(searchText, options) {
235
325
  const { span, updatedOptions } = createSpan("SearchClient-search", options);
236
326
  try {
237
327
  const pageResult = await this.searchDocuments(searchText, updatedOptions);
238
- const { count, coverage, facets } = pageResult;
328
+ const { count, coverage, facets, answers } = pageResult;
239
329
  return {
240
330
  count,
241
331
  coverage,
242
332
  facets,
243
- results: this.listSearchResults(pageResult, searchText, updatedOptions)
333
+ answers,
334
+ results: this.listSearchResults(pageResult, searchText, updatedOptions),
244
335
  };
245
336
  }
246
337
  catch (e) {
247
338
  span.setStatus({
248
- code: SpanStatusCode.ERROR,
249
- message: e.message
339
+ status: "error",
340
+ error: e.message,
250
341
  });
251
342
  throw e;
252
343
  }
@@ -260,6 +351,33 @@ export class SearchClient {
260
351
  * @param searchText - The search text to use to suggest documents. Must be at least 1 character, and no more than 100 characters.
261
352
  * @param suggesterName - The name of the suggester as specified in the suggesters collection that's part of the index definition.
262
353
  * @param options - Options for the suggest operation
354
+ * @example
355
+ * ```ts
356
+ * import {
357
+ * AzureKeyCredential,
358
+ * SearchClient,
359
+ * SelectFields,
360
+ * } from "@azure/search-documents";
361
+ *
362
+ * type Model = {
363
+ * key: string;
364
+ * azure?: { sdk: string | null } | null;
365
+ * };
366
+ *
367
+ * const client = new SearchClient<Model>(
368
+ * "endpoint.azure",
369
+ * "indexName",
370
+ * new AzureKeyCredential("key")
371
+ * );
372
+ *
373
+ * const select = ["azure/sdk"] as const;
374
+ * const searchFields: SelectFields<Model>[] = ["azure/sdk"];
375
+ *
376
+ * const suggestResult = await client.suggest("searchText", "suggesterName", {
377
+ * select,
378
+ * searchFields,
379
+ * });
380
+ * ```
263
381
  */
264
382
  async suggest(searchText, suggesterName, options = {}) {
265
383
  const { operationOptions, restOptions } = this.extractOperationOptions(Object.assign({}, options));
@@ -273,14 +391,14 @@ export class SearchClient {
273
391
  }
274
392
  const { span, updatedOptions } = createSpan("SearchClient-suggest", operationOptions);
275
393
  try {
276
- const result = await this.client.documents.suggestPost(fullOptions, operationOptionsToRequestOptionsBase(updatedOptions));
394
+ const result = await this.client.documents.suggestPost(fullOptions, updatedOptions);
277
395
  const modifiedResult = utils.generatedSuggestDocumentsResultToPublicSuggestDocumentsResult(result);
278
396
  return deserialize(modifiedResult);
279
397
  }
280
398
  catch (e) {
281
399
  span.setStatus({
282
- code: SpanStatusCode.ERROR,
283
- message: e.message
400
+ status: "error",
401
+ error: e.message,
284
402
  });
285
403
  throw e;
286
404
  }
@@ -296,13 +414,13 @@ export class SearchClient {
296
414
  async getDocument(key, options = {}) {
297
415
  const { span, updatedOptions } = createSpan("SearchClient-getDocument", options);
298
416
  try {
299
- const result = await this.client.documents.get(key, operationOptionsToRequestOptionsBase(updatedOptions));
300
- return deserialize(result.body);
417
+ const result = await this.client.documents.get(key, Object.assign(Object.assign({}, updatedOptions), { selectedFields: updatedOptions.selectedFields }));
418
+ return deserialize(result);
301
419
  }
302
420
  catch (e) {
303
421
  span.setStatus({
304
- code: SpanStatusCode.ERROR,
305
- message: e.message
422
+ status: "error",
423
+ error: e.message,
306
424
  });
307
425
  throw e;
308
426
  }
@@ -325,16 +443,22 @@ export class SearchClient {
325
443
  batch, options = {}) {
326
444
  const { span, updatedOptions } = createSpan("SearchClient-indexDocuments", options);
327
445
  try {
328
- const result = await this.client.documents.index({ actions: serialize(batch.actions) }, operationOptionsToRequestOptionsBase(updatedOptions));
329
- if (options.throwOnAnyFailure && result._response.status === 207) {
446
+ let status = 0;
447
+ const result = await this.client.documents.index({ actions: serialize(batch.actions) }, Object.assign(Object.assign({}, updatedOptions), { onResponse: (rawResponse, flatResponse) => {
448
+ status = rawResponse.status;
449
+ if (updatedOptions.onResponse) {
450
+ updatedOptions.onResponse(rawResponse, flatResponse);
451
+ }
452
+ } }));
453
+ if (options.throwOnAnyFailure && status === 207) {
330
454
  throw result;
331
455
  }
332
456
  return result;
333
457
  }
334
458
  catch (e) {
335
459
  span.setStatus({
336
- code: SpanStatusCode.ERROR,
337
- message: e.message
460
+ status: "error",
461
+ error: e.message,
338
462
  });
339
463
  throw e;
340
464
  }
@@ -356,8 +480,8 @@ export class SearchClient {
356
480
  }
357
481
  catch (e) {
358
482
  span.setStatus({
359
- code: SpanStatusCode.ERROR,
360
- message: e.message
483
+ status: "error",
484
+ error: e.message,
361
485
  });
362
486
  throw e;
363
487
  }
@@ -380,8 +504,8 @@ export class SearchClient {
380
504
  }
381
505
  catch (e) {
382
506
  span.setStatus({
383
- code: SpanStatusCode.ERROR,
384
- message: e.message
507
+ status: "error",
508
+ error: e.message,
385
509
  });
386
510
  throw e;
387
511
  }
@@ -404,8 +528,8 @@ export class SearchClient {
404
528
  }
405
529
  catch (e) {
406
530
  span.setStatus({
407
- code: SpanStatusCode.ERROR,
408
- message: e.message
531
+ status: "error",
532
+ error: e.message,
409
533
  });
410
534
  throw e;
411
535
  }
@@ -427,8 +551,8 @@ export class SearchClient {
427
551
  }
428
552
  catch (e) {
429
553
  span.setStatus({
430
- code: SpanStatusCode.ERROR,
431
- message: e.message
554
+ status: "error",
555
+ error: e.message,
432
556
  });
433
557
  throw e;
434
558
  }
@@ -443,7 +567,7 @@ export class SearchClient {
443
567
  const payload = JSON.stringify({
444
568
  apiVersion: this.apiVersion,
445
569
  nextLink,
446
- nextPageParameters
570
+ nextPageParameters,
447
571
  });
448
572
  return encode(payload);
449
573
  }
@@ -459,7 +583,7 @@ export class SearchClient {
459
583
  }
460
584
  return {
461
585
  nextLink: result.nextLink,
462
- nextPageParameters: result.nextPageParameters
586
+ nextPageParameters: result.nextPageParameters,
463
587
  };
464
588
  }
465
589
  catch (e) {
@@ -473,9 +597,9 @@ export class SearchClient {
473
597
  operationOptions: {
474
598
  abortSignal,
475
599
  requestOptions,
476
- tracingOptions
600
+ tracingOptions,
477
601
  },
478
- restOptions
602
+ restOptions,
479
603
  };
480
604
  }
481
605
  convertSelect(select) {
@@ -490,6 +614,12 @@ export class SearchClient {
490
614
  }
491
615
  return searchFields;
492
616
  }
617
+ convertSemanticFields(semanticFields) {
618
+ if (semanticFields) {
619
+ return semanticFields.join(",");
620
+ }
621
+ return semanticFields;
622
+ }
493
623
  convertOrderBy(orderBy) {
494
624
  if (orderBy) {
495
625
  return orderBy.join(",");