-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
indexModels.ts
679 lines (653 loc) · 25.4 KB
/
indexModels.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { OperationOptions } from "@azure/core-http";
import {
QueryType,
SearchMode,
FacetResult,
AutocompleteMode,
IndexActionType,
ScoringStatistics,
QueryLanguage,
Speller,
Answers,
CaptionResult,
AnswerResult,
Captions
} from "./generated/data/models";
import { PagedAsyncIterableIterator } from "@azure/core-paging";
/**
* Options for performing the count operation on the index.
*/
export type CountDocumentsOptions = OperationOptions;
/**
* Options for retrieving completion text for a partial searchText.
*/
export type AutocompleteOptions<Fields> = OperationOptions & AutocompleteRequest<Fields>;
/**
* Options for committing a full search request.
*/
export type SearchOptions<Fields> = OperationOptions & SearchRequestOptions<Fields>;
/**
* Options for retrieving suggestions based on the searchText.
*/
export type SuggestOptions<Fields> = OperationOptions & SuggestRequest<Fields>;
/**
* Options for SearchIndexingBufferedSender.
*/
export interface SearchIndexingBufferedSenderOptions {
/**
* Indicates if autoFlush is enabled.
*/
autoFlush?: boolean;
/**
* Initial Batch Action Count.
*
* A batch request will be sent once the documents
* reach the initialBatchActionCount.
*/
initialBatchActionCount?: number;
/**
* Flush Window.
*
* A batch request will be sent after flushWindowInMs is
* reached.
*/
flushWindowInMs?: number;
/**
* Maximum number of Retries
*/
maxRetriesPerAction?: number;
/**
* Delay between retries
*/
throttlingDelayInMs?: number;
/**
* Max Delay between retries
*/
maxThrottlingDelayInMs?: number;
}
/**
* Options for SearchIndexingBufferedSenderUploadDocuments.
*/
export type SearchIndexingBufferedSenderUploadDocumentsOptions = OperationOptions;
/**
* Options for SearchIndexingBufferedSenderMergeDocuments.
*/
export type SearchIndexingBufferedSenderMergeDocumentsOptions = OperationOptions;
/**
* Options for SearchIndexingBufferedSenderMergeOrUploadDocuments.
*/
export type SearchIndexingBufferedSenderMergeOrUploadDocumentsOptions = OperationOptions;
/**
* Options for SearchIndexingBufferedSenderDeleteDocuments.
*/
export type SearchIndexingBufferedSenderDeleteDocumentsOptions = OperationOptions;
/**
* Options for SearchIndexingBufferedSenderFlushDocuments.
*/
export type SearchIndexingBufferedSenderFlushDocumentsOptions = OperationOptions;
/**
* Options for retrieving a single document.
*/
export interface GetDocumentOptions<Fields> extends OperationOptions {
/**
* List of field names to retrieve for the document; Any field not retrieved will be missing from
* the returned document.
*/
selectedFields?: Fields[];
}
/**
* Options for the modify index batch operation.
*/
export interface IndexDocumentsOptions extends OperationOptions {
/**
* If true, will cause this operation to throw if any document operation
* in the batch did not succeed.
*/
throwOnAnyFailure?: boolean;
}
/**
* Options for the upload documents operation.
*/
export type UploadDocumentsOptions = IndexDocumentsOptions;
/**
* Options for the merge documents operation.
*/
export type MergeDocumentsOptions = IndexDocumentsOptions;
/**
* Options for the merge or upload documents operation.
*/
export type MergeOrUploadDocumentsOptions = IndexDocumentsOptions;
/**
* Options for the delete documents operation.
*/
export type DeleteDocumentsOptions = IndexDocumentsOptions;
/**
* Arguments for retrieving the next page of search results.
*/
export interface ListSearchResultsPageSettings {
/**
* A token used for retrieving the next page of results when the server
* enforces pagination.
*/
continuationToken?: string;
}
/**
* An iterator for search results of a paticular query. Will make requests
* as needed during iteration. Use .byPage() to make one request to the server
* per iteration.
*/
export type SearchIterator<Fields> = PagedAsyncIterableIterator<
SearchResult<Fields>,
SearchDocumentsPageResult<Fields>,
ListSearchResultsPageSettings
>;
// BEGIN manually modified generated interfaces
//
// This section is for places where we have to manually fix issues
// with interfaces from the generated code.
// Mostly this is to allow modeling additionalProperties:true as generics.
/**
* Parameters for filtering, sorting, faceting, paging, and other search query behaviors.
*/
export interface SearchRequest {
/**
* A value that specifies whether to fetch the total count of results. Default is false. Setting
* this value to true may have a performance impact. Note that the count returned is an
* approximation.
*/
includeTotalCount?: boolean;
/**
* The list of facet expressions to apply to the search query. Each facet expression contains a
* field name, optionally followed by a comma-separated list of name:value pairs.
*/
facets?: string[];
/**
* The OData $filter expression to apply to the search query.
*/
filter?: string;
/**
* The comma-separated list of field names to use for hit highlights. Only searchable fields can
* be used for hit highlighting.
*/
highlightFields?: string;
/**
* A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is
* </em>.
*/
highlightPostTag?: string;
/**
* A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default
* is <em>.
*/
highlightPreTag?: string;
/**
* A number between 0 and 100 indicating the percentage of the index that must be covered by a
* search query in order for the query to be reported as a success. This parameter can be useful
* for ensuring search availability even for services with only one replica. The default is 100.
*/
minimumCoverage?: number;
/**
* The comma-separated list of OData $orderby expressions by which to sort the results. Each
* expression can be either a field name or a call to either the geo.distance() or the
* search.score() functions. Each expression can be followed by asc to indicate ascending, or
* desc to indicate descending. The default is ascending order. Ties will be broken by the match
* scores of documents. If no $orderby is specified, the default sort order is descending by
* document match score. There can be at most 32 $orderby clauses.
*/
orderBy?: string;
/**
* A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if
* your query uses the Lucene query syntax. Possible values include: 'Simple', 'Full'
*/
queryType?: QueryType;
/**
* A value that specifies whether we want to calculate scoring statistics (such as document
* frequency) globally for more consistent scoring, or locally, for lower latency. The default is
* 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global
* scoring statistics can increase latency of search queries. Possible values include: 'Local',
* 'Global'
*/
scoringStatistics?: ScoringStatistics;
/**
* A value to be used to create a sticky session, which can help getting more consistent results.
* As long as the same sessionId is used, a best-effort attempt will be made to target the same
* replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the
* load balancing of the requests across replicas and adversely affect the performance of the
* search service. The value used as sessionId cannot start with a '_' character.
*/
sessionId?: string;
/**
* The list of parameter values to be used in scoring functions (for example,
* referencePointParameter) using the format name-values. For example, if the scoring profile
* defines a function with a parameter called 'mylocation' the parameter string would be
* "mylocation--122.2,44.8" (without the quotes).
*/
scoringParameters?: string[];
/**
* The name of a scoring profile to evaluate match scores for matching documents in order to sort
* the results.
*/
scoringProfile?: string;
/**
* A full-text search query expression; Use "*" or omit this parameter to match all documents.
*/
searchText?: string;
/**
* The comma-separated list of field names to which to scope the full-text search. When using
* fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each
* fielded search expression take precedence over any field names listed in this parameter.
*/
searchFields?: string;
/**
* A value that specifies whether any or all of the search terms must be matched in order to
* count the document as a match. Possible values include: 'Any', 'All'
*/
searchMode?: SearchMode;
/**
* A value that specifies the language of the search query.
*/
queryLanguage?: QueryLanguage;
/**
* A value that specified the type of the speller to use to spell-correct individual search
* query terms.
*/
speller?: Speller;
/**
* A value that specifies whether answers should be returned as part of the search response.
*/
answers?: Answers;
/**
* The comma-separated list of fields to retrieve. If unspecified, all fields marked as
* retrievable in the schema are included.
*/
select?: string;
/**
* The number of search results to skip. This value cannot be greater than 100,000. If you need
* to scan documents in sequence, but cannot use skip due to this limitation, consider using
* orderby on a totally-ordered key and filter with a range query instead.
*/
skip?: number;
/**
* The number of search results to retrieve. This can be used in conjunction with $skip to
* implement client-side paging of search results. If results are truncated due to server-side
* paging, the response will include a continuation token that can be used to issue another
* Search request for the next page of results.
*/
top?: number;
/**
* A value that specifies whether captions should be returned as part of the search response.
*/
captions?: Captions;
/**
* The comma-separated list of field names used for semantic search.
*/
semanticFields?: string;
}
/**
* Parameters for filtering, sorting, faceting, paging, and other search query behaviors.
*/
export interface SearchRequestOptions<Fields> {
/**
* A value that specifies whether to fetch the total count of results. Default is false. Setting
* this value to true may have a performance impact. Note that the count returned is an
* approximation.
*/
includeTotalCount?: boolean;
/**
* The list of facet expressions to apply to the search query. Each facet expression contains a
* field name, optionally followed by a comma-separated list of name:value pairs.
*/
facets?: string[];
/**
* The OData $filter expression to apply to the search query.
*/
filter?: string;
/**
* The comma-separated list of field names to use for hit highlights. Only searchable fields can
* be used for hit highlighting.
*/
highlightFields?: string;
/**
* A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is
* </em>.
*/
highlightPostTag?: string;
/**
* A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default
* is <em>.
*/
highlightPreTag?: string;
/**
* A number between 0 and 100 indicating the percentage of the index that must be covered by a
* search query in order for the query to be reported as a success. This parameter can be useful
* for ensuring search availability even for services with only one replica. The default is 100.
*/
minimumCoverage?: number;
/**
* The list of OData $orderby expressions by which to sort the results. Each
* expression can be either a field name or a call to either the geo.distance() or the
* search.score() functions. Each expression can be followed by asc to indicate ascending, or
* desc to indicate descending. The default is ascending order. Ties will be broken by the match
* scores of documents. If no $orderby is specified, the default sort order is descending by
* document match score. There can be at most 32 $orderby clauses.
*/
orderBy?: string[];
/**
* A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if
* your query uses the Lucene query syntax. Possible values include: 'simple', 'full'
*/
queryType?: QueryType;
/**
* The list of parameter values to be used in scoring functions (for example,
* referencePointParameter) using the format name-values. For example, if the scoring profile
* defines a function with a parameter called 'mylocation' the parameter string would be
* "mylocation--122.2,44.8" (without the quotes).
*/
scoringParameters?: string[];
/**
* The name of a scoring profile to evaluate match scores for matching documents in order to sort
* the results.
*/
scoringProfile?: string;
/**
* The comma-separated list of field names to which to scope the full-text search. When using
* fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each
* fielded search expression take precedence over any field names listed in this parameter.
*/
searchFields?: Fields[];
/**
* The language of the query.
*/
queryLanguage?: QueryLanguage;
/**
* Improve search recall by spell-correcting individual search query terms.
*/
speller?: Speller;
/**
* This parameter is only valid if the query type is 'semantic'. If set, the query returns answers
* extracted from key passages in the highest ranked documents. The number of answers returned can
* be configured by appending the pipe character '|' followed by the 'count-\<number of answers\>' option
* after the answers parameter value, such as 'extractive|count-3'. Default count is 1.
*/
answers?: Answers;
/**
* A value that specifies whether any or all of the search terms must be matched in order to
* count the document as a match. Possible values include: 'any', 'all'
*/
searchMode?: SearchMode;
/**
* A value that specifies whether we want to calculate scoring statistics (such as document
* frequency) globally for more consistent scoring, or locally, for lower latency. Possible
* values include: 'Local', 'Global'
*/
scoringStatistics?: ScoringStatistics;
/**
* A value to be used to create a sticky session, which can help to get more consistent results.
* As long as the same sessionId is used, a best-effort attempt will be made to target the same
* replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the
* load balancing of the requests across replicas and adversely affect the performance of the
* search service. The value used as sessionId cannot start with a '_' character.
*/
sessionId?: string;
/**
* The list of fields to retrieve. If unspecified, all fields marked as
* retrievable in the schema are included.
*/
select?: Fields[];
/**
* The number of search results to skip. This value cannot be greater than 100,000. If you need
* to scan documents in sequence, but cannot use skip due to this limitation, consider using
* orderby on a totally-ordered key and filter with a range query instead.
*/
skip?: number;
/**
* The number of search results to retrieve. This can be used in conjunction with $skip to
* implement client-side paging of search results. If results are truncated due to server-side
* paging, the response will include a continuation token that can be used to issue another
* Search request for the next page of results.
*/
top?: number;
/**
* This parameter is only valid if the query type is 'semantic'. If set, the query returns captions
* extracted from key passages in the highest ranked documents. When Captions is set to 'extractive',
* highlighting is enabled by default, and can be configured by appending the pipe character '|'
* followed by the 'highlight-true'/'highlight-false' option, such as 'extractive|highlight-true'. Defaults to 'None'.
*/
captions?: Captions;
/**
* The list of field names used for semantic search.
*/
semanticFields?: string[];
}
/**
* Contains a document found by a search query, plus associated metadata.
*/
export type SearchResult<T> = {
/**
* The relevance score of the document compared to other documents returned by the query.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly score: number;
/**
* The relevance score computed by the semantic ranker for the top search results. Search results are sorted by the RerankerScore first and then by the Score. RerankerScore is only returned for queries of type 'semantic'.
* NOTE: This property will not be serialized. It can only be populated by the server.
*/
readonly rerankerScore?: number;
/**
* Text fragments from the document that indicate the matching search terms, organized by each
* applicable field; null if hit highlighting was not enabled for the query.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly highlights?: { [k in keyof T]?: string[] };
/**
* Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.
* NOTE: This property will not be serialized. It can only be populated by the server.
*/
readonly captions?: CaptionResult[];
document: T;
};
/**
* Response containing search results from an index.
*/
export interface SearchDocumentsResultBase {
/**
* The total count of results found by the search operation, or null if the count was not
* requested. If present, the count may be greater than the number of results in this response.
* This can happen if you use the $top or $skip parameters, or if Azure Cognitive Search can't
* return all the requested documents in a single Search response.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly count?: number;
/**
* A value indicating the percentage of the index that was included in the query, or null if
* minimumCoverage was not specified in the request.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly coverage?: number;
/**
* The facet query results for the search operation, organized as a collection of buckets for
* each faceted field; null if the query did not include any facet expressions.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly facets?: { [propertyName: string]: FacetResult[] };
/**
* The answers query results for the search operation; null if the answers query parameter was
* not specified or set to 'none'.
* NOTE: This property will not be serialized. It can only be populated by the server.
*/
readonly answers?: AnswerResult[];
}
/**
* Response containing search results from an index.
*/
export interface SearchDocumentsResult<T> extends SearchDocumentsResultBase {
/**
* The sequence of results returned by the query.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly results: SearchIterator<T>;
}
/**
* Response containing search page results from an index.
*/
export interface SearchDocumentsPageResult<T> extends SearchDocumentsResultBase {
/**
* The sequence of results returned by the query.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly results: SearchResult<T>[];
/**
* A token used for retrieving the next page of results when the server
* enforces pagination.
*/
continuationToken?: string;
}
/**
* Parameters for filtering, sorting, fuzzy matching, and other suggestions query behaviors.
*/
export interface SuggestRequest<Fields> {
/**
* An OData expression that filters the documents considered for suggestions.
*/
filter?: string;
/**
* A value indicating whether to use fuzzy matching for the suggestion query. Default is false.
* When set to true, the query will find suggestions even if there's a substituted or missing
* character in the search text. While this provides a better experience in some scenarios, it
* comes at a performance cost as fuzzy suggestion searches are slower and consume more
* resources.
*/
useFuzzyMatching?: boolean;
/**
* A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted,
* hit highlighting of suggestions is disabled.
*/
highlightPostTag?: string;
/**
* A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If
* omitted, hit highlighting of suggestions is disabled.
*/
highlightPreTag?: string;
/**
* A number between 0 and 100 indicating the percentage of the index that must be covered by a
* suggestion query in order for the query to be reported as a success. This parameter can be
* useful for ensuring search availability even for services with only one replica. The default
* is 80.
*/
minimumCoverage?: number;
/**
* The list of OData $orderby expressions by which to sort the results. Each
* expression can be either a field name or a call to either the geo.distance() or the
* search.score() functions. Each expression can be followed by asc to indicate ascending, or
* desc to indicate descending. The default is ascending order. Ties will be broken by the match
* scores of documents. If no $orderby is specified, the default sort order is descending by
* document match score. There can be at most 32 $orderby clauses.
*/
orderBy?: string[];
/**
* The comma-separated list of field names to search for the specified search text. Target fields
* must be included in the specified suggester.
*/
searchFields?: Fields[];
/**
* The list of fields to retrieve. If unspecified, only the key field will be
* included in the results.
*/
select?: Fields[];
/**
* The number of suggestions to retrieve. This must be a value between 1 and 100. The default is
* 5.
*/
top?: number;
}
/**
* A result containing a document found by a suggestion query, plus associated metadata.
*/
export type SuggestResult<T> = {
/**
* The text of the suggestion result.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly text: string;
document: T;
};
/**
* Response containing suggestion query results from an index.
*/
export interface SuggestDocumentsResult<T> {
/**
* The sequence of results returned by the query.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly results: SuggestResult<T>[];
/**
* A value indicating the percentage of the index that was included in the query, or null if
* minimumCoverage was not set in the request.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
readonly coverage?: number;
}
/**
* Parameters for fuzzy matching, and other autocomplete query behaviors.
*/
export interface AutocompleteRequest<Fields> {
/**
* Specifies the mode for Autocomplete. The default is 'oneTerm'. Use 'twoTerms' to get shingles
* and 'oneTermWithContext' to use the current context while producing auto-completed terms.
* Possible values include: 'oneTerm', 'twoTerms', 'oneTermWithContext'
*/
autocompleteMode?: AutocompleteMode;
/**
* An OData expression that filters the documents used to produce completed terms for the
* Autocomplete result.
*/
filter?: string;
/**
* A value indicating whether to use fuzzy matching for the autocomplete query. Default is false.
* When set to true, the query will autocomplete terms even if there's a substituted or missing
* character in the search text. While this provides a better experience in some scenarios, it
* comes at a performance cost as fuzzy autocomplete queries are slower and consume more
* resources.
*/
useFuzzyMatching?: boolean;
/**
* A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted,
* hit highlighting is disabled.
*/
highlightPostTag?: string;
/**
* A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If
* omitted, hit highlighting is disabled.
*/
highlightPreTag?: string;
/**
* A number between 0 and 100 indicating the percentage of the index that must be covered by an
* autocomplete query in order for the query to be reported as a success. This parameter can be
* useful for ensuring search availability even for services with only one replica. The default
* is 80.
*/
minimumCoverage?: number;
/**
* The comma-separated list of field names to consider when querying for auto-completed terms.
* Target fields must be included in the specified suggester.
*/
searchFields?: Fields[];
/**
* The number of auto-completed terms to retrieve. This must be a value between 1 and 100. The
* default is 5.
*/
top?: number;
}
/**
* Represents an index action that operates on a document.
*/
export type IndexDocumentsAction<T> = {
/**
* The operation to perform on a document in an indexing batch. Possible values include:
* 'upload', 'merge', 'mergeOrUpload', 'delete'
*/
__actionType: IndexActionType;
} & Partial<T>;
// END manually modified generated interfaces