-
Notifications
You must be signed in to change notification settings - Fork 77
/
index.d.ts
8803 lines (7976 loc) · 336 KB
/
index.d.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
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for elastic-builder
// Project: https://elastic-builder.js.org
// Definitions by: Suhas Karanth <sudo.suhas@gmail.com>
export = esb;
declare namespace esb {
/**
* The `RequestBodySearch` object provides methods generating an elasticsearch
* search request body. The search request can be executed with a search DSL,
* which includes the Query DSL, within its body.
*/
export class RequestBodySearch {
/**
* Define query on the search request body using the Query DSL.
*
* @param {Query} query
*/
query(query: Query): this;
/**
* Sets aggregation on the request body.
* Alias for method `aggregation`
*
* @param {Aggregation} agg Any valid `Aggregation`
* @throws {TypeError} If `agg` is not an instance of `Aggregation`
*/
agg(agg: Aggregation): this;
/**
* Sets aggregation on the request body.
*
* @param {Aggregation} agg Any valid `Aggregation`
* @throws {TypeError} If `agg` is not an instance of `Aggregation`
*/
aggregation(agg: Aggregation): this;
/**
* Sets multiple aggregation items on the request body.
* Alias for method `aggregations`
*
* @param {Array<Aggregation>} aggs Array of valid `Aggregation` items
* @throws {TypeError} If `aggs` is not an instance of `Array`
* @throws {TypeError} If `aggs` contains instances not of type `Aggregation`
*/
aggs(aggs: Aggregation[]): this;
/**
* Sets multiple aggregation items on the request body.
*
* @param {Array<Aggregation>} aggs Array of valid `Aggregation` items
* @throws {TypeError} If `aggs` is not an instance of `Array`
* @throws {TypeError} If `aggs` contains instances not of type `Aggregation`
*/
aggregations(aggs: Aggregation[]): this;
/**
* Sets suggester on the request body.
*
* @param {Suggester} suggest Any valid `Suggester`
* @throws {TypeError} If `suggest` is not an instance of `Suggester`
*/
suggest(suggest: Suggester): this;
/**
* Sets the global suggest text to avoid repetition for multiple suggestions.
*
* @param {string} txt Global suggest text
*/
suggestText(txt: string): this;
/**
* Sets a search timeout, bounding the search request to be executed within
* the specified time value and bail with the hits accumulated up to that
* point when expired.
*
* @param {string} timeout Duration can be specified using time units.
* Defaults to no timeout.
*/
timeout(timeout: string): this;
/**
* To retrieve hits from a certain offset.
*
* @param {number} from Defaults to 0.
*/
from(from: number): this;
/**
* The number of hits to return. If you do not care about getting some hits back
* but only about the number of matches and/or aggregations, setting the value
* to 0 will help performance.
*
* @param {number} size Defaults to 10.
*/
size(size: number): this;
/**
* The maximum number of documents to collect for each shard, upon reaching which
* the query execution will terminate early. If set, the response will have a
* boolean field `terminated_early` to indicate whether the query execution has
* actually terminated early.
*
* @param {number} numberOfDocs Maximum number of documents to collect for each shard.
* Defaults to no limit.
*/
terminateAfter(numberOfDocs: number): this;
/**
* Allows to add sort on specific field. The sort can be reversed as well.
* The sort is defined on a per field level, with special field name for `_score` to
* sort by score, and `_doc` to sort by index order.
*
* @param {Sort} sort
* @throws {TypeError} If parameter `sort` is not an instance of `Sort`.
*/
sort(sort: Sort): this;
/**
* Allows to add multiple sort on specific fields. Each sort can be reversed as well.
* The sort is defined on a per field level, with special field name for _score to
* sort by score, and _doc to sort by index order.
*
* @param {Array<Sort>} sorts Arry of sort
* @throws {TypeError} If any item in parameter `sorts` is not an instance of `Sort`.
*/
sorts(sorts: Sort[]): this;
/**
* When sorting on a field, scores are not computed. By setting `track_scores` to true,
* scores will still be computed and tracked.
*
* @param {boolean} enable
*/
trackScores(enable: boolean): this;
/**
* Allows to control how the `_source` field is returned with every hit.
* You can turn off `_source` retrieval by passing `false`.
* It also accepts one(string) or more wildcard(array) patterns to control
* what parts of the `_source` should be returned
* An object can also be used to specify the wildcard patterns for `includes` and `excludes`.
*
* @param {boolean|string|Array|Object} source
*/
source(source: boolean | string | string[] | object): this;
/**
* The `stored_fields` parameter is about fields that are explicitly marked as stored in the mapping.
* Selectively load specific stored fields for each document represented by a search hit
* using array of stored fields.
* An empty array will cause only the `_id` and `_type` for each hit to be returned.
* To disable the stored fields (and metadata fields) entirely use: `_none_`
*
* @param {Array|string} fields
*/
storedFields(fields: object | string): this;
/**
* Computes a document property dynamically based on the supplied `Script`.
*
* @param {string} scriptFieldName
* @param {string|Script} script string or instance of `Script`
*/
scriptField(scriptFieldName: string, script: string | Script): this;
/**
* Sets given dynamic document properties to be computed using supplied `Script`s.
* Object should have `scriptFieldName` as key and `script` as the value.
*
* @param {object} scriptFields Object with `scriptFieldName` as key and `script` as the value.
*/
scriptFields(scriptFields: object): this;
/**
* Allows to return the doc value representation of a field for each hit.
* Doc value fields can work on fields that are not stored.
*
* @param {Array<string>} fields
*/
docvalueFields(fields: string[]): this;
/**
* The `post_filter` is applied to the search hits at the very end of a search request,
* after aggregations have already been calculated.
*
* @param {Query} filterQuery The filter to be applied after aggregation.
*/
postFilter(filterQuery: Query): this;
/**
* Allows to highlight search results on one or more fields. The implementation
* uses either the lucene `plain` highlighter, the fast vector highlighter (`fvh`)
* or `postings` highlighter.
*
* Note: The `postings` highlighter has been removed in elasticsearch 6.0. The `unified`
* highlighter outputs the same highlighting when `index_options` is set to `offsets`.
*
* @param {Highlight} highlight
*/
highlight(highlight: Highlight): this;
/**
* Rescoring can help to improve precision by reordering just the top (eg 100 - 500)
* documents returned by the `query` and `post_filter` phases, using a secondary
* (usually more costly) algorithm, instead of applying the costly algorithm to
* all documents in the index.
*
* @param {Rescore} rescore
* @throws {TypeError} If `query` is not an instance of `Rescore`
*/
rescore(rescore: Rescore): this;
/**
* Enables explanation for each hit on how its score was computed.
*
* @param {boolean} enable
*/
explain(enable: boolean): this;
/**
* Returns a version for each search hit.
*
* @param {boolean} enable
*/
version(enable: boolean): this;
/**
* Allows to configure different boost level per index when searching across
* more than one indices. This is very handy when hits coming from one index
* matter more than hits coming from another index.
* Alias for method `indicesBoost`.
*
* @param {string} index Index windcard expression or alias
* @param {number} boost
*/
indexBoost(index: string, boost: number): this;
/**
* Allows to configure different boost level per index when searching across
* more than one indices. This is very handy when hits coming from one index
* matter more than hits coming from another index.
*
* @param {string} index Index windcard expression or alias
* @param {number} boost
*/
indicesBoost(index: string, boost: number): this;
/**
* Exclude documents which have a `_score` less than the minimum specified in `min_score`.
*
* @param {number} score
*/
minScore(score: number): this;
/**
* Allows to collapse search results based on field values. The collapsing
* is done by selecting only the top sorted document per collapse key.
* The field used for collapsing must be a single valued `keyword` or `numeric`
* field with `doc_values` activated
*
* @param {string} field
* @param {InnerHits=} innerHits Allows to expand each collapsed top hits.
* @param {number=} maxConcurrentGroupRequests The number of concurrent
* requests allowed to retrieve the inner_hits' per group
* @throws {TypeError} If `innerHits` is not an instance of `InnerHits`
*/
collapse(
field: string,
innerHits?: InnerHits,
maxConcurrentGroupRequests?: number
): this;
/**
* Allows to use the results from the previous page to help the retrieval
* of the next page. The `search_after` parameter provides a live cursor.
* The parameter `from` must be set to `0` (or `-1`) when `search_after` is used.
*
* @param {Array<*>} values The `sort values` of the last document to retrieve
* the next page of results
*/
searchAfter(values: any[]): this;
/**
* Override default `toJSON` to return DSL representation for the request body search
*
* @override
*/
toJSON(): object;
}
/**
* The `RequestBodySearch` object provides methods generating an elasticsearch
* search request body. The search request can be executed with a search DSL,
* which includes the Query DSL, within its body.
*/
export function requestBodySearch(): RequestBodySearch;
/**
* Base class implementation for all query types.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class should be extended and used, as validation against the class
* type is present in various places.
*
* @param {string} queryType
*/
class Query {
constructor(queryType: string);
/**
* Sets the boost value for documents matching the `Query`.
*
* @param {number} factor
*/
boost(factor: number): this;
/**
* Sets the query name.
*
* @param {string} name
*/
name(name: string): this;
/**
* Build and returns DSL representation of the `Query` class instance.
*
*/
getDSL(): object;
/**
* Override default `toJSON` to return DSL representation for the `query`
*
* @override
*/
toJSON(): object;
}
/**
* The most simple query, which matches all documents, giving them all a `_score` of `1.0`.
*
* @extends Query
*/
export class MatchAllQuery extends Query {
constructor();
}
/**
* The most simple query, which matches all documents, giving them all a `_score` of `1.0`.
*/
export function matchAllQuery(): MatchAllQuery;
/**
* The inverse of the `match_all` query, which matches no documents.
*
* @extends Query
*/
export class MatchNoneQuery extends Query {
constructor();
}
/**
* The inverse of the `match_all` query, which matches no documents.
*/
export function matchNoneQuery(): MatchNoneQuery;
/**
* The `FullTextQueryBase` provides support for common options used across
* various full text query implementations.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} queryType
* @param {string=} queryString The query string
* @extends Query
*/
class FullTextQueryBase extends Query {
constructor(queryType: string, queryString?: string);
/**
* Set the analyzer to control which analyzer will perform the analysis process on the text
*
* @param {string} analyzer
*/
analyzer(analyzer: string): this;
/**
* Sets the value controlling how many "should" clauses in the resulting boolean
* query should match. It can be an absolute value (2), a percentage (30%)
* or a combination of both. For Common Terms Query when specifying different
* `minimum_should_match` for low and high frequency terms, an object with the
* keys `low_freq` and `high_freq` can be used.
*
* @param {string|number|Object} minimumShouldMatch
* Note: Object notation can only be used with Common Terms Query.
*/
minimumShouldMatch(minimumShouldMatch: string | number | object): this;
/**
* Sets the query string.
*
* @param {string} queryString
*/
query(queryString: string): this;
}
/**
* The `MonoFieldQueryBase` provides support for common options used across
* various full text query implementations with single search field.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} queryType
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
* @extends FullTextQueryBase
*/
class MonoFieldQueryBase extends FullTextQueryBase {
constructor(queryType: string, field?: string, queryString?: string);
/**
* Sets the field to search on.
*
* @param {string} field
*/
field(field: string): this;
/**
* Override default `toJSON` to return DSL representation of the Full text query
* class instance.
*
* @override
*/
toJSON(): object;
}
/**
* `match` query accepts text/numerics/dates, analyzes them, and constructs a query.
*
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
* @extends MonoFieldQueryBase
*/
export class MatchQuery extends MonoFieldQueryBase {
constructor(field?: string, queryString?: string);
/**
* The operator to be used in the boolean query which is constructed
* by analyzing the text provided. The `operator` flag can be set to `or` or
* `and` to control the boolean clauses (defaults to `or`).
*
* @param {string} operator Can be `and`/`or`. Default is `or`.
*/
operator(operator: 'and' | 'or'): this;
/**
* Sets the `lenient` parameter which allows to ignore exceptions caused
* by data-type mismatches such as trying to query a numeric field with a
* text query string when set to `true`.
*
* @param {boolean} enable Defaules to `false`
*/
lenient(enable: boolean): this;
/**
* Sets the `fuzziness` parameter which is interpreted as a Levenshtein Edit Distance —
* the number of one character changes that need to be made to one string to make it
* the same as another string.
*
* @param {number|string} factor Can be specified either as a number, or the maximum
* number of edits, or as `AUTO` which generates an edit distance based on the length
* of the term.
*/
fuzziness(factor: number | string): this;
/**
* Sets the prefix length for a fuzzy prefix `MatchQuery`
*
* @param {number} len
*/
prefixLength(len: number): this;
/**
* Sets the max expansions for a fuzzy prefix `MatchQuery`
*
* @param {number} limit
*/
maxExpansions(limit: number): this;
/**
* Sets the rewrite method. Valid values are:
* - `constant_score` - tries to pick the best constant-score rewrite
* method based on term and document counts from the query.
* Synonyms - `constant_score_auto`, `constant_score_filter`
* - `scoring_boolean` - translates each term into boolean should and
* keeps the scores as computed by the query
* - `constant_score_boolean` - same as `scoring_boolean`, expect no scores
* are computed.
* - `constant_score_filter` - first creates a private Filter, by visiting
* each term in sequence and marking all docs for that term
* - `top_terms_boost_N` - first translates each term into boolean should
* and scores are only computed as the boost using the top N
* scoring terms. Replace N with an integer value.
* - `top_terms_N` - first translates each term into boolean should
* and keeps the scores as computed by the query. Only the top N
* scoring terms are used. Replace N with an integer value.
* Default is `constant_score`.
* This is an advanced option, use with care.
*
* Note: The deprecated multi term rewrite parameters `constant_score_auto`,
* `constant_score_filter` (synonyms for `constant_score`) have been removed in
* elasticsearch 6.0.
*
* @param {string} method The rewrite method as a string.
* @throws {Error} If the given `rewrite` method is not valid.
*/
rewrite(method: string): this;
/**
* Sets the fuzzy rewrite method. Valid values are:
* - `constant_score` - tries to pick the best constant-score rewrite
* method based on term and document counts from the query.
* Synonyms - `constant_score_auto`, `constant_score_filter`
* - `scoring_boolean` - translates each term into boolean should and
* keeps the scores as computed by the query
* - `constant_score_boolean` - same as `scoring_boolean`, expect no scores
* are computed.
* - `constant_score_filter` - first creates a private Filter, by visiting
* each term in sequence and marking all docs for that term
* - `top_terms_boost_N` - first translates each term into boolean should
* and scores are only computed as the boost using the top N
* scoring terms. Replace N with an integer value.
* - `top_terms_N` - first translates each term into boolean should
* and keeps the scores as computed by the query. Only the top N
* scoring terms are used. Replace N with an integer value.
* Default is `constant_score`.
* This is an advanced option, use with care.
*
* Note: The deprecated multi term rewrite parameters `constant_score_auto`,
* `constant_score_filter` (synonyms for `constant_score`) have been removed in
* elasticsearch 6.0.
*
* @param {string} method The rewrite method as a string.
* @throws {Error} If the given `fuzzy_rewrite` method is not valid.
*/
fuzzyRewrite(method: string): this;
/**
* Fuzzy transpositions (`ab` → `ba`) are allowed by default but can be disabled
* by setting `fuzzy_transpositions` to false.
*
* @param {boolean} enable
*/
fuzzyTranspositions(enable: boolean): this;
/**
* If the analyzer used removes all tokens in a query like a `stop` filter does,
* the default behavior is to match no documents at all. In order to change that
* the `zero_terms_query` option can be used, which accepts `none` (default) and `all`
* which corresponds to a `match_all` query.
*
* @param {string} behavior A no match action, `all` or `none`. Default is `none`.
*/
zeroTermsQuery(behavior: 'all' | 'none'): this;
/**
* Allows specifying an absolute or relative document frequency where high frequency
* terms are moved into an optional subquery and are only scored if one of the
* low frequency (below the cutoff) terms in the case of an `or` operator or
* all of the low frequency terms in the case of an `and` operator match.
*
* @param {number} frequency It can either be relative to the total number of documents
* if in the range `[0..1)` or absolute if greater or equal to `1.0`.
*/
cutoffFrequency(frequency: number): this;
}
/**
* `match` query accepts text/numerics/dates, analyzes them, and constructs a query.
*
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
*/
export function matchQuery(
field?: string,
queryString?: string
): MatchQuery;
/**
* The `MatchPhraseQueryBase` provides support for common options used across
* various bucket match phrase query implementations.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} queryType
* @param {string} refUrl
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
* @extends MonoFieldQueryBase
*/
class MatchPhraseQueryBase extends MonoFieldQueryBase {
constructor(
queryType: string,
refUrl: string,
field?: string,
queryString?: string
);
/**
* @override
* @throws {Error} This method cannot be called on `MatchPhraseQueryBase`
*/
minimumShouldMatch(): never;
/**
* Configures the `slop`(default is 0) for matching terms in any order.
* Transposed terms have a slop of 2.
* @param {number} slop A positive integer value, defaults is 0.
*/
slop(slop: number): this;
}
/**
* The `match_phrase` query analyzes the text and creates a `phrase` query out of
* the analyzed text.
*
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
* @extends MatchPhraseQueryBase
*/
export class MatchPhraseQuery extends MatchPhraseQueryBase {
constructor(field?: string, queryString?: string);
}
/**
* The `match_phrase` query analyzes the text and creates a `phrase` query out of
* the analyzed text.
*
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
*/
export function matchPhraseQuery(
field?: string,
queryString?: string
): MatchPhraseQuery;
/**
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
* @extends MatchPhraseQueryBase
*/
export class MatchPhrasePrefixQuery extends MatchPhraseQueryBase {
constructor(field?: string, queryString?: string);
/**
* Control to how many prefixes the last term will be expanded.
*
* @param {number} limit Defaults to 50.
*/
maxExpansions(limit: number): this;
}
/**
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
*/
export function matchPhrasePrefixQuery(
field?: string,
queryString?: string
): MatchPhrasePrefixQuery;
/**
* A `MultiMatchQuery` query builds further on top of the
* `MultiMatchQuery` by allowing multiple fields to be specified.
* The idea here is to allow to more easily build a concise match type query
* over multiple fields instead of using a relatively more expressive query
* by using multiple match queries within a bool query.
*
* @param {Array<string>|string=} fields The fields to be queried
* @param {string=} queryString The query string
* @extends FullTextQueryBase
*/
export class MultiMatchQuery extends FullTextQueryBase {
constructor(fields?: string[] | string, queryString?: string);
/**
* Appends given field to the list of fields to search against.
* Fields can be specified with wildcards.
* Individual fields can be boosted with the caret (^) notation.
* Example - `"subject^3"`
*
* @param {string} field One of the fields to be queried
*/
field(field: string): this;
/**
* Appends given fields to the list of fields to search against.
* Fields can be specified with wildcards.
* Individual fields can be boosted with the caret (^) notation.
*
* @param {Array<string>} fields The fields to be queried
*/
fields(fields: string[]): this;
/**
* Sets the type of multi match query. Valid values are:
* - `best_fields` - (default) Finds documents which match any field,
* but uses the `_score` from the best field.
* - `most_fields` - Finds documents which match any field and combines
* the `_score` from each field.
* - `cross_fields` - Treats fields with the same `analyzer` as though
* they were one big field. Looks for each word in *any* field
* - `phrase` - Runs a `match_phrase` query on each field and combines
* the `_score` from each field.
* - `phrase_prefix` - Runs a `match_phrase_prefix` query on each field
* and combines the `_score` from each field.
*
* @param {string} type Can be one of `best_fields`, `most_fields`,
* `cross_fields`, `phrase`, and `phrase_prefix`. Default is `best_fields`.
*/
type(
type:
| 'best_fields'
| 'most_fields'
| 'cross_fields'
| 'phrase'
| 'phrase_prefix'
): this;
/**
* The tie breaker value. The tie breaker capability allows results
* that include the same term in multiple fields to be judged better than
* results that include this term in only the best of those multiple
* fields, without confusing this with the better case of two different
* terms in the multiple fields. Default: `0.0`.
*
* @param {number} factor
*/
tieBreaker(factor: number): this;
/**
* The operator to be used in the boolean query which is constructed
* by analyzing the text provided. The `operator` flag can be set to `or` or
* `and` to control the boolean clauses (defaults to `or`).
*
* @param {string} operator Can be `and`/`or`. Default is `or`.
*/
operator(operator: 'and' | 'or'): this;
/**
* Sets the `lenient` parameter which allows to ignore exceptions caused
* by data-type mismatches such as trying to query a numeric field with a
* text query string when set to `true`.
*
* @param {boolean} enable Defaules to `false`
*/
lenient(enable: boolean): this;
/**
* Configures the `slop`(default is 0) for matching terms in any order.
* Transposed terms have a slop of 2.
*
* @param {number} slop A positive integer value, defaults is 0.
*/
slop(slop: number): this;
/**
* Sets the `fuzziness` parameter which is interpreted as a Levenshtein Edit Distance —
* the number of one character changes that need to be made to one string to make it
* the same as another string.
* The `fuzziness` parameter cannot be used with the `phrase`, `phrase_prefix`
* or `cross_fields` type.
*
* @param {number|string} factor Can be specified either as a number, or the maximum
* number of edits, or as `AUTO` which generates an edit distance based on the length
* of the term.
*/
fuzziness(factor: number | string): this;
/**
* Sets the prefix length for a fuzzy prefix `MultiMatchQuery`
*
* @param {number} len
*/
prefixLength(len: number): this;
/**
* Sets the max expansions for a fuzzy prefix `MultiMatchQuery`
*
* @param {number} limit
*/
maxExpansions(limit: number): this;
/**
* Sets the rewrite method. Valid values are:
* - `constant_score` - tries to pick the best constant-score rewrite
* method based on term and document counts from the query.
* Synonyms - `constant_score_auto`, `constant_score_filter`
* - `scoring_boolean` - translates each term into boolean should and
* keeps the scores as computed by the query
* - `constant_score_boolean` - same as `scoring_boolean`, expect no scores
* are computed.
* - `constant_score_filter` - first creates a private Filter, by visiting
* each term in sequence and marking all docs for that term
* - `top_terms_boost_N` - first translates each term into boolean should
* and scores are only computed as the boost using the top N
* scoring terms. Replace N with an integer value.
* - `top_terms_N` - first translates each term into boolean should
* and keeps the scores as computed by the query. Only the top N
* scoring terms are used. Replace N with an integer value.
*
* Default is `constant_score`.
* This is an advanced option, use with care.
*
* Note: The deprecated multi term rewrite parameters `constant_score_auto`,
* `constant_score_filter` (synonyms for `constant_score`) have been removed in
* elasticsearch 6.0.
*
* @param {string} method The rewrite method as a string.
* @throws {Error} If the given `rewrite` method is not valid.
*/
rewrite(method: string): this;
/**
* Sets the fuzzy rewrite method. Valid values are:
* - `constant_score` - tries to pick the best constant-score rewrite
* method based on term and document counts from the query.
* Synonyms - `constant_score_auto`, `constant_score_filter`
* - `scoring_boolean` - translates each term into boolean should and
* keeps the scores as computed by the query
* - `constant_score_boolean` - same as `scoring_boolean`, expect no scores
* are computed.
* - `constant_score_filter` - first creates a private Filter, by visiting
* each term in sequence and marking all docs for that term
* - `top_terms_boost_N` - first translates each term into boolean should
* and scores are only computed as the boost using the top N
* scoring terms. Replace N with an integer value.
* - `top_terms_N` - first translates each term into boolean should
* and keeps the scores as computed by the query. Only the top N
* scoring terms are used. Replace N with an integer value.
*
* Default is `constant_score`.
* This is an advanced option, use with care.
*
* Note: The deprecated multi term rewrite parameters `constant_score_auto`,
* `constant_score_filter` (synonyms for `constant_score`) have been removed in
* elasticsearch 6.0.
*
* @param {string} method The rewrite method as a string.
* @throws {Error} If the given `fuzzy_rewrite` method is not valid.
*/
fuzzyRewrite(method: string): this;
/**
* If the analyzer used removes all tokens in a query like a `stop` filter does,
* the default behavior is to match no documents at all. In order to change that
* the `zero_terms_query` option can be used, which accepts `none` (default) and `all`
* which corresponds to a `match_all` query.
*
* @param {string} behavior A no match action, `all` or `none`. Default is `none`.
*/
zeroTermsQuery(behavior: 'all' | 'none'): this;
/**
* Allows specifying an absolute or relative document frequency where high frequency
* terms are moved into an optional subquery and are only scored if one of the
* low frequency (below the cutoff) terms in the case of an `or` operator or
* all of the low frequency terms in the case of an `and` operator match.
*
* @param {number} frequency It can either be relative to the total number of documents
* if in the range `[0..1)` or absolute if greater or equal to `1.0`.
*/
cutoffFrequency(frequency: number): this;
}
/**
* A `MultiMatchQuery` query builds further on top of the
* `MultiMatchQuery` by allowing multiple fields to be specified.
* The idea here is to allow to more easily build a concise match type query
* over multiple fields instead of using a relatively more expressive query
* by using multiple match queries within a bool query.
*
* @param {Array<string>|string=} fields The fields to be queried
* @param {string=} queryString The query string
*/
export function multiMatchQuery(
fields?: string[] | string,
queryString?: string
): MultiMatchQuery;
/**
* The `common` terms query is a modern alternative to stopwords which
* improves the precision and recall of search results (by taking
* stopwords into account), without sacrificing performance.
*
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
* @extends MonoFieldQueryBase
*/
export class CommonTermsQuery extends MonoFieldQueryBase {
constructor(field?: string, queryString?: string);
/**
* Allows specifying an absolute or relative document frequency where high frequency
* terms are moved into an optional subquery and are only scored if one of the
* low frequency (below the cutoff) terms in the case of an `or` operator or
* all of the low frequency terms in the case of an `and` operator match.
*
* @param {number} frequency It can either be relative to the total number of documents
* if in the range `[0..1)` or absolute if greater or equal to `1.0`.
*/
cutoffFrequency(frequency: number): this;
/**
* The operator to be used on low frequency terms in the boolean query
* which is constructed by analyzing the text provided. The `operator` flag
* can be set to `or` or `and` to control the boolean clauses (defaults to `or`).
*
* @param {string} operator Can be `and`/`or`. Default is `or`.
*/
lowFreqOperator(operator: 'and' | 'or'): this;
/**
* The operator to be used on high frequency terms in the boolean query
* which is constructed by analyzing the text provided. The `operator` flag
* can be set to `or` or `and` to control the boolean clauses (defaults to `or`).
*
* @param {string} operator Can be `and`/`or`. Default is `or`.
*/
highFreqOperator(operator: 'and' | 'or'): this;
/**
* Sets the value controlling how many "should" clauses in the resulting boolean
* query should match for low frequency terms. It can be an absolute value (2),
* a percentage (30%) or a combination of both.
*
* @param {string|number} lowFreqMinMatch
*/
lowFreq(lowFreqMinMatch: string | number): this;
/**
* Sets the value controlling how many "should" clauses in the resulting boolean
* query should match for high frequency terms. It can be an absolute value (2),
* a percentage (30%) or a combination of both.
*
* @param {string|number} highFreqMinMatch
*/
highFreq(highFreqMinMatch: string | number): this;
/**
* Enables or disables similarity coordinate scoring of documents
* commoning the `CommonTermsQuery`. Default: `false`.
*
* NOTE: This has been removed in elasticsearch 6.0. If provided,
* it will be ignored and a deprecation warning will be issued.
*
* @param {boolean} enable
*/
disableCoord(enable: boolean): this;
}
/**
* The `common` terms query is a modern alternative to stopwords which
* improves the precision and recall of search results (by taking
* stopwords into account), without sacrificing performance.
*
* @param {string=} field The document field to query against
* @param {string=} queryString The query string
*/
export function commonTermsQuery(
field?: string,
queryString?: string
): CommonTermsQuery;
/**
* The `QueryStringQueryBase` provides support for common options used across
* full text query implementations `QueryStringQuery` and `SimpleQueryStringQuery`.
* A query that uses a query parser in order to parse its content.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} queryType
* @param {string} refUrl
* @param {string=} queryString The actual query to be parsed.
* @extends FullTextQueryBase
*/
class QueryStringQueryBase extends FullTextQueryBase {
constructor(queryType: string, refUrl: string, queryString?: string);
/**
* Appends given field to the list of fields to search against.