-
Notifications
You must be signed in to change notification settings - Fork 64
/
term.ts
285 lines (267 loc) · 7.68 KB
/
term.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
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import {
Field,
Fuzziness,
Id,
Ids,
IndexName,
MultiTermQueryRewrite,
Routing,
FieldValue
} from '@_types/common'
import { double, float, integer, long } from '@_types/Numeric'
import { Script } from '@_types/Scripting'
import { DateFormat, DateMath, TimeZone } from '@_types/Time'
import { QueryBase } from './abstractions'
import { AdditionalProperty } from '@spec_utils/behaviors'
export class ExistsQuery extends QueryBase {
/**
* Name of the field you wish to search.
*/
field: Field
}
/** @shortcut_property value */
export class FuzzyQuery extends QueryBase {
/**
* Maximum number of variations created.
* @server_default 50
*/
max_expansions?: integer
/**
* Number of beginning characters left unchanged when creating expansions.
* @server_default 0
*/
prefix_length?: integer
/**
* Number of beginning characters left unchanged when creating expansions.
* @doc_id query-dsl-multi-term-rewrite
* @server_default constant_score
*/
rewrite?: MultiTermQueryRewrite
/**
* Indicates whether edits include transpositions of two adjacent characters (for example `ab` to `ba`).
* @server_default true
*/
transpositions?: boolean
/**
* Maximum edit distance allowed for matching.
* @doc_id fuzziness
*/
fuzziness?: Fuzziness
/**
* Term you wish to find in the provided field.
*/
// ES is lenient and accepts any primitive type, but ultimately converts it to a string.
// Changing this field definition from UserDefinedValue to string breaks a recording produced from Nest tests,
// but Nest is probably also overly flexible here and exposes an option that should not exist.
value: string | double | boolean
}
export class IdsQuery extends QueryBase {
/**
* An array of document IDs.
*/
values?: Ids
}
/** @shortcut_property value */
export class PrefixQuery extends QueryBase {
/**
* Method used to rewrite the query.
* @doc_id query-dsl-multi-term-rewrite
*/
rewrite?: MultiTermQueryRewrite
/**
* Beginning characters of terms you wish to find in the provided field.
*/
value: string
/**
* Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`.
* Default is `false` which means the case sensitivity of matching depends on the underlying field’s mapping.
* @server_default false
* @availability stack since=7.10.0
* @availability serverless
*/
case_insensitive?: boolean
}
export class RangeQueryBase extends QueryBase {
/**
* Indicates how the range query matches values for `range` fields.
* @server_default intersects
*/
relation?: RangeRelation
}
export class DateRangeQuery extends RangeQueryBase {
/**
* Greater than.
*/
gt?: DateMath
/**
* Greater than or equal to.
*/
gte?: DateMath
/**
* Less than.
*/
lt?: DateMath
/**
* Less than or equal to.
*/
lte?: DateMath
from?: DateMath | null
to?: DateMath | null
/**
* Date format used to convert `date` values in the query.
*/
format?: DateFormat
/**
* Coordinated Universal Time (UTC) offset or IANA time zone used to convert `date` values in the query to UTC.
*/
time_zone?: TimeZone
}
export class NumberRangeQuery extends RangeQueryBase {
/**
* Greater than.
*/
gt?: double
/**
* Greater than or equal to.
*/
gte?: double
/**
* Less than.
*/
lt?: double
/**
* Less than or equal to.
*/
lte?: double
from?: double | null
to?: double | null
}
/** @codegen_names date, number */
// Note: deserialization depends on value types
export type RangeQuery = DateRangeQuery | NumberRangeQuery
export enum RangeRelation {
/**
* Matches documents with a range field value entirely within the query’s range.
*/
within = 0,
/**
* Matches documents with a range field value that entirely contains the query’s range.
*/
contains = 1,
/**
* Matches documents with a range field value that intersects the query’s range.
*/
intersects = 2
}
/** @shortcut_property value */
export class RegexpQuery extends QueryBase {
/**
* Allows case insensitive matching of the regular expression value with the indexed field values when set to `true`.
* When `false`, case sensitivity of matching depends on the underlying field’s mapping.
* @server_default false
* @availability stack since=7.10.0
* @availability serverless
*/
case_insensitive?: boolean
/**
* Enables optional operators for the regular expression.
* @doc_id regexp-syntax
*/
flags?: string
/**
* Maximum number of automaton states required for the query.
* @server_default 10000
*/
max_determinized_states?: integer
/**
* Method used to rewrite the query.
* @doc_id query-dsl-multi-term-rewrite
*/
rewrite?: MultiTermQueryRewrite
/**
* Regular expression for terms you wish to find in the provided field.
* @doc_id regexp-syntax
*/
value: string
}
/** @shortcut_property value */
export class TermQuery extends QueryBase {
/**
* Term you wish to find in the provided field.
*/
value: FieldValue
/**
* Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`.
* When `false`, the case sensitivity of matching depends on the underlying field’s mapping.
* @availability stack since=7.10.0
* @availability serverless
* @server_default false
*/
case_insensitive?: boolean
}
export class TermsQuery
extends QueryBase
implements AdditionalProperty<Field, TermsQueryField> {}
/**
* @codegen_names value, lookup
*/
export type TermsQueryField = FieldValue[] | TermsLookup
export class TermsLookup {
index: IndexName
id: Id
path: Field
routing?: Routing
}
export class TermsSetQuery extends QueryBase {
/**
* Numeric field containing the number of matching terms required to return a document.
*/
minimum_should_match_field?: Field
/**
* Custom script containing the number of matching terms required to return a document.
*/
minimum_should_match_script?: Script
/**
* Array of terms you wish to find in the provided field.
*/
terms: string[]
}
export class TypeQuery extends QueryBase {
value: string
}
/** @shortcut_property value */
export class WildcardQuery extends QueryBase {
/**
* Allows case insensitive matching of the pattern with the indexed field values when set to true. Default is false which means the case sensitivity of matching depends on the underlying field’s mapping.
* @availability stack since=7.10.0
* @availability serverless
*/
case_insensitive?: boolean
/**
* Method used to rewrite the query.
* @doc_id query-dsl-multi-term-rewrite
*/
rewrite?: MultiTermQueryRewrite
/** Wildcard pattern for terms you wish to find in the provided field. Required, when wildcard is not set. */
value?: string
/** Wildcard pattern for terms you wish to find in the provided field. Required, when value is not set. */
wildcard?: string
}