elasticsearch9 9.2.1__py3-none-any.whl → 9.3.0__py3-none-any.whl
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.
- elasticsearch9/_async/client/__init__.py +44 -40
- elasticsearch9/_async/client/async_search.py +4 -3
- elasticsearch9/_async/client/cat.py +163 -8
- elasticsearch9/_async/client/cluster.py +66 -34
- elasticsearch9/_async/client/eql.py +7 -6
- elasticsearch9/_async/client/esql.py +157 -8
- elasticsearch9/_async/client/fleet.py +1 -1
- elasticsearch9/_async/client/graph.py +1 -1
- elasticsearch9/_async/client/indices.py +436 -17
- elasticsearch9/_async/client/inference.py +299 -9
- elasticsearch9/_async/client/ml.py +7 -3
- elasticsearch9/_async/client/nodes.py +167 -5
- elasticsearch9/_async/client/project.py +9 -1
- elasticsearch9/_async/client/security.py +26 -3
- elasticsearch9/_async/client/snapshot.py +1 -1
- elasticsearch9/_async/client/sql.py +7 -6
- elasticsearch9/_async/client/streams.py +0 -1
- elasticsearch9/_async/client/text_structure.py +3 -3
- elasticsearch9/_sync/client/__init__.py +44 -40
- elasticsearch9/_sync/client/async_search.py +4 -3
- elasticsearch9/_sync/client/cat.py +163 -8
- elasticsearch9/_sync/client/cluster.py +66 -34
- elasticsearch9/_sync/client/eql.py +7 -6
- elasticsearch9/_sync/client/esql.py +157 -8
- elasticsearch9/_sync/client/fleet.py +1 -1
- elasticsearch9/_sync/client/graph.py +1 -1
- elasticsearch9/_sync/client/indices.py +436 -17
- elasticsearch9/_sync/client/inference.py +299 -9
- elasticsearch9/_sync/client/ml.py +7 -3
- elasticsearch9/_sync/client/nodes.py +167 -5
- elasticsearch9/_sync/client/project.py +9 -1
- elasticsearch9/_sync/client/project_routing.py +264 -0
- elasticsearch9/_sync/client/security.py +26 -3
- elasticsearch9/_sync/client/snapshot.py +1 -1
- elasticsearch9/_sync/client/sql.py +7 -6
- elasticsearch9/_sync/client/streams.py +0 -1
- elasticsearch9/_sync/client/text_structure.py +3 -3
- elasticsearch9/_version.py +2 -2
- elasticsearch9/dsl/__init__.py +4 -0
- elasticsearch9/dsl/aggs.py +6 -6
- elasticsearch9/dsl/field.py +91 -7
- elasticsearch9/dsl/query.py +2 -2
- elasticsearch9/dsl/response/__init__.py +2 -0
- elasticsearch9/dsl/types.py +66 -7
- elasticsearch9/dsl/utils.py +11 -2
- elasticsearch9/esql/functions.py +924 -250
- elasticsearch9/helpers/__init__.py +2 -0
- elasticsearch9/helpers/actions.py +21 -0
- elasticsearch9/helpers/vectorstore/_async/vectorstore.py +3 -0
- elasticsearch9/helpers/vectorstore/_sync/vectorstore.py +3 -0
- {elasticsearch9-9.2.1.dist-info → elasticsearch9-9.3.0.dist-info}/METADATA +2 -1
- {elasticsearch9-9.2.1.dist-info → elasticsearch9-9.3.0.dist-info}/RECORD +55 -54
- {elasticsearch9-9.2.1.dist-info → elasticsearch9-9.3.0.dist-info}/WHEEL +0 -0
- {elasticsearch9-9.2.1.dist-info → elasticsearch9-9.3.0.dist-info}/licenses/LICENSE +0 -0
- {elasticsearch9-9.2.1.dist-info → elasticsearch9-9.3.0.dist-info}/licenses/NOTICE +0 -0
elasticsearch9/esql/functions.py
CHANGED
|
@@ -39,17 +39,28 @@ def abs(number: ExpressionType) -> InstrumentedExpression:
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def absent(field: ExpressionType) -> InstrumentedExpression:
|
|
42
|
-
"""Returns true if the input expression yields no non-null values within
|
|
43
|
-
current aggregation context.
|
|
42
|
+
"""Returns true if the input expression yields no non-null values within
|
|
43
|
+
the current aggregation context. Otherwise it returns false.
|
|
44
44
|
|
|
45
45
|
:param field: Expression that outputs values to be checked for absence.
|
|
46
46
|
"""
|
|
47
47
|
return InstrumentedExpression(f"ABSENT({_render(field)})")
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def absent_over_time(
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
def absent_over_time(
|
|
51
|
+
field: ExpressionType, window: ExpressionType = None
|
|
52
|
+
) -> InstrumentedExpression:
|
|
53
|
+
"""Calculates the absence of a field in the output result over time range.
|
|
54
|
+
|
|
55
|
+
:param field: the metric field to calculate the value for
|
|
56
|
+
:param window: the time window over which to compute the absent over time
|
|
57
|
+
"""
|
|
58
|
+
if window is not None:
|
|
59
|
+
return InstrumentedExpression(
|
|
60
|
+
f"ABSENT_OVER_TIME({_render(field)}, {_render(window)})"
|
|
61
|
+
)
|
|
62
|
+
else:
|
|
63
|
+
return InstrumentedExpression(f"ABSENT_OVER_TIME({_render(field)})")
|
|
53
64
|
|
|
54
65
|
|
|
55
66
|
def acos(number: ExpressionType) -> InstrumentedExpression:
|
|
@@ -60,6 +71,24 @@ def acos(number: ExpressionType) -> InstrumentedExpression:
|
|
|
60
71
|
return InstrumentedExpression(f"ACOS({_render(number)})")
|
|
61
72
|
|
|
62
73
|
|
|
74
|
+
def all_first(value: ExpressionType, sort: ExpressionType) -> InstrumentedExpression:
|
|
75
|
+
"""Calculates the earliest value of a field, and can operate on null values.
|
|
76
|
+
|
|
77
|
+
:param value: Values to return
|
|
78
|
+
:param sort: Sort key
|
|
79
|
+
"""
|
|
80
|
+
return InstrumentedExpression(f"ALL_FIRST({_render(value)}, {_render(sort)})")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def all_last(value: ExpressionType, sort: ExpressionType) -> InstrumentedExpression:
|
|
84
|
+
"""Calculates the latest value of a field, and can operate on null values.
|
|
85
|
+
|
|
86
|
+
:param value: Values to return
|
|
87
|
+
:param sort: Sort key
|
|
88
|
+
"""
|
|
89
|
+
return InstrumentedExpression(f"ALL_LAST({_render(value)}, {_render(sort)})")
|
|
90
|
+
|
|
91
|
+
|
|
63
92
|
def asin(number: ExpressionType) -> InstrumentedExpression:
|
|
64
93
|
"""Returns the arcsine of the input numeric expression as an angle,
|
|
65
94
|
expressed in radians.
|
|
@@ -100,12 +129,20 @@ def avg(number: ExpressionType) -> InstrumentedExpression:
|
|
|
100
129
|
return InstrumentedExpression(f"AVG({_render(number)})")
|
|
101
130
|
|
|
102
131
|
|
|
103
|
-
def avg_over_time(
|
|
104
|
-
|
|
132
|
+
def avg_over_time(
|
|
133
|
+
field: ExpressionType, window: ExpressionType = None
|
|
134
|
+
) -> InstrumentedExpression:
|
|
135
|
+
"""Calculates the average over time of a numeric field.
|
|
105
136
|
|
|
106
|
-
:param
|
|
137
|
+
:param field: the metric field to calculate the value for
|
|
138
|
+
:param window: the time window over which to compute the average
|
|
107
139
|
"""
|
|
108
|
-
|
|
140
|
+
if window is not None:
|
|
141
|
+
return InstrumentedExpression(
|
|
142
|
+
f"AVG_OVER_TIME({_render(field)}, {_render(window)})"
|
|
143
|
+
)
|
|
144
|
+
else:
|
|
145
|
+
return InstrumentedExpression(f"AVG_OVER_TIME({_render(field)})")
|
|
109
146
|
|
|
110
147
|
|
|
111
148
|
def bit_length(string: ExpressionType) -> InstrumentedExpression:
|
|
@@ -129,9 +166,10 @@ def bucket(
|
|
|
129
166
|
:param field: Numeric or date expression from which to derive buckets.
|
|
130
167
|
:param buckets: Target number of buckets, or desired bucket size if `from`
|
|
131
168
|
and `to` parameters are omitted.
|
|
132
|
-
:param from_: Start of the range. Can be a number, a date or a date
|
|
133
|
-
as a string.
|
|
134
|
-
:param to: End of the range. Can be a number, a date or a date expressed as
|
|
169
|
+
:param from_: Start of the range. Can be a number, a date or a date
|
|
170
|
+
expressed as a string.
|
|
171
|
+
:param to: End of the range. Can be a number, a date or a date expressed as
|
|
172
|
+
a string.
|
|
135
173
|
"""
|
|
136
174
|
return InstrumentedExpression(
|
|
137
175
|
f"BUCKET({_render(field)}, {_render(buckets)}, {_render(from_)}, {_render(to)})"
|
|
@@ -152,18 +190,28 @@ def case(*conditions: ExpressionType) -> InstrumentedExpression:
|
|
|
152
190
|
number of arguments is odd, the last argument is the default value which is
|
|
153
191
|
returned when no condition matches. If the number of arguments is even, and
|
|
154
192
|
no condition matches, the function returns `null`.
|
|
193
|
+
|
|
194
|
+
:param conditions: The conditions.
|
|
155
195
|
"""
|
|
156
196
|
return InstrumentedExpression(
|
|
157
197
|
f'CASE({", ".join([_render(c) for c in conditions])})'
|
|
158
198
|
)
|
|
159
199
|
|
|
160
200
|
|
|
161
|
-
def categorize(
|
|
201
|
+
def categorize(
|
|
202
|
+
field: ExpressionType, options: ExpressionType = None
|
|
203
|
+
) -> InstrumentedExpression:
|
|
162
204
|
"""Groups text messages into categories of similarly formatted text values.
|
|
163
205
|
|
|
164
206
|
:param field: Expression to categorize
|
|
207
|
+
:param options: (Optional) Categorize additional options as function named parameters.
|
|
165
208
|
"""
|
|
166
|
-
|
|
209
|
+
if options is not None:
|
|
210
|
+
return InstrumentedExpression(
|
|
211
|
+
f"CATEGORIZE({_render(field)}, {_render(options)})"
|
|
212
|
+
)
|
|
213
|
+
else:
|
|
214
|
+
return InstrumentedExpression(f"CATEGORIZE({_render(field)})")
|
|
167
215
|
|
|
168
216
|
|
|
169
217
|
def cbrt(number: ExpressionType) -> InstrumentedExpression:
|
|
@@ -183,6 +231,40 @@ def ceil(number: ExpressionType) -> InstrumentedExpression:
|
|
|
183
231
|
return InstrumentedExpression(f"CEIL({_render(number)})")
|
|
184
232
|
|
|
185
233
|
|
|
234
|
+
def chicken(
|
|
235
|
+
text: ExpressionType, style: ExpressionType = None, width: ExpressionType = None
|
|
236
|
+
) -> InstrumentedExpression:
|
|
237
|
+
if style is not None and width is not None:
|
|
238
|
+
return InstrumentedExpression(
|
|
239
|
+
f"CHICKEN({_render(text)}, {_render(style)}, {_render(width)})"
|
|
240
|
+
)
|
|
241
|
+
elif style is not None and width is None:
|
|
242
|
+
return InstrumentedExpression(f"CHICKEN({_render(text)}, {_render(style)})")
|
|
243
|
+
elif style is None and width is not None:
|
|
244
|
+
return InstrumentedExpression(
|
|
245
|
+
f"CHICKEN({_render(text)}, {_render('ordinary')}, {_render(width)})"
|
|
246
|
+
)
|
|
247
|
+
else:
|
|
248
|
+
return InstrumentedExpression(f"CHICKEN({_render(text)})")
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def chunk(
|
|
252
|
+
field: ExpressionType, chunking_settings: ExpressionType = None
|
|
253
|
+
) -> InstrumentedExpression:
|
|
254
|
+
"""Use `CHUNK` to split a text field into smaller chunks.
|
|
255
|
+
|
|
256
|
+
:param field: The input to chunk.
|
|
257
|
+
:param chunking_settings: Options to customize chunking behavior. Defaults
|
|
258
|
+
to {"strategy":"sentence","max_chunk_size":300,"sentence_overlap":0}.
|
|
259
|
+
"""
|
|
260
|
+
if chunking_settings is not None:
|
|
261
|
+
return InstrumentedExpression(
|
|
262
|
+
f"CHUNK({_render(field)}, {_render(chunking_settings)})"
|
|
263
|
+
)
|
|
264
|
+
else:
|
|
265
|
+
return InstrumentedExpression(f"CHUNK({_render(field)})")
|
|
266
|
+
|
|
267
|
+
|
|
186
268
|
def cidr_match(ip: ExpressionType, block_x: ExpressionType) -> InstrumentedExpression:
|
|
187
269
|
"""Returns true if the provided IP is contained in one of the provided CIDR blocks.
|
|
188
270
|
|
|
@@ -192,6 +274,41 @@ def cidr_match(ip: ExpressionType, block_x: ExpressionType) -> InstrumentedExpre
|
|
|
192
274
|
return InstrumentedExpression(f"CIDR_MATCH({_render(ip)}, {_render(block_x)})")
|
|
193
275
|
|
|
194
276
|
|
|
277
|
+
def clamp(
|
|
278
|
+
field: ExpressionType, min: ExpressionType, max: ExpressionType
|
|
279
|
+
) -> InstrumentedExpression:
|
|
280
|
+
"""Limits (or clamps) the values of all samples to have a lower limit of
|
|
281
|
+
min and an upper limit of max.
|
|
282
|
+
|
|
283
|
+
:param field: Numeric expression. If `null`, the function returns `null`.
|
|
284
|
+
:param min: The min value to clamp data into.
|
|
285
|
+
:param max: The max value to clamp data into.
|
|
286
|
+
"""
|
|
287
|
+
return InstrumentedExpression(
|
|
288
|
+
f"CLAMP({_render(field)}, {_render(min)}, {_render(max)})"
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def clamp_max(field: ExpressionType, max: ExpressionType) -> InstrumentedExpression:
|
|
293
|
+
"""Limits (or clamps) all input sample values to an upper bound of max. Any
|
|
294
|
+
value above max is reduced to max.
|
|
295
|
+
|
|
296
|
+
:param field: field to clamp.
|
|
297
|
+
:param max: The max value to clamp data into.
|
|
298
|
+
"""
|
|
299
|
+
return InstrumentedExpression(f"CLAMP_MAX({_render(field)}, {_render(max)})")
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def clamp_min(field: ExpressionType, min: ExpressionType) -> InstrumentedExpression:
|
|
303
|
+
"""Limits (or clamps) all input sample values to a lower bound of min. Any
|
|
304
|
+
value below min is set to min.
|
|
305
|
+
|
|
306
|
+
:param field: field to clamp.
|
|
307
|
+
:param min: The min value to clamp data into.
|
|
308
|
+
"""
|
|
309
|
+
return InstrumentedExpression(f"CLAMP_MIN({_render(field)}, {_render(min)})")
|
|
310
|
+
|
|
311
|
+
|
|
195
312
|
def coalesce(first: ExpressionType, rest: ExpressionType) -> InstrumentedExpression:
|
|
196
313
|
"""Returns the first of its arguments that is not null. If all arguments
|
|
197
314
|
are null, it returns `null`.
|
|
@@ -203,12 +320,45 @@ def coalesce(first: ExpressionType, rest: ExpressionType) -> InstrumentedExpress
|
|
|
203
320
|
|
|
204
321
|
|
|
205
322
|
def concat(*strings: ExpressionType) -> InstrumentedExpression:
|
|
206
|
-
"""Concatenates two or more strings.
|
|
323
|
+
"""Concatenates two or more strings.
|
|
324
|
+
|
|
325
|
+
:param strings: strings to concatenate.
|
|
326
|
+
"""
|
|
207
327
|
return InstrumentedExpression(
|
|
208
328
|
f'CONCAT({", ".join([f"{_render(s)}" for s in strings])})'
|
|
209
329
|
)
|
|
210
330
|
|
|
211
331
|
|
|
332
|
+
def contains(
|
|
333
|
+
string: ExpressionType, substring: ExpressionType
|
|
334
|
+
) -> InstrumentedExpression:
|
|
335
|
+
"""Returns a boolean that indicates whether a keyword substring is within
|
|
336
|
+
another string. Returns `null` if either parameter is null.
|
|
337
|
+
|
|
338
|
+
:param string: String expression: input string to check against. If
|
|
339
|
+
`null`, the function returns `null`.
|
|
340
|
+
:param substring: String expression: A substring to find in the input
|
|
341
|
+
string. If `null`, the function returns `null`.
|
|
342
|
+
"""
|
|
343
|
+
return InstrumentedExpression(f"CONTAINS({_render(string)}, {_render(substring)})")
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def copy_sign(
|
|
347
|
+
magnitude: ExpressionType, sign: ExpressionType
|
|
348
|
+
) -> InstrumentedExpression:
|
|
349
|
+
"""Returns a value with the magnitude of the first argument and the sign of
|
|
350
|
+
the second argument. This function is similar to Java's
|
|
351
|
+
Math.copySign(double magnitude, double sign) which is similar to `copysign`
|
|
352
|
+
from IEEE 754.
|
|
353
|
+
|
|
354
|
+
:param magnitude: The expression providing the magnitude of the result.
|
|
355
|
+
Must be a numeric type.
|
|
356
|
+
:param sign: The expression providing the sign of the result. Must be a
|
|
357
|
+
numeric type.
|
|
358
|
+
"""
|
|
359
|
+
return InstrumentedExpression(f"COPY_SIGN({_render(magnitude)}, {_render(sign)})")
|
|
360
|
+
|
|
361
|
+
|
|
212
362
|
def cos(angle: ExpressionType) -> InstrumentedExpression:
|
|
213
363
|
"""Returns the cosine of an angle.
|
|
214
364
|
|
|
@@ -240,9 +390,11 @@ def count_distinct(
|
|
|
240
390
|
"""Returns the approximate number of distinct values.
|
|
241
391
|
|
|
242
392
|
:param field: Column or literal for which to count the number of distinct values.
|
|
243
|
-
:param precision: Precision threshold.
|
|
244
|
-
|
|
245
|
-
|
|
393
|
+
:param precision: Precision threshold. Refer to
|
|
394
|
+
`AGG-COUNT-DISTINCT-APPROXIMATE`. The maximum supported
|
|
395
|
+
value is 40000. Thresholds above this number will have
|
|
396
|
+
the same effect as a threshold of 40000. The default
|
|
397
|
+
value is 3000.
|
|
246
398
|
"""
|
|
247
399
|
return InstrumentedExpression(
|
|
248
400
|
f"COUNT_DISTINCT({_render(field)}, {_render(precision)})"
|
|
@@ -252,24 +404,34 @@ def count_distinct(
|
|
|
252
404
|
def count_distinct_over_time(
|
|
253
405
|
field: ExpressionType, precision: ExpressionType
|
|
254
406
|
) -> InstrumentedExpression:
|
|
255
|
-
"""
|
|
407
|
+
"""Calculates the count of distinct values over time for a field.
|
|
256
408
|
|
|
257
|
-
:param field:
|
|
258
|
-
:param precision: Precision threshold.
|
|
259
|
-
|
|
260
|
-
|
|
409
|
+
:param field: the metric field to calculate the value for
|
|
410
|
+
:param precision: Precision threshold. Refer to
|
|
411
|
+
`AGG-COUNT-DISTINCT-APPROXIMATE`. The maximum supported
|
|
412
|
+
value is 40000. Thresholds above this number will have
|
|
413
|
+
the same effect as a threshold of 40000. The default
|
|
414
|
+
value is 3000.
|
|
261
415
|
"""
|
|
262
416
|
return InstrumentedExpression(
|
|
263
417
|
f"COUNT_DISTINCT_OVER_TIME({_render(field)}, {_render(precision)})"
|
|
264
418
|
)
|
|
265
419
|
|
|
266
420
|
|
|
267
|
-
def count_over_time(
|
|
268
|
-
|
|
421
|
+
def count_over_time(
|
|
422
|
+
field: ExpressionType, window: ExpressionType = None
|
|
423
|
+
) -> InstrumentedExpression:
|
|
424
|
+
"""Calculates the count over time value of a field.
|
|
269
425
|
|
|
270
|
-
:param field:
|
|
426
|
+
:param field: the metric field to calculate the value for
|
|
427
|
+
:param window: the time window over which to compute the count over time
|
|
271
428
|
"""
|
|
272
|
-
|
|
429
|
+
if window is not None:
|
|
430
|
+
return InstrumentedExpression(
|
|
431
|
+
f"COUNT_OVER_TIME({_render(field)}, {_render(window)})"
|
|
432
|
+
)
|
|
433
|
+
else:
|
|
434
|
+
return InstrumentedExpression(f"COUNT_OVER_TIME({_render(field)})")
|
|
273
435
|
|
|
274
436
|
|
|
275
437
|
def date_diff(
|
|
@@ -294,15 +456,20 @@ def date_extract(
|
|
|
294
456
|
"""Extracts parts of a date, like year, month, day, hour.
|
|
295
457
|
|
|
296
458
|
:param date_part: Part of the date to extract. Can be:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
459
|
+
`aligned_day_of_week_in_month`,
|
|
460
|
+
`aligned_day_of_week_in_year`, `aligned_week_of_month`,
|
|
461
|
+
`aligned_week_of_year`, `ampm_of_day`,
|
|
462
|
+
`clock_hour_of_ampm`, `clock_hour_of_day`,
|
|
463
|
+
`day_of_month`, `day_of_week`, `day_of_year`,
|
|
464
|
+
`epoch_day`, `era`, `hour_of_ampm`, `hour_of_day`,
|
|
465
|
+
`instant_seconds`, `micro_of_day`, `micro_of_second`,
|
|
466
|
+
`milli_of_day`, `milli_of_second`, `minute_of_day`,
|
|
467
|
+
`minute_of_hour`, `month_of_year`, `nano_of_day`,
|
|
468
|
+
`nano_of_second`, `offset_seconds`, `proleptic_month`,
|
|
469
|
+
`second_of_day`, `second_of_minute`, `year`, or
|
|
470
|
+
`year_of_era`. Refer to java.time.temporal.ChronoField
|
|
471
|
+
for a description of these values. If `null`, the
|
|
472
|
+
function returns `null`.
|
|
306
473
|
:param date: Date expression. If `null`, the function returns `null`.
|
|
307
474
|
"""
|
|
308
475
|
return InstrumentedExpression(
|
|
@@ -316,10 +483,10 @@ def date_format(
|
|
|
316
483
|
) -> InstrumentedExpression:
|
|
317
484
|
"""Returns a string representation of a date, in the provided format.
|
|
318
485
|
|
|
319
|
-
:param date_format: Date format (optional). If no format is specified, the
|
|
320
|
-
`yyyy-MM-dd'T'HH:mm:ss.SSSZ` format is used. If `null`, the
|
|
321
|
-
function returns `null`.
|
|
322
486
|
:param date: Date expression. If `null`, the function returns `null`.
|
|
487
|
+
:param date_format: Date format (optional). If no format is specified,
|
|
488
|
+
the `yyyy-MM-dd'T'HH:mm:ss.SSSZ` format is used. If
|
|
489
|
+
`null`, the function returns `null`.
|
|
323
490
|
"""
|
|
324
491
|
if date_format is not None:
|
|
325
492
|
return InstrumentedExpression(
|
|
@@ -330,18 +497,29 @@ def date_format(
|
|
|
330
497
|
|
|
331
498
|
|
|
332
499
|
def date_parse(
|
|
333
|
-
date_pattern: ExpressionType,
|
|
500
|
+
date_pattern: ExpressionType,
|
|
501
|
+
date_string: ExpressionType,
|
|
502
|
+
options: ExpressionType = None,
|
|
334
503
|
) -> InstrumentedExpression:
|
|
335
504
|
"""Returns a date by parsing the second argument using the format specified
|
|
336
505
|
in the first argument.
|
|
337
506
|
|
|
338
|
-
:param date_pattern: The date format.
|
|
507
|
+
:param date_pattern: The date format. Refer to the `DateTimeFormatter`
|
|
508
|
+
documentation for the syntax. If `null`, the function
|
|
509
|
+
returns `null`.
|
|
339
510
|
:param date_string: Date expression as a string. If `null` or an empty
|
|
340
511
|
string, the function returns `null`.
|
|
512
|
+
:param options: (Optional) Additional options for date parsing, specifying
|
|
513
|
+
time zone and locale as function named parameters.
|
|
341
514
|
"""
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
515
|
+
if options is not None:
|
|
516
|
+
return InstrumentedExpression(
|
|
517
|
+
f"DATE_PARSE({_render(date_pattern)}, {_render(date_string)}, {_render(options)})"
|
|
518
|
+
)
|
|
519
|
+
else:
|
|
520
|
+
return InstrumentedExpression(
|
|
521
|
+
f"DATE_PARSE({_render(date_pattern)}, {_render(date_string)})"
|
|
522
|
+
)
|
|
345
523
|
|
|
346
524
|
|
|
347
525
|
def date_trunc(
|
|
@@ -355,6 +533,52 @@ def date_trunc(
|
|
|
355
533
|
return InstrumentedExpression(f"DATE_TRUNC({_render(interval)}, {_render(date)})")
|
|
356
534
|
|
|
357
535
|
|
|
536
|
+
def day_name(date: ExpressionType) -> InstrumentedExpression:
|
|
537
|
+
"""Returns the name of the weekday for date based on the configured Locale.
|
|
538
|
+
|
|
539
|
+
:param date: Date expression. If `null`, the function returns `null`.
|
|
540
|
+
"""
|
|
541
|
+
return InstrumentedExpression(f"DAY_NAME({_render(date)})")
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def decay(
|
|
545
|
+
value: ExpressionType,
|
|
546
|
+
origin: ExpressionType,
|
|
547
|
+
scale: ExpressionType,
|
|
548
|
+
options: ExpressionType,
|
|
549
|
+
) -> InstrumentedExpression:
|
|
550
|
+
"""Calculates a relevance score that decays based on the distance of a
|
|
551
|
+
numeric, spatial or date type value from a target origin, using
|
|
552
|
+
configurable decay functions.
|
|
553
|
+
|
|
554
|
+
:param value: The input value to apply decay scoring to.
|
|
555
|
+
:param origin: Central point from which the distances are calculated.
|
|
556
|
+
:param scale: Distance from the origin where the function returns the decay value.
|
|
557
|
+
:param options:
|
|
558
|
+
"""
|
|
559
|
+
return InstrumentedExpression(
|
|
560
|
+
f"DECAY({_render(value)}, {_render(origin)}, {_render(scale)}, {_render(options)})"
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def delta(field: ExpressionType, window: ExpressionType) -> InstrumentedExpression:
|
|
565
|
+
"""Calculates the absolute change of a gauge field in a time window.
|
|
566
|
+
|
|
567
|
+
:param field: the metric field to calculate the value for
|
|
568
|
+
:param window: the time window over which to compute the delta over time
|
|
569
|
+
"""
|
|
570
|
+
return InstrumentedExpression(f"DELTA({_render(field)}, {_render(window)})")
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
def deriv(field: ExpressionType, window: ExpressionType) -> InstrumentedExpression:
|
|
574
|
+
"""Calculates the derivative over time of a numeric field using linear regression.
|
|
575
|
+
|
|
576
|
+
:param field: the metric field to calculate the value for
|
|
577
|
+
:param window: the time window over which to compute the derivative over time
|
|
578
|
+
"""
|
|
579
|
+
return InstrumentedExpression(f"DERIV({_render(field)}, {_render(window)})")
|
|
580
|
+
|
|
581
|
+
|
|
358
582
|
def e() -> InstrumentedExpression:
|
|
359
583
|
"""Returns Euler’s number)."""
|
|
360
584
|
return InstrumentedExpression("E()")
|
|
@@ -379,17 +603,29 @@ def exp(number: ExpressionType) -> InstrumentedExpression:
|
|
|
379
603
|
|
|
380
604
|
|
|
381
605
|
def first(value: ExpressionType, sort: ExpressionType) -> InstrumentedExpression:
|
|
382
|
-
"""Calculates the earliest value of a field.
|
|
606
|
+
"""Calculates the earliest value of a field.
|
|
607
|
+
|
|
608
|
+
:param value: Values to return
|
|
609
|
+
:param sort: Sort key
|
|
610
|
+
"""
|
|
383
611
|
return InstrumentedExpression(f"FIRST({_render(value)}, {_render(sort)})")
|
|
384
612
|
|
|
385
613
|
|
|
386
|
-
def first_over_time(
|
|
387
|
-
|
|
388
|
-
|
|
614
|
+
def first_over_time(
|
|
615
|
+
field: ExpressionType, window: ExpressionType = None
|
|
616
|
+
) -> InstrumentedExpression:
|
|
617
|
+
"""Calculates the earliest value of a field, where recency determined by
|
|
618
|
+
the `@timestamp` field.
|
|
389
619
|
|
|
390
|
-
:param field:
|
|
620
|
+
:param field: the metric field to calculate the value for
|
|
621
|
+
:param window: the time window over which to compute the first over time value
|
|
391
622
|
"""
|
|
392
|
-
|
|
623
|
+
if window is not None:
|
|
624
|
+
return InstrumentedExpression(
|
|
625
|
+
f"FIRST_OVER_TIME({_render(field)}, {_render(window)})"
|
|
626
|
+
)
|
|
627
|
+
else:
|
|
628
|
+
return InstrumentedExpression(f"FIRST_OVER_TIME({_render(field)})")
|
|
393
629
|
|
|
394
630
|
|
|
395
631
|
def floor(number: ExpressionType) -> InstrumentedExpression:
|
|
@@ -438,6 +674,27 @@ def hypot(number1: ExpressionType, number2: ExpressionType) -> InstrumentedExpre
|
|
|
438
674
|
return InstrumentedExpression(f"HYPOT({number1}, {number2})")
|
|
439
675
|
|
|
440
676
|
|
|
677
|
+
def idelta(field: ExpressionType, window: ExpressionType) -> InstrumentedExpression:
|
|
678
|
+
"""Calculates the idelta of a gauge. idelta is the absolute change between
|
|
679
|
+
the last two data points (it ignores all but the last two data points in
|
|
680
|
+
each time period). This function is very similar to delta, but is more
|
|
681
|
+
responsive to recent changes.
|
|
682
|
+
|
|
683
|
+
:param field: the metric field to calculate the value for
|
|
684
|
+
:param window: the time window over which to compute the idelta over time
|
|
685
|
+
"""
|
|
686
|
+
return InstrumentedExpression(f"IDELTA({_render(field)}, {_render(window)})")
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
def increase(field: ExpressionType, window: ExpressionType) -> InstrumentedExpression:
|
|
690
|
+
"""Calculates the absolute increase of a counter field in a time window.
|
|
691
|
+
|
|
692
|
+
:param field: the metric field to calculate the value for
|
|
693
|
+
:param window: the time window over which to compute the increase over time
|
|
694
|
+
"""
|
|
695
|
+
return InstrumentedExpression(f"INCREASE({_render(field)}, {_render(window)})")
|
|
696
|
+
|
|
697
|
+
|
|
441
698
|
def ip_prefix(
|
|
442
699
|
ip: ExpressionType,
|
|
443
700
|
prefix_length_v4: ExpressionType,
|
|
@@ -454,16 +711,31 @@ def ip_prefix(
|
|
|
454
711
|
)
|
|
455
712
|
|
|
456
713
|
|
|
714
|
+
def irate(field: ExpressionType, window: ExpressionType) -> InstrumentedExpression:
|
|
715
|
+
"""Calculates the irate of a counter field. irate is the per-second rate of
|
|
716
|
+
increase between the last two data points (it ignores all but the last two
|
|
717
|
+
data points in each time period). This function is very similar to rate,
|
|
718
|
+
but is more responsive to recent changes in the rate of increase.
|
|
719
|
+
|
|
720
|
+
:param field: the metric field to calculate the value for
|
|
721
|
+
:param window: the time window over which to compute the irate
|
|
722
|
+
"""
|
|
723
|
+
return InstrumentedExpression(f"IRATE({_render(field)}, {_render(window)})")
|
|
724
|
+
|
|
725
|
+
|
|
457
726
|
def knn(
|
|
458
727
|
field: ExpressionType, query: ExpressionType, options: ExpressionType = None
|
|
459
728
|
) -> InstrumentedExpression:
|
|
460
729
|
"""Finds the k nearest vectors to a query vector, as measured by a
|
|
461
730
|
similarity metric. knn function finds nearest vectors through approximate
|
|
462
|
-
search on indexed dense_vectors.
|
|
731
|
+
search on indexed dense_vectors or semantic_text fields.
|
|
463
732
|
|
|
464
|
-
:param field: Field that the query will target.
|
|
733
|
+
:param field: Field that the query will target. knn function can be used
|
|
734
|
+
with dense_vector or semantic_text fields. Other text fields
|
|
735
|
+
are not allowed
|
|
465
736
|
:param query: Vector value to find top nearest neighbours for.
|
|
466
|
-
:param options: (Optional) kNN additional options as function named
|
|
737
|
+
:param options: (Optional) kNN additional options as function named
|
|
738
|
+
parameters. See knn query for more information.
|
|
467
739
|
"""
|
|
468
740
|
if options is not None:
|
|
469
741
|
return InstrumentedExpression(
|
|
@@ -473,27 +745,46 @@ def knn(
|
|
|
473
745
|
return InstrumentedExpression(f"KNN({_render(field)}, {_render(query)})")
|
|
474
746
|
|
|
475
747
|
|
|
476
|
-
def kql(
|
|
748
|
+
def kql(
|
|
749
|
+
query: ExpressionType, options: ExpressionType = None
|
|
750
|
+
) -> InstrumentedExpression:
|
|
477
751
|
"""Performs a KQL query. Returns true if the provided KQL query string
|
|
478
752
|
matches the row.
|
|
479
753
|
|
|
480
754
|
:param query: Query string in KQL query string format.
|
|
755
|
+
:param options: (Optional) KQL additional options as function named
|
|
756
|
+
parameters. Available in stack version 9.3.0 and later.
|
|
481
757
|
"""
|
|
482
|
-
|
|
758
|
+
if options is not None:
|
|
759
|
+
return InstrumentedExpression(f"KQL({_render(query)}, {_render(options)})")
|
|
760
|
+
else:
|
|
761
|
+
return InstrumentedExpression(f"KQL({_render(query)})")
|
|
483
762
|
|
|
484
763
|
|
|
485
764
|
def last(value: ExpressionType, sort: ExpressionType) -> InstrumentedExpression:
|
|
486
|
-
"""Calculates the latest value of a field.
|
|
765
|
+
"""Calculates the latest value of a field.
|
|
766
|
+
|
|
767
|
+
:param value: Values to return
|
|
768
|
+
:param sort: Sort key
|
|
769
|
+
"""
|
|
487
770
|
return InstrumentedExpression(f"LAST({_render(value)}, {_render(sort)})")
|
|
488
771
|
|
|
489
772
|
|
|
490
|
-
def last_over_time(
|
|
491
|
-
|
|
773
|
+
def last_over_time(
|
|
774
|
+
field: ExpressionType, window: ExpressionType = None
|
|
775
|
+
) -> InstrumentedExpression:
|
|
776
|
+
"""Calculates the latest value of a field, where recency determined by the
|
|
492
777
|
`@timestamp` field.
|
|
493
778
|
|
|
494
|
-
:param field:
|
|
779
|
+
:param field: the metric field to calculate the latest value for
|
|
780
|
+
:param window: the time window over which to find the latest value
|
|
495
781
|
"""
|
|
496
|
-
|
|
782
|
+
if window is not None:
|
|
783
|
+
return InstrumentedExpression(
|
|
784
|
+
f"LAST_OVER_TIME({_render(field)}, {_render(window)})"
|
|
785
|
+
)
|
|
786
|
+
else:
|
|
787
|
+
return InstrumentedExpression(f"LAST_OVER_TIME({_render(field)})")
|
|
497
788
|
|
|
498
789
|
|
|
499
790
|
def least(first: ExpressionType, rest: ExpressionType) -> InstrumentedExpression:
|
|
@@ -546,7 +837,8 @@ def log(base: ExpressionType, number: ExpressionType) -> InstrumentedExpression:
|
|
|
546
837
|
numbers, and base of one return `null` as well as a warning.
|
|
547
838
|
|
|
548
839
|
:param base: Base of logarithm. If `null`, the function returns `null`. If
|
|
549
|
-
not provided, this function returns the natural logarithm
|
|
840
|
+
not provided, this function returns the natural logarithm
|
|
841
|
+
(base e) of a value.
|
|
550
842
|
:param number: Numeric expression. If `null`, the function returns `null`.
|
|
551
843
|
"""
|
|
552
844
|
return InstrumentedExpression(f"LOG({_render(base)}, {_render(number)})")
|
|
@@ -597,7 +889,8 @@ def match_phrase(
|
|
|
597
889
|
|
|
598
890
|
:param field: Field that the query will target.
|
|
599
891
|
:param query: Value to find in the provided field.
|
|
600
|
-
:param options: (Optional) MatchPhrase additional options as function named
|
|
892
|
+
:param options: (Optional) MatchPhrase additional options as function named
|
|
893
|
+
parameters. See `match_phrase` for more information.
|
|
601
894
|
"""
|
|
602
895
|
if options is not None:
|
|
603
896
|
return InstrumentedExpression(
|
|
@@ -617,16 +910,24 @@ def max(field: ExpressionType) -> InstrumentedExpression:
|
|
|
617
910
|
return InstrumentedExpression(f"MAX({_render(field)})")
|
|
618
911
|
|
|
619
912
|
|
|
620
|
-
def max_over_time(
|
|
621
|
-
|
|
913
|
+
def max_over_time(
|
|
914
|
+
field: ExpressionType, window: ExpressionType = None
|
|
915
|
+
) -> InstrumentedExpression:
|
|
916
|
+
"""Calculates the maximum over time value of a field.
|
|
622
917
|
|
|
623
|
-
:param field:
|
|
918
|
+
:param field: the metric field to calculate the value for
|
|
919
|
+
:param window: the time window over which to compute the maximum
|
|
624
920
|
"""
|
|
625
|
-
|
|
921
|
+
if window is not None:
|
|
922
|
+
return InstrumentedExpression(
|
|
923
|
+
f"MAX_OVER_TIME({_render(field)}, {_render(window)})"
|
|
924
|
+
)
|
|
925
|
+
else:
|
|
926
|
+
return InstrumentedExpression(f"MAX_OVER_TIME({_render(field)})")
|
|
626
927
|
|
|
627
928
|
|
|
628
929
|
def md5(input: ExpressionType) -> InstrumentedExpression:
|
|
629
|
-
"""Computes the MD5 hash of the input.
|
|
930
|
+
"""Computes the MD5 hash of the input (if the MD5 hash is available on the JVM).
|
|
630
931
|
|
|
631
932
|
:param input: Input to hash.
|
|
632
933
|
"""
|
|
@@ -664,12 +965,28 @@ def min(field: ExpressionType) -> InstrumentedExpression:
|
|
|
664
965
|
return InstrumentedExpression(f"MIN({_render(field)})")
|
|
665
966
|
|
|
666
967
|
|
|
667
|
-
def min_over_time(
|
|
668
|
-
|
|
968
|
+
def min_over_time(
|
|
969
|
+
field: ExpressionType, window: ExpressionType = None
|
|
970
|
+
) -> InstrumentedExpression:
|
|
971
|
+
"""Calculates the minimum over time value of a field.
|
|
669
972
|
|
|
670
|
-
:param field:
|
|
973
|
+
:param field: the metric field to calculate the value for
|
|
974
|
+
:param window: the time window over which to compute the minimum
|
|
975
|
+
"""
|
|
976
|
+
if window is not None:
|
|
977
|
+
return InstrumentedExpression(
|
|
978
|
+
f"MIN_OVER_TIME({_render(field)}, {_render(window)})"
|
|
979
|
+
)
|
|
980
|
+
else:
|
|
981
|
+
return InstrumentedExpression(f"MIN_OVER_TIME({_render(field)})")
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
def month_name(date: ExpressionType) -> InstrumentedExpression:
|
|
985
|
+
"""Returns the month name for the provided date based on the configured Locale.
|
|
986
|
+
|
|
987
|
+
:param date: Date expression. If `null`, the function returns `null`.
|
|
671
988
|
"""
|
|
672
|
-
return InstrumentedExpression(f"
|
|
989
|
+
return InstrumentedExpression(f"MONTH_NAME({_render(date)})")
|
|
673
990
|
|
|
674
991
|
|
|
675
992
|
def multi_match(
|
|
@@ -680,8 +997,8 @@ def multi_match(
|
|
|
680
997
|
|
|
681
998
|
:param query: Value to find in the provided fields.
|
|
682
999
|
:param fields: Fields to use for matching
|
|
683
|
-
:param options: (Optional) Additional options for MultiMatch, passed as
|
|
684
|
-
named parameters
|
|
1000
|
+
:param options: (Optional) Additional options for MultiMatch, passed as
|
|
1001
|
+
function named parameters." See multi-match query for more information.
|
|
685
1002
|
"""
|
|
686
1003
|
if options is not None:
|
|
687
1004
|
return InstrumentedExpression(
|
|
@@ -699,7 +1016,7 @@ def mv_append(field1: ExpressionType, field2: ExpressionType) -> InstrumentedExp
|
|
|
699
1016
|
:param field1:
|
|
700
1017
|
:param field2:
|
|
701
1018
|
"""
|
|
702
|
-
return InstrumentedExpression(f"MV_APPEND({field1}, {field2})")
|
|
1019
|
+
return InstrumentedExpression(f"MV_APPEND({_render(field1)}, {_render(field2)})")
|
|
703
1020
|
|
|
704
1021
|
|
|
705
1022
|
def mv_avg(number: ExpressionType) -> InstrumentedExpression:
|
|
@@ -724,9 +1041,12 @@ def mv_concat(string: ExpressionType, delim: ExpressionType) -> InstrumentedExpr
|
|
|
724
1041
|
def mv_contains(
|
|
725
1042
|
superset: ExpressionType, subset: ExpressionType
|
|
726
1043
|
) -> InstrumentedExpression:
|
|
727
|
-
"""Checks if all values yielded by the second multivalue expression are
|
|
728
|
-
values yielded by the first multivalue expression. Returns a
|
|
729
|
-
treated as an empty set.
|
|
1044
|
+
"""Checks if all values yielded by the second multivalue expression are
|
|
1045
|
+
present in the values yielded by the first multivalue expression. Returns a
|
|
1046
|
+
boolean. Null values are treated as an empty set.
|
|
1047
|
+
|
|
1048
|
+
:param superset: Multivalue expression.
|
|
1049
|
+
:param subset: Multivalue expression.
|
|
730
1050
|
"""
|
|
731
1051
|
return InstrumentedExpression(
|
|
732
1052
|
f"MV_CONTAINS({_render(superset)}, {_render(subset)})"
|
|
@@ -760,6 +1080,20 @@ def mv_first(field: ExpressionType) -> InstrumentedExpression:
|
|
|
760
1080
|
return InstrumentedExpression(f"MV_FIRST({_render(field)})")
|
|
761
1081
|
|
|
762
1082
|
|
|
1083
|
+
def mv_intersection(
|
|
1084
|
+
field1: ExpressionType, field2: ExpressionType
|
|
1085
|
+
) -> InstrumentedExpression:
|
|
1086
|
+
"""Returns the values that appear in both input fields. Returns `null` if
|
|
1087
|
+
either field is null or if no values match.
|
|
1088
|
+
|
|
1089
|
+
:param field1: Multivalue expression. If null, the function returns null.
|
|
1090
|
+
:param field2: Multivalue expression. If null, the function returns null.
|
|
1091
|
+
"""
|
|
1092
|
+
return InstrumentedExpression(
|
|
1093
|
+
f"MV_INTERSECTION({_render(field1)}, {_render(field2)})"
|
|
1094
|
+
)
|
|
1095
|
+
|
|
1096
|
+
|
|
763
1097
|
def mv_last(field: ExpressionType) -> InstrumentedExpression:
|
|
764
1098
|
"""Converts a multivalue expression into a single valued column containing
|
|
765
1099
|
the last value. This is most useful when reading from a function that emits
|
|
@@ -848,11 +1182,11 @@ def mv_slice(
|
|
|
848
1182
|
|
|
849
1183
|
:param field: Multivalue expression. If `null`, the function returns `null`.
|
|
850
1184
|
:param start: Start position. If `null`, the function returns `null`. The
|
|
851
|
-
start argument can be negative. An index of -1 is used to
|
|
852
|
-
the last value in the list.
|
|
1185
|
+
start argument can be negative. An index of -1 is used to
|
|
1186
|
+
specify the last value in the list.
|
|
853
1187
|
:param end: End position(included). Optional; if omitted, the position at
|
|
854
|
-
`start` is returned. The end argument can be negative. An index
|
|
855
|
-
is used to specify the last value in the list.
|
|
1188
|
+
`start` is returned. The end argument can be negative. An index
|
|
1189
|
+
of -1 is used to specify the last value in the list.
|
|
856
1190
|
"""
|
|
857
1191
|
if end is not None:
|
|
858
1192
|
return InstrumentedExpression(
|
|
@@ -866,7 +1200,8 @@ def mv_sort(field: ExpressionType, order: ExpressionType) -> InstrumentedExpress
|
|
|
866
1200
|
"""Sorts a multivalued field in lexicographical order.
|
|
867
1201
|
|
|
868
1202
|
:param field: Multivalue expression. If `null`, the function returns `null`.
|
|
869
|
-
:param order: Sort order. The valid options are ASC and DESC, the default
|
|
1203
|
+
:param order: Sort order. The valid options are ASC and DESC, the default
|
|
1204
|
+
is ASC.
|
|
870
1205
|
"""
|
|
871
1206
|
return InstrumentedExpression(f"MV_SORT({_render(field)}, {_render(order)})")
|
|
872
1207
|
|
|
@@ -880,6 +1215,17 @@ def mv_sum(number: ExpressionType) -> InstrumentedExpression:
|
|
|
880
1215
|
return InstrumentedExpression(f"MV_SUM({_render(number)})")
|
|
881
1216
|
|
|
882
1217
|
|
|
1218
|
+
def mv_union(field1: ExpressionType, field2: ExpressionType) -> InstrumentedExpression:
|
|
1219
|
+
"""Returns all unique values from the combined input fields (set union).
|
|
1220
|
+
Null values are treated as empty sets; returns `null` only if both fields
|
|
1221
|
+
are null.
|
|
1222
|
+
|
|
1223
|
+
:param field1: Multivalue expression. Null values are treated as empty sets.
|
|
1224
|
+
:param field2: Multivalue expression. Null values are treated as empty sets.
|
|
1225
|
+
"""
|
|
1226
|
+
return InstrumentedExpression(f"MV_UNION({_render(field1)}, {_render(field2)})")
|
|
1227
|
+
|
|
1228
|
+
|
|
883
1229
|
def mv_zip(
|
|
884
1230
|
string1: ExpressionType, string2: ExpressionType, delim: ExpressionType = None
|
|
885
1231
|
) -> InstrumentedExpression:
|
|
@@ -896,6 +1242,25 @@ def mv_zip(
|
|
|
896
1242
|
return InstrumentedExpression(f"MV_ZIP({string1}, {string2})")
|
|
897
1243
|
|
|
898
1244
|
|
|
1245
|
+
def network_direction(
|
|
1246
|
+
source_ip: ExpressionType,
|
|
1247
|
+
destination_ip: ExpressionType,
|
|
1248
|
+
internal_networks: ExpressionType,
|
|
1249
|
+
) -> InstrumentedExpression:
|
|
1250
|
+
"""Returns the direction type (inbound, outbound, internal, external) given
|
|
1251
|
+
a source IP address, destination IP address, and a list of internal networks.
|
|
1252
|
+
|
|
1253
|
+
:param source_ip: Source IP address of type `ip` (both IPv4 and IPv6 are supported).
|
|
1254
|
+
:param destination_ip: Destination IP address of type `ip` (both IPv4 and
|
|
1255
|
+
IPv6 are supported).
|
|
1256
|
+
:param internal_networks: List of internal networks. Supports IPv4 and IPv6
|
|
1257
|
+
addresses, ranges in CIDR notation, and named ranges.
|
|
1258
|
+
"""
|
|
1259
|
+
return InstrumentedExpression(
|
|
1260
|
+
f"NETWORK_DIRECTION({_render(source_ip)}, {_render(destination_ip)}, {_render(internal_networks)})"
|
|
1261
|
+
)
|
|
1262
|
+
|
|
1263
|
+
|
|
899
1264
|
def now() -> InstrumentedExpression:
|
|
900
1265
|
"""Returns current date and time."""
|
|
901
1266
|
return InstrumentedExpression("NOW()")
|
|
@@ -916,6 +1281,19 @@ def percentile(
|
|
|
916
1281
|
)
|
|
917
1282
|
|
|
918
1283
|
|
|
1284
|
+
def percentile_over_time(
|
|
1285
|
+
field: ExpressionType, percentile: ExpressionType
|
|
1286
|
+
) -> InstrumentedExpression:
|
|
1287
|
+
"""Calculates the percentile over time of a field.
|
|
1288
|
+
|
|
1289
|
+
:param field: the metric field to calculate the value for
|
|
1290
|
+
:param percentile: the percentile value to compute (between 0 and 100)
|
|
1291
|
+
"""
|
|
1292
|
+
return InstrumentedExpression(
|
|
1293
|
+
f"PERCENTILE_OVER_TIME({_render(field)}, {_render(percentile)})"
|
|
1294
|
+
)
|
|
1295
|
+
|
|
1296
|
+
|
|
919
1297
|
def pi() -> InstrumentedExpression:
|
|
920
1298
|
"""Returns Pi, the ratio of a circle’s circumference to its diameter."""
|
|
921
1299
|
return InstrumentedExpression("PI()")
|
|
@@ -924,22 +1302,37 @@ def pi() -> InstrumentedExpression:
|
|
|
924
1302
|
def pow(base: ExpressionType, exponent: ExpressionType) -> InstrumentedExpression:
|
|
925
1303
|
"""Returns the value of `base` raised to the power of `exponent`.
|
|
926
1304
|
|
|
927
|
-
:param base: Numeric expression for the base. If `null`, the function
|
|
928
|
-
|
|
1305
|
+
:param base: Numeric expression for the base. If `null`, the function
|
|
1306
|
+
returns `null`.
|
|
1307
|
+
:param exponent: Numeric expression for the exponent. If `null`, the
|
|
1308
|
+
function returns `null`.
|
|
929
1309
|
"""
|
|
930
1310
|
return InstrumentedExpression(f"POW({_render(base)}, {_render(exponent)})")
|
|
931
1311
|
|
|
932
1312
|
|
|
933
1313
|
def present(field: ExpressionType) -> InstrumentedExpression:
|
|
934
|
-
"""Returns true if the input expression yields any non-null values within
|
|
935
|
-
aggregation context. Otherwise it returns false.
|
|
1314
|
+
"""Returns true if the input expression yields any non-null values within
|
|
1315
|
+
the current aggregation context. Otherwise it returns false.
|
|
1316
|
+
|
|
1317
|
+
:param field: Expression that outputs values to be checked for presence.
|
|
936
1318
|
"""
|
|
937
1319
|
return InstrumentedExpression(f"PRESENT({_render(field)})")
|
|
938
1320
|
|
|
939
1321
|
|
|
940
|
-
def present_over_time(
|
|
941
|
-
|
|
942
|
-
|
|
1322
|
+
def present_over_time(
|
|
1323
|
+
field: ExpressionType, window: ExpressionType = None
|
|
1324
|
+
) -> InstrumentedExpression:
|
|
1325
|
+
"""Calculates the presence of a field in the output result over time range.
|
|
1326
|
+
|
|
1327
|
+
:param field: the metric field to calculate the value for
|
|
1328
|
+
:param window: the time window over which to compute the present over time
|
|
1329
|
+
"""
|
|
1330
|
+
if window is not None:
|
|
1331
|
+
return InstrumentedExpression(
|
|
1332
|
+
f"PRESENT_OVER_TIME({_render(field)}, {_render(window)})"
|
|
1333
|
+
)
|
|
1334
|
+
else:
|
|
1335
|
+
return InstrumentedExpression(f"PRESENT_OVER_TIME({_render(field)})")
|
|
943
1336
|
|
|
944
1337
|
|
|
945
1338
|
def qstr(
|
|
@@ -949,8 +1342,8 @@ def qstr(
|
|
|
949
1342
|
matches the row.
|
|
950
1343
|
|
|
951
1344
|
:param query: Query string in Lucene query string format.
|
|
952
|
-
:param options: (Optional) Additional options for Query String as function
|
|
953
|
-
parameters.
|
|
1345
|
+
:param options: (Optional) Additional options for Query String as function
|
|
1346
|
+
named parameters. See query string query for more information.
|
|
954
1347
|
"""
|
|
955
1348
|
if options is not None:
|
|
956
1349
|
return InstrumentedExpression(f"QSTR({_render(query)}, {_render(options)})")
|
|
@@ -958,12 +1351,22 @@ def qstr(
|
|
|
958
1351
|
return InstrumentedExpression(f"QSTR({_render(query)})")
|
|
959
1352
|
|
|
960
1353
|
|
|
961
|
-
def rate(field: ExpressionType) -> InstrumentedExpression:
|
|
962
|
-
"""
|
|
1354
|
+
def rate(field: ExpressionType, window: ExpressionType) -> InstrumentedExpression:
|
|
1355
|
+
"""Calculates the per-second average rate of increase of a counter. Rate
|
|
1356
|
+
calculations account for breaks in monotonicity, such as counter resets
|
|
1357
|
+
when a service restarts, and extrapolate values within each bucketed time
|
|
1358
|
+
interval. Rate is the most appropriate aggregate function for counters. It
|
|
1359
|
+
is only allowed in a STATS command under a `TS` source command, to be
|
|
1360
|
+
properly applied per time series.
|
|
963
1361
|
|
|
964
|
-
:param field:
|
|
1362
|
+
:param field: the counter field whose per-second average rate of increase
|
|
1363
|
+
is computed
|
|
1364
|
+
:param window: the time window over which the rate is computed
|
|
965
1365
|
"""
|
|
966
|
-
|
|
1366
|
+
if window is None:
|
|
1367
|
+
return InstrumentedExpression(f"RATE({_render(field)}, {_render(window)})")
|
|
1368
|
+
else:
|
|
1369
|
+
return InstrumentedExpression(f"RATE({_render(field)})")
|
|
967
1370
|
|
|
968
1371
|
|
|
969
1372
|
def repeat(string: ExpressionType, number: ExpressionType) -> InstrumentedExpression:
|
|
@@ -1017,8 +1420,8 @@ def round(
|
|
|
1017
1420
|
number, rounds to the number of digits left of the decimal point.
|
|
1018
1421
|
|
|
1019
1422
|
:param number: The numeric value to round. If `null`, the function returns `null`.
|
|
1020
|
-
:param decimals: The number of decimal places to round to. Defaults to 0.
|
|
1021
|
-
`null`, the function returns `null`.
|
|
1423
|
+
:param decimals: The number of decimal places to round to. Defaults to 0.
|
|
1424
|
+
If `null`, the function returns `null`.
|
|
1022
1425
|
"""
|
|
1023
1426
|
if decimals is not None:
|
|
1024
1427
|
return InstrumentedExpression(f"ROUND({_render(number)}, {_render(decimals)})")
|
|
@@ -1059,12 +1462,21 @@ def scalb(d: ExpressionType, scale_factor: ExpressionType) -> InstrumentedExpres
|
|
|
1059
1462
|
|
|
1060
1463
|
:param d: Numeric expression for the multiplier. If `null`, the function
|
|
1061
1464
|
returns `null`.
|
|
1062
|
-
:param scale_factor: Numeric expression for the scale factor. If `null`,
|
|
1063
|
-
function returns `null`.
|
|
1465
|
+
:param scale_factor: Numeric expression for the scale factor. If `null`,
|
|
1466
|
+
the function returns `null`.
|
|
1064
1467
|
"""
|
|
1065
1468
|
return InstrumentedExpression(f"SCALB({_render(d)}, {_render(scale_factor)})")
|
|
1066
1469
|
|
|
1067
1470
|
|
|
1471
|
+
def score(query: ExpressionType) -> InstrumentedExpression:
|
|
1472
|
+
"""Scores an expression. Only full text functions will be scored. Returns
|
|
1473
|
+
scores for all the resulting docs.
|
|
1474
|
+
|
|
1475
|
+
:param query: Boolean expression that contains full text function(s) to be scored.
|
|
1476
|
+
"""
|
|
1477
|
+
return InstrumentedExpression(f"SCORE({_render(query)})")
|
|
1478
|
+
|
|
1479
|
+
|
|
1068
1480
|
def sha1(input: ExpressionType) -> InstrumentedExpression:
|
|
1069
1481
|
"""Computes the SHA1 hash of the input.
|
|
1070
1482
|
|
|
@@ -1133,24 +1545,6 @@ def sqrt(number: ExpressionType) -> InstrumentedExpression:
|
|
|
1133
1545
|
return InstrumentedExpression(f"SQRT({_render(number)})")
|
|
1134
1546
|
|
|
1135
1547
|
|
|
1136
|
-
def starts_with(str: ExpressionType, prefix: ExpressionType) -> InstrumentedExpression:
|
|
1137
|
-
"""Returns a boolean that indicates whether a keyword string starts with
|
|
1138
|
-
another string.
|
|
1139
|
-
|
|
1140
|
-
:param str: String expression. If `null`, the function returns `null`.
|
|
1141
|
-
:param prefix: String expression. If `null`, the function returns `null`.
|
|
1142
|
-
"""
|
|
1143
|
-
return InstrumentedExpression(f"STARTS_WITH({_render(str)}, {_render(prefix)})")
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
def std_dev(number: ExpressionType) -> InstrumentedExpression:
|
|
1147
|
-
"""The population standard deviation of a numeric field.
|
|
1148
|
-
|
|
1149
|
-
:param number:
|
|
1150
|
-
"""
|
|
1151
|
-
return InstrumentedExpression(f"STD_DEV({_render(number)})")
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
1548
|
def st_centroid_agg(field: ExpressionType) -> InstrumentedExpression:
|
|
1155
1549
|
"""Calculate the spatial centroid over a field with spatial point geometry type.
|
|
1156
1550
|
|
|
@@ -1166,13 +1560,13 @@ def st_contains(
|
|
|
1166
1560
|
the inverse of the ST_WITHIN function.
|
|
1167
1561
|
|
|
1168
1562
|
:param geom_a: Expression of type `geo_point`, `cartesian_point`,
|
|
1169
|
-
`geo_shape` or `cartesian_shape`. If `null`, the function
|
|
1170
|
-
`null`.
|
|
1171
|
-
:param geom_b: Expression of type `geo_point`, `cartesian_point`,
|
|
1172
|
-
or `cartesian_shape`. If `null`, the function
|
|
1173
|
-
second parameter must also have the same
|
|
1174
|
-
first. This means it is not
|
|
1175
|
-
`cartesian_*` parameters.
|
|
1563
|
+
`geo_shape` or `cartesian_shape`. If `null`, the function
|
|
1564
|
+
returns `null`.
|
|
1565
|
+
:param geom_b: Expression of type `geo_point`, `cartesian_point`,
|
|
1566
|
+
`geo_shape` or `cartesian_shape`. If `null`, the function
|
|
1567
|
+
returns `null`. The second parameter must also have the same
|
|
1568
|
+
coordinate system as the first. This means it is not
|
|
1569
|
+
possible to combine `geo_*` and `cartesian_*` parameters.
|
|
1176
1570
|
"""
|
|
1177
1571
|
return InstrumentedExpression(f"ST_CONTAINS({_render(geom_a)}, {_render(geom_b)})")
|
|
1178
1572
|
|
|
@@ -1184,14 +1578,16 @@ def st_disjoint(
|
|
|
1184
1578
|
This is the inverse of the ST_INTERSECTS function. In mathematical terms:
|
|
1185
1579
|
ST_Disjoint(A, B) ⇔ A ⋂ B = ∅
|
|
1186
1580
|
|
|
1187
|
-
:param geom_a: Expression
|
|
1188
|
-
`geo_shape` or `cartesian_shape
|
|
1189
|
-
`null
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
`
|
|
1581
|
+
:param geom_a: Expression that is either a geometry (`geo_point`,
|
|
1582
|
+
`cartesian_point`, `geo_shape` or `cartesian_shape`) or a
|
|
1583
|
+
geo-grid value (`geohash`, `geotile`, `geohex`). If `null`,
|
|
1584
|
+
the function returns `null`.
|
|
1585
|
+
:param geom_b: Expression that is either a geometry (`geo_point`,
|
|
1586
|
+
`cartesian_point`, `geo_shape` or `cartesian_shape`) or a
|
|
1587
|
+
geo-grid value (`geohash`, `geotile`, `geohex`). If `null`,
|
|
1588
|
+
the function returns `null`. The second parameter must also
|
|
1589
|
+
have the same coordinate system as the first. This means it
|
|
1590
|
+
is not possible to combine `geo_*` and `cartesian_*` parameters.
|
|
1195
1591
|
"""
|
|
1196
1592
|
return InstrumentedExpression(f"ST_DISJOINT({_render(geom_a)}, {_render(geom_b)})")
|
|
1197
1593
|
|
|
@@ -1207,9 +1603,10 @@ def st_distance(
|
|
|
1207
1603
|
:param geom_a: Expression of type `geo_point` or `cartesian_point`. If
|
|
1208
1604
|
`null`, the function returns `null`.
|
|
1209
1605
|
:param geom_b: Expression of type `geo_point` or `cartesian_point`. If
|
|
1210
|
-
`null`, the function returns `null`. The second parameter
|
|
1211
|
-
also have the same coordinate system as the first. This
|
|
1212
|
-
is not possible to combine `geo_point` and
|
|
1606
|
+
`null`, the function returns `null`. The second parameter
|
|
1607
|
+
must also have the same coordinate system as the first. This
|
|
1608
|
+
means it is not possible to combine `geo_point` and
|
|
1609
|
+
`cartesian_point` parameters.
|
|
1213
1610
|
"""
|
|
1214
1611
|
return InstrumentedExpression(f"ST_DISTANCE({_render(geom_a)}, {_render(geom_b)})")
|
|
1215
1612
|
|
|
@@ -1218,8 +1615,8 @@ def st_envelope(geometry: ExpressionType) -> InstrumentedExpression:
|
|
|
1218
1615
|
"""Determines the minimum bounding box of the supplied geometry.
|
|
1219
1616
|
|
|
1220
1617
|
:param geometry: Expression of type `geo_point`, `geo_shape`,
|
|
1221
|
-
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1222
|
-
returns `null`.
|
|
1618
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1619
|
+
function returns `null`.
|
|
1223
1620
|
"""
|
|
1224
1621
|
return InstrumentedExpression(f"ST_ENVELOPE({_render(geometry)})")
|
|
1225
1622
|
|
|
@@ -1237,9 +1634,10 @@ def st_geohash(
|
|
|
1237
1634
|
geometry: ExpressionType, precision: ExpressionType, bounds: ExpressionType = None
|
|
1238
1635
|
) -> InstrumentedExpression:
|
|
1239
1636
|
"""Calculates the `geohash` of the supplied geo_point at the specified
|
|
1240
|
-
precision. The result is long encoded. Use
|
|
1241
|
-
|
|
1242
|
-
|
|
1637
|
+
precision. The result is long encoded. Use TO_STRING to convert the result
|
|
1638
|
+
to a string, TO_LONG to convert it to a `long`, or TO_GEOSHAPE to calculate
|
|
1639
|
+
the `geo_shape` bounding geometry. These functions are related to the
|
|
1640
|
+
`geo_grid` query and the `geohash_grid` aggregation.
|
|
1243
1641
|
|
|
1244
1642
|
:param geometry: Expression of type `geo_point`. If `null`, the function
|
|
1245
1643
|
returns `null`.
|
|
@@ -1283,17 +1681,18 @@ def st_geohex(
|
|
|
1283
1681
|
geometry: ExpressionType, precision: ExpressionType, bounds: ExpressionType = None
|
|
1284
1682
|
) -> InstrumentedExpression:
|
|
1285
1683
|
"""Calculates the `geohex`, the H3 cell-id, of the supplied geo_point at
|
|
1286
|
-
the specified precision. The result is long encoded. Use
|
|
1287
|
-
|
|
1288
|
-
|
|
1684
|
+
the specified precision. The result is long encoded. Use TO_STRING to
|
|
1685
|
+
convert the result to a string, TO_LONG to convert it to a `long`, or
|
|
1686
|
+
TO_GEOSHAPE to calculate the `geo_shape` bounding geometry. These
|
|
1687
|
+
functions are related to the `geo_grid` query and the `geohex_grid` aggregation.
|
|
1289
1688
|
|
|
1290
1689
|
:param geometry: Expression of type `geo_point`. If `null`, the function
|
|
1291
1690
|
returns `null`.
|
|
1292
1691
|
:param precision: Expression of type `integer`. If `null`, the function
|
|
1293
1692
|
returns `null`. Valid values are between 0 and 15.
|
|
1294
1693
|
:param bounds: Optional bounds to filter the grid tiles, a `geo_shape` of
|
|
1295
|
-
type `BBOX`. Use `ST_ENVELOPE` if the `geo_shape`
|
|
1296
|
-
|
|
1694
|
+
type `BBOX`. Use `ST_ENVELOPE` if the `geo_shape` is of any
|
|
1695
|
+
other type.
|
|
1297
1696
|
"""
|
|
1298
1697
|
if bounds is not None:
|
|
1299
1698
|
return InstrumentedExpression(
|
|
@@ -1329,9 +1728,10 @@ def st_geotile(
|
|
|
1329
1728
|
geometry: ExpressionType, precision: ExpressionType, bounds: ExpressionType = None
|
|
1330
1729
|
) -> InstrumentedExpression:
|
|
1331
1730
|
"""Calculates the `geotile` of the supplied geo_point at the specified
|
|
1332
|
-
precision. The result is long encoded. Use
|
|
1333
|
-
|
|
1334
|
-
|
|
1731
|
+
precision. The result is long encoded. Use TO_STRING to convert the result
|
|
1732
|
+
to a string, TO_LONG to convert it to a `long`, or TO_GEOSHAPE to calculate
|
|
1733
|
+
the `geo_shape` bounding geometry. These functions are related to the
|
|
1734
|
+
`geo_grid` query and the `geotile_grid` aggregation.
|
|
1335
1735
|
|
|
1336
1736
|
:param geometry: Expression of type `geo_point`. If `null`, the function
|
|
1337
1737
|
returns `null`.
|
|
@@ -1379,38 +1779,69 @@ def st_intersects(
|
|
|
1379
1779
|
within polygons). This is the inverse of the ST_DISJOINT function. In
|
|
1380
1780
|
mathematical terms: ST_Intersects(A, B) ⇔ A ⋂ B ≠ ∅
|
|
1381
1781
|
|
|
1382
|
-
:param geom_a: Expression
|
|
1383
|
-
`geo_shape` or `cartesian_shape
|
|
1384
|
-
`null
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
`
|
|
1782
|
+
:param geom_a: Expression that is either a geometry (`geo_point`,
|
|
1783
|
+
`cartesian_point`, `geo_shape` or `cartesian_shape`) or a
|
|
1784
|
+
geo-grid value (`geohash`, `geotile`, `geohex`). If `null`,
|
|
1785
|
+
the function returns `null`.
|
|
1786
|
+
:param geom_b: Expression that is either a geometry (`geo_point`,
|
|
1787
|
+
`cartesian_point`, `geo_shape` or `cartesian_shape`) or a
|
|
1788
|
+
geo-grid value (`geohash`, `geotile`, `geohex`). If `null`,
|
|
1789
|
+
the function returns `null`. The second parameter must also
|
|
1790
|
+
have the same coordinate system as the first. This means it
|
|
1791
|
+
is not possible to combine `geo_*` and `cartesian_*` parameters.
|
|
1390
1792
|
"""
|
|
1391
1793
|
return InstrumentedExpression(
|
|
1392
1794
|
f"ST_INTERSECTS({_render(geom_a)}, {_render(geom_b)})"
|
|
1393
1795
|
)
|
|
1394
1796
|
|
|
1395
1797
|
|
|
1798
|
+
def st_npoints(geometry: ExpressionType) -> InstrumentedExpression:
|
|
1799
|
+
"""Counts the number of points in the supplied geometry.
|
|
1800
|
+
|
|
1801
|
+
:param geometry: Expression of type `geo_point`, `geo_shape`,
|
|
1802
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1803
|
+
function returns `null`.
|
|
1804
|
+
"""
|
|
1805
|
+
return InstrumentedExpression(f"ST_NPOINTS({_render(geometry)})")
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
def st_simplify(
|
|
1809
|
+
geometry: ExpressionType, tolerance: ExpressionType
|
|
1810
|
+
) -> InstrumentedExpression:
|
|
1811
|
+
"""Simplifies the input geometry by applying the Douglas-Peucker algorithm
|
|
1812
|
+
with a specified tolerance. Vertices that fall within the tolerance
|
|
1813
|
+
distance from the simplified shape are removed. Note that the resulting
|
|
1814
|
+
geometry may be invalid, even if the original input was valid.
|
|
1815
|
+
|
|
1816
|
+
:param geometry: Expression of type `geo_point`, `geo_shape`,
|
|
1817
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1818
|
+
function returns `null`.
|
|
1819
|
+
:param tolerance: Tolerance for the geometry simplification, in the units
|
|
1820
|
+
of the input SRS
|
|
1821
|
+
"""
|
|
1822
|
+
return InstrumentedExpression(
|
|
1823
|
+
f"ST_SIMPLIFY({_render(geometry)}, {_render(tolerance)})"
|
|
1824
|
+
)
|
|
1825
|
+
|
|
1826
|
+
|
|
1396
1827
|
def st_within(geom_a: ExpressionType, geom_b: ExpressionType) -> InstrumentedExpression:
|
|
1397
1828
|
"""Returns whether the first geometry is within the second geometry. This
|
|
1398
1829
|
is the inverse of the ST_CONTAINS function.
|
|
1399
1830
|
|
|
1400
1831
|
:param geom_a: Expression of type `geo_point`, `cartesian_point`,
|
|
1401
|
-
`geo_shape` or `cartesian_shape`. If `null`, the function
|
|
1402
|
-
`null`.
|
|
1403
|
-
:param geom_b: Expression of type `geo_point`, `cartesian_point`,
|
|
1404
|
-
or `cartesian_shape`. If `null`, the function
|
|
1405
|
-
second parameter must also have the same
|
|
1406
|
-
first. This means it is not
|
|
1407
|
-
`cartesian_*` parameters.
|
|
1832
|
+
`geo_shape` or `cartesian_shape`. If `null`, the function
|
|
1833
|
+
returns `null`.
|
|
1834
|
+
:param geom_b: Expression of type `geo_point`, `cartesian_point`,
|
|
1835
|
+
`geo_shape` or `cartesian_shape`. If `null`, the function
|
|
1836
|
+
returns `null`. The second parameter must also have the same
|
|
1837
|
+
coordinate system as the first. This means it is not
|
|
1838
|
+
possible to combine `geo_*` and `cartesian_*` parameters.
|
|
1408
1839
|
"""
|
|
1409
1840
|
return InstrumentedExpression(f"ST_WITHIN({_render(geom_a)}, {_render(geom_b)})")
|
|
1410
1841
|
|
|
1411
1842
|
|
|
1412
1843
|
def st_x(point: ExpressionType) -> InstrumentedExpression:
|
|
1413
|
-
"""Extracts the `x` coordinate from the supplied point. If the
|
|
1844
|
+
"""Extracts the `x` coordinate from the supplied point. If the point is of
|
|
1414
1845
|
type `geo_point` this is equivalent to extracting the `longitude` value.
|
|
1415
1846
|
|
|
1416
1847
|
:param point: Expression of type `geo_point` or `cartesian_point`. If
|
|
@@ -1424,8 +1855,9 @@ def st_xmax(point: ExpressionType) -> InstrumentedExpression:
|
|
|
1424
1855
|
geometry. If the geometry is of type `geo_point` or `geo_shape` this is
|
|
1425
1856
|
equivalent to extracting the maximum `longitude` value.
|
|
1426
1857
|
|
|
1427
|
-
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1428
|
-
or `cartesian_shape`. If `null`, the
|
|
1858
|
+
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1859
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1860
|
+
function returns `null`.
|
|
1429
1861
|
"""
|
|
1430
1862
|
return InstrumentedExpression(f"ST_XMAX({_render(point)})")
|
|
1431
1863
|
|
|
@@ -1435,14 +1867,15 @@ def st_xmin(point: ExpressionType) -> InstrumentedExpression:
|
|
|
1435
1867
|
geometry. If the geometry is of type `geo_point` or `geo_shape` this is
|
|
1436
1868
|
equivalent to extracting the minimum `longitude` value.
|
|
1437
1869
|
|
|
1438
|
-
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1439
|
-
or `cartesian_shape`. If `null`, the
|
|
1870
|
+
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1871
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1872
|
+
function returns `null`.
|
|
1440
1873
|
"""
|
|
1441
1874
|
return InstrumentedExpression(f"ST_XMIN({_render(point)})")
|
|
1442
1875
|
|
|
1443
1876
|
|
|
1444
1877
|
def st_y(point: ExpressionType) -> InstrumentedExpression:
|
|
1445
|
-
"""Extracts the `y` coordinate from the supplied point. If the
|
|
1878
|
+
"""Extracts the `y` coordinate from the supplied point. If the point is of
|
|
1446
1879
|
type `geo_point` this is equivalent to extracting the `latitude` value.
|
|
1447
1880
|
|
|
1448
1881
|
:param point: Expression of type `geo_point` or `cartesian_point`. If
|
|
@@ -1456,8 +1889,9 @@ def st_ymax(point: ExpressionType) -> InstrumentedExpression:
|
|
|
1456
1889
|
geometry. If the geometry is of type `geo_point` or `geo_shape` this is
|
|
1457
1890
|
equivalent to extracting the maximum `latitude` value.
|
|
1458
1891
|
|
|
1459
|
-
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1460
|
-
or `cartesian_shape`. If `null`, the
|
|
1892
|
+
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1893
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1894
|
+
function returns `null`.
|
|
1461
1895
|
"""
|
|
1462
1896
|
return InstrumentedExpression(f"ST_YMAX({_render(point)})")
|
|
1463
1897
|
|
|
@@ -1467,12 +1901,45 @@ def st_ymin(point: ExpressionType) -> InstrumentedExpression:
|
|
|
1467
1901
|
geometry. If the geometry is of type `geo_point` or `geo_shape` this is
|
|
1468
1902
|
equivalent to extracting the minimum `latitude` value.
|
|
1469
1903
|
|
|
1470
|
-
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1471
|
-
or `cartesian_shape`. If `null`, the
|
|
1904
|
+
:param point: Expression of type `geo_point`, `geo_shape`,
|
|
1905
|
+
`cartesian_point` or `cartesian_shape`. If `null`, the
|
|
1906
|
+
function returns `null`.
|
|
1472
1907
|
"""
|
|
1473
1908
|
return InstrumentedExpression(f"ST_YMIN({_render(point)})")
|
|
1474
1909
|
|
|
1475
1910
|
|
|
1911
|
+
def starts_with(str: ExpressionType, prefix: ExpressionType) -> InstrumentedExpression:
|
|
1912
|
+
"""Returns a boolean that indicates whether a keyword string starts with
|
|
1913
|
+
another string.
|
|
1914
|
+
|
|
1915
|
+
:param str: String expression. If `null`, the function returns `null`.
|
|
1916
|
+
:param prefix: String expression. If `null`, the function returns `null`.
|
|
1917
|
+
"""
|
|
1918
|
+
return InstrumentedExpression(f"STARTS_WITH({_render(str)}, {_render(prefix)})")
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
def std_dev(number: ExpressionType) -> InstrumentedExpression:
|
|
1922
|
+
"""The population standard deviation of a numeric field.
|
|
1923
|
+
|
|
1924
|
+
:param number:
|
|
1925
|
+
"""
|
|
1926
|
+
return InstrumentedExpression(f"STD_DEV({_render(number)})")
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
def stddev_over_time(
|
|
1930
|
+
field: ExpressionType, window: ExpressionType
|
|
1931
|
+
) -> InstrumentedExpression:
|
|
1932
|
+
"""Calculates the population standard deviation over time of a numeric field.
|
|
1933
|
+
|
|
1934
|
+
:param field: the metric field to calculate the standard deviation for
|
|
1935
|
+
:param window: the time window over which to compute the standard deviation
|
|
1936
|
+
over time
|
|
1937
|
+
"""
|
|
1938
|
+
return InstrumentedExpression(
|
|
1939
|
+
f"STDDEV_OVER_TIME({_render(field)}, {_render(window)})"
|
|
1940
|
+
)
|
|
1941
|
+
|
|
1942
|
+
|
|
1476
1943
|
def substring(
|
|
1477
1944
|
string: ExpressionType, start: ExpressionType, length: ExpressionType = None
|
|
1478
1945
|
) -> InstrumentedExpression:
|
|
@@ -1481,8 +1948,8 @@ def substring(
|
|
|
1481
1948
|
|
|
1482
1949
|
:param string: String expression. If `null`, the function returns `null`.
|
|
1483
1950
|
:param start: Start position.
|
|
1484
|
-
:param length: Length of the substring from the start position. Optional;
|
|
1485
|
-
omitted, all positions after `start` are returned.
|
|
1951
|
+
:param length: Length of the substring from the start position. Optional;
|
|
1952
|
+
if omitted, all positions after `start` are returned.
|
|
1486
1953
|
"""
|
|
1487
1954
|
if length is not None:
|
|
1488
1955
|
return InstrumentedExpression(
|
|
@@ -1500,9 +1967,20 @@ def sum(number: ExpressionType) -> InstrumentedExpression:
|
|
|
1500
1967
|
return InstrumentedExpression(f"SUM({_render(number)})")
|
|
1501
1968
|
|
|
1502
1969
|
|
|
1503
|
-
def sum_over_time(
|
|
1504
|
-
|
|
1505
|
-
|
|
1970
|
+
def sum_over_time(
|
|
1971
|
+
field: ExpressionType, window: ExpressionType = None
|
|
1972
|
+
) -> InstrumentedExpression:
|
|
1973
|
+
"""Calculates the sum over time value of a field.
|
|
1974
|
+
|
|
1975
|
+
:param field: the metric field to calculate the value for
|
|
1976
|
+
:param window: the time window over which to compute the sum over time
|
|
1977
|
+
"""
|
|
1978
|
+
if window is not None:
|
|
1979
|
+
return InstrumentedExpression(
|
|
1980
|
+
f"SUM_OVER_TIME({_render(field)}, {_render(window)})"
|
|
1981
|
+
)
|
|
1982
|
+
else:
|
|
1983
|
+
return InstrumentedExpression(f"SUM({_render(field)})")
|
|
1506
1984
|
|
|
1507
1985
|
|
|
1508
1986
|
def tan(angle: ExpressionType) -> InstrumentedExpression:
|
|
@@ -1526,6 +2004,15 @@ def tau() -> InstrumentedExpression:
|
|
|
1526
2004
|
return InstrumentedExpression("TAU()")
|
|
1527
2005
|
|
|
1528
2006
|
|
|
2007
|
+
def tbucket(buckets: ExpressionType) -> InstrumentedExpression:
|
|
2008
|
+
"""Creates groups of values - buckets - out of a @timestamp attribute. The
|
|
2009
|
+
size of the buckets must be provided directly.
|
|
2010
|
+
|
|
2011
|
+
:param buckets: Desired bucket size.
|
|
2012
|
+
"""
|
|
2013
|
+
return InstrumentedExpression(f"TBUCKET({_render(buckets)})")
|
|
2014
|
+
|
|
2015
|
+
|
|
1529
2016
|
def term(field: ExpressionType, query: ExpressionType) -> InstrumentedExpression:
|
|
1530
2017
|
"""Performs a Term query on the specified field. Returns true if the
|
|
1531
2018
|
provided term matches the row.
|
|
@@ -1539,25 +2026,19 @@ def term(field: ExpressionType, query: ExpressionType) -> InstrumentedExpression
|
|
|
1539
2026
|
def text_embedding(
|
|
1540
2027
|
text: ExpressionType, inference_id: ExpressionType
|
|
1541
2028
|
) -> InstrumentedExpression:
|
|
1542
|
-
"""Generates dense vector embeddings from text input using a specified
|
|
1543
|
-
Use this function to generate query vectors for KNN
|
|
1544
|
-
or others dense vector based operations.
|
|
1545
|
-
return InstrumentedExpression(
|
|
1546
|
-
f"TEXT_EMBEDDING({_render(text)}, {_render(inference_id)})"
|
|
1547
|
-
)
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
def top(
|
|
1551
|
-
field: ExpressionType, limit: ExpressionType, order: ExpressionType
|
|
1552
|
-
) -> InstrumentedExpression:
|
|
1553
|
-
"""Collects the top values for a field. Includes repeated values.
|
|
2029
|
+
"""Generates dense vector embeddings from text input using a specified
|
|
2030
|
+
inference endpoint. Use this function to generate query vectors for KNN
|
|
2031
|
+
searches against your vectorized data or others dense vector based operations.
|
|
1554
2032
|
|
|
1555
|
-
:param
|
|
1556
|
-
|
|
1557
|
-
:param
|
|
2033
|
+
:param text: Text string to generate embeddings from. Must be a non-null
|
|
2034
|
+
literal string value.
|
|
2035
|
+
:param inference_id: Identifier of an existing inference endpoint the that
|
|
2036
|
+
will generate the embeddings. The inference endpoint
|
|
2037
|
+
must have the `text_embedding` task type and should
|
|
2038
|
+
use the same model that was used to embed your indexed data.
|
|
1558
2039
|
"""
|
|
1559
2040
|
return InstrumentedExpression(
|
|
1560
|
-
f"
|
|
2041
|
+
f"TEXT_EMBEDDING({_render(text)}, {_render(inference_id)})"
|
|
1561
2042
|
)
|
|
1562
2043
|
|
|
1563
2044
|
|
|
@@ -1585,8 +2066,8 @@ def to_boolean(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1585
2066
|
numerical value of `0` will be converted to `false`, anything else will be
|
|
1586
2067
|
converted to `true`.
|
|
1587
2068
|
|
|
1588
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1589
|
-
or an expression.
|
|
2069
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2070
|
+
column or an expression.
|
|
1590
2071
|
"""
|
|
1591
2072
|
return InstrumentedExpression(f"TO_BOOLEAN({_render(field)})")
|
|
1592
2073
|
|
|
@@ -1595,8 +2076,8 @@ def to_cartesianpoint(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1595
2076
|
"""Converts an input value to a `cartesian_point` value. A string will only
|
|
1596
2077
|
be successfully converted if it respects the WKT Point format.
|
|
1597
2078
|
|
|
1598
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1599
|
-
or an expression.
|
|
2079
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2080
|
+
column or an expression.
|
|
1600
2081
|
"""
|
|
1601
2082
|
return InstrumentedExpression(f"TO_CARTESIANPOINT({_render(field)})")
|
|
1602
2083
|
|
|
@@ -1605,12 +2086,21 @@ def to_cartesianshape(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1605
2086
|
"""Converts an input value to a `cartesian_shape` value. A string will only
|
|
1606
2087
|
be successfully converted if it respects the WKT format.
|
|
1607
2088
|
|
|
1608
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1609
|
-
or an expression.
|
|
2089
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2090
|
+
column or an expression.
|
|
1610
2091
|
"""
|
|
1611
2092
|
return InstrumentedExpression(f"TO_CARTESIANSHAPE({_render(field)})")
|
|
1612
2093
|
|
|
1613
2094
|
|
|
2095
|
+
def to_date_nanos(field: ExpressionType) -> InstrumentedExpression:
|
|
2096
|
+
"""Converts an input to a nanosecond-resolution date value (aka date_nanos).
|
|
2097
|
+
|
|
2098
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2099
|
+
column or an expression.
|
|
2100
|
+
"""
|
|
2101
|
+
return InstrumentedExpression(f"TO_DATE_NANOS({_render(field)})")
|
|
2102
|
+
|
|
2103
|
+
|
|
1614
2104
|
def to_dateperiod(field: ExpressionType) -> InstrumentedExpression:
|
|
1615
2105
|
"""Converts an input value into a `date_period` value.
|
|
1616
2106
|
|
|
@@ -1624,21 +2114,12 @@ def to_datetime(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1624
2114
|
successfully converted if it’s respecting the format
|
|
1625
2115
|
`yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. To convert dates in other formats, use `DATE_PARSE`.
|
|
1626
2116
|
|
|
1627
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1628
|
-
or an expression.
|
|
2117
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2118
|
+
column or an expression.
|
|
1629
2119
|
"""
|
|
1630
2120
|
return InstrumentedExpression(f"TO_DATETIME({_render(field)})")
|
|
1631
2121
|
|
|
1632
2122
|
|
|
1633
|
-
def to_date_nanos(field: ExpressionType) -> InstrumentedExpression:
|
|
1634
|
-
"""Converts an input to a nanosecond-resolution date value (aka date_nanos).
|
|
1635
|
-
|
|
1636
|
-
:param field: Input value. The input can be a single- or multi-valued column
|
|
1637
|
-
or an expression.
|
|
1638
|
-
"""
|
|
1639
|
-
return InstrumentedExpression(f"TO_DATE_NANOS({_render(field)})")
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
2123
|
def to_degrees(number: ExpressionType) -> InstrumentedExpression:
|
|
1643
2124
|
"""Converts a number in radians to degrees).
|
|
1644
2125
|
|
|
@@ -1648,30 +2129,44 @@ def to_degrees(number: ExpressionType) -> InstrumentedExpression:
|
|
|
1648
2129
|
return InstrumentedExpression(f"TO_DEGREES({_render(number)})")
|
|
1649
2130
|
|
|
1650
2131
|
|
|
2132
|
+
def to_dense_vector(field: ExpressionType) -> InstrumentedExpression:
|
|
2133
|
+
"""Converts a multi-valued input of numbers, or a hexadecimal string, to a dense_vector.
|
|
2134
|
+
|
|
2135
|
+
:param field: multi-valued input of numbers or hexadecimal string to convert.
|
|
2136
|
+
"""
|
|
2137
|
+
return InstrumentedExpression(f"TO_DENSE_VECTOR({_render(field)})")
|
|
2138
|
+
|
|
2139
|
+
|
|
1651
2140
|
def to_double(field: ExpressionType) -> InstrumentedExpression:
|
|
1652
2141
|
"""Converts an input value to a double value. If the input parameter is of
|
|
1653
2142
|
a date type, its value will be interpreted as milliseconds since the Unix
|
|
1654
2143
|
epoch, converted to double. Boolean `true` will be converted to double
|
|
1655
2144
|
`1.0`, `false` to `0.0`.
|
|
1656
2145
|
|
|
1657
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1658
|
-
or an expression.
|
|
2146
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2147
|
+
column or an expression.
|
|
1659
2148
|
"""
|
|
1660
2149
|
return InstrumentedExpression(f"TO_DOUBLE({_render(field)})")
|
|
1661
2150
|
|
|
1662
2151
|
|
|
1663
2152
|
def to_geohash(field: ExpressionType) -> InstrumentedExpression:
|
|
1664
|
-
"""Converts an input value to a geohash value. A string will only be
|
|
1665
|
-
converted if it respects the geohash format, as described
|
|
1666
|
-
aggregation.
|
|
2153
|
+
"""Converts an input value to a `geohash` value. A string will only be
|
|
2154
|
+
successfully converted if it respects the `geohash` format, as described
|
|
2155
|
+
for the geohash grid aggregation.
|
|
2156
|
+
|
|
2157
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2158
|
+
column or an expression.
|
|
1667
2159
|
"""
|
|
1668
2160
|
return InstrumentedExpression(f"TO_GEOHASH({_render(field)})")
|
|
1669
2161
|
|
|
1670
2162
|
|
|
1671
2163
|
def to_geohex(field: ExpressionType) -> InstrumentedExpression:
|
|
1672
|
-
"""Converts an input value to a geohex value. A string will only be
|
|
1673
|
-
converted if it respects the geohex format, as described for
|
|
1674
|
-
aggregation.
|
|
2164
|
+
"""Converts an input value to a `geohex` value. A string will only be
|
|
2165
|
+
successfully converted if it respects the `geohex` format, as described for
|
|
2166
|
+
the geohex grid aggregation.
|
|
2167
|
+
|
|
2168
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2169
|
+
column or an expression.
|
|
1675
2170
|
"""
|
|
1676
2171
|
return InstrumentedExpression(f"TO_GEOHEX({_render(field)})")
|
|
1677
2172
|
|
|
@@ -1680,8 +2175,8 @@ def to_geopoint(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1680
2175
|
"""Converts an input value to a `geo_point` value. A string will only be
|
|
1681
2176
|
successfully converted if it respects the WKT Point format.
|
|
1682
2177
|
|
|
1683
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1684
|
-
or an expression.
|
|
2178
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2179
|
+
column or an expression.
|
|
1685
2180
|
"""
|
|
1686
2181
|
return InstrumentedExpression(f"TO_GEOPOINT({_render(field)})")
|
|
1687
2182
|
|
|
@@ -1690,30 +2185,40 @@ def to_geoshape(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1690
2185
|
"""Converts an input value to a `geo_shape` value. A string will only be
|
|
1691
2186
|
successfully converted if it respects the WKT format.
|
|
1692
2187
|
|
|
1693
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1694
|
-
or an expression.
|
|
2188
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2189
|
+
column or an expression.
|
|
1695
2190
|
"""
|
|
1696
2191
|
return InstrumentedExpression(f"TO_GEOSHAPE({_render(field)})")
|
|
1697
2192
|
|
|
1698
2193
|
|
|
1699
2194
|
def to_geotile(field: ExpressionType) -> InstrumentedExpression:
|
|
1700
|
-
"""Converts an input value to a geotile value. A string will only be
|
|
1701
|
-
converted if it respects the geotile format, as described
|
|
1702
|
-
aggregation.
|
|
2195
|
+
"""Converts an input value to a `geotile` value. A string will only be
|
|
2196
|
+
successfully converted if it respects the `geotile` format, as described
|
|
2197
|
+
for the geotile grid aggregation.
|
|
2198
|
+
|
|
2199
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2200
|
+
column or an expression.
|
|
1703
2201
|
"""
|
|
1704
2202
|
return InstrumentedExpression(f"TO_GEOTILE({_render(field)})")
|
|
1705
2203
|
|
|
1706
2204
|
|
|
1707
|
-
def to_integer(
|
|
2205
|
+
def to_integer(
|
|
2206
|
+
field: ExpressionType, base: ExpressionType = None
|
|
2207
|
+
) -> InstrumentedExpression:
|
|
1708
2208
|
"""Converts an input value to an integer value. If the input parameter is
|
|
1709
2209
|
of a date type, its value will be interpreted as milliseconds since the
|
|
1710
2210
|
Unix epoch, converted to integer. Boolean `true` will be converted to
|
|
1711
2211
|
integer `1`, `false` to `0`.
|
|
1712
2212
|
|
|
1713
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1714
|
-
or an expression.
|
|
2213
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2214
|
+
column or an expression.
|
|
2215
|
+
:param base: (Optional) Radix or base used to convert the input value.When
|
|
2216
|
+
a base is specified the input type must be `keyword` or `text`.
|
|
1715
2217
|
"""
|
|
1716
|
-
|
|
2218
|
+
if base is not None:
|
|
2219
|
+
return InstrumentedExpression(f"TO_INTEGER({_render(field)}, {_render(base)})")
|
|
2220
|
+
else:
|
|
2221
|
+
return InstrumentedExpression(f"TO_INTEGER({_render(field)})")
|
|
1717
2222
|
|
|
1718
2223
|
|
|
1719
2224
|
def to_ip(
|
|
@@ -1721,8 +2226,8 @@ def to_ip(
|
|
|
1721
2226
|
) -> InstrumentedExpression:
|
|
1722
2227
|
"""Converts an input string to an IP value.
|
|
1723
2228
|
|
|
1724
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1725
|
-
or an expression.
|
|
2229
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2230
|
+
column or an expression.
|
|
1726
2231
|
:param options: (Optional) Additional options.
|
|
1727
2232
|
"""
|
|
1728
2233
|
if options is not None:
|
|
@@ -1731,24 +2236,30 @@ def to_ip(
|
|
|
1731
2236
|
return InstrumentedExpression(f"TO_IP({_render(field)})")
|
|
1732
2237
|
|
|
1733
2238
|
|
|
1734
|
-
def to_long(
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
2239
|
+
def to_long(
|
|
2240
|
+
field: ExpressionType, base: ExpressionType = None
|
|
2241
|
+
) -> InstrumentedExpression:
|
|
2242
|
+
"""Converts the input value to a long. If the input parameter is of a date
|
|
2243
|
+
type, its value will be interpreted as milliseconds since the Unix epoch,
|
|
2244
|
+
converted to long. Boolean `true` will be converted to long `1`, `false` to `0`.
|
|
1739
2245
|
|
|
1740
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1741
|
-
or an expression.
|
|
2246
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2247
|
+
column or an expression.
|
|
2248
|
+
:param base: (Optional) Radix or base used to convert the input value.When
|
|
2249
|
+
a base is specified the input type must be `keyword` or `text`.
|
|
1742
2250
|
"""
|
|
1743
|
-
|
|
2251
|
+
if base is not None:
|
|
2252
|
+
return InstrumentedExpression(f"TO_LONG({_render(field)}, {_render(base)})")
|
|
2253
|
+
else:
|
|
2254
|
+
return InstrumentedExpression(f"TO_LONG({_render(field)})")
|
|
1744
2255
|
|
|
1745
2256
|
|
|
1746
2257
|
def to_lower(str: ExpressionType) -> InstrumentedExpression:
|
|
1747
2258
|
"""Returns a new string representing the input string converted to lower case.
|
|
1748
2259
|
|
|
1749
2260
|
:param str: String expression. If `null`, the function returns `null`. The
|
|
1750
|
-
input can be a single-valued column or expression, or a
|
|
1751
|
-
column or expression.
|
|
2261
|
+
input can be a single-valued column or expression, or a
|
|
2262
|
+
multi-valued column or expression .
|
|
1752
2263
|
"""
|
|
1753
2264
|
return InstrumentedExpression(f"TO_LOWER({_render(str)})")
|
|
1754
2265
|
|
|
@@ -1765,8 +2276,8 @@ def to_radians(number: ExpressionType) -> InstrumentedExpression:
|
|
|
1765
2276
|
def to_string(field: ExpressionType) -> InstrumentedExpression:
|
|
1766
2277
|
"""Converts an input value into a string.
|
|
1767
2278
|
|
|
1768
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1769
|
-
or an expression.
|
|
2279
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2280
|
+
column or an expression.
|
|
1770
2281
|
"""
|
|
1771
2282
|
return InstrumentedExpression(f"TO_STRING({_render(field)})")
|
|
1772
2283
|
|
|
@@ -1785,8 +2296,8 @@ def to_unsigned_long(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1785
2296
|
since the Unix epoch, converted to unsigned long. Boolean `true` will be
|
|
1786
2297
|
converted to unsigned long `1`, `false` to `0`.
|
|
1787
2298
|
|
|
1788
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1789
|
-
or an expression.
|
|
2299
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2300
|
+
column or an expression.
|
|
1790
2301
|
"""
|
|
1791
2302
|
return InstrumentedExpression(f"TO_UNSIGNED_LONG({_render(field)})")
|
|
1792
2303
|
|
|
@@ -1795,8 +2306,8 @@ def to_upper(str: ExpressionType) -> InstrumentedExpression:
|
|
|
1795
2306
|
"""Returns a new string representing the input string converted to upper case.
|
|
1796
2307
|
|
|
1797
2308
|
:param str: String expression. If `null`, the function returns `null`. The
|
|
1798
|
-
input can be a single-valued column or expression, or a
|
|
1799
|
-
column or expression.
|
|
2309
|
+
input can be a single-valued column or expression, or a
|
|
2310
|
+
multi-valued column or expression .
|
|
1800
2311
|
"""
|
|
1801
2312
|
return InstrumentedExpression(f"TO_UPPER({_render(str)})")
|
|
1802
2313
|
|
|
@@ -1804,12 +2315,72 @@ def to_upper(str: ExpressionType) -> InstrumentedExpression:
|
|
|
1804
2315
|
def to_version(field: ExpressionType) -> InstrumentedExpression:
|
|
1805
2316
|
"""Converts an input string to a version value.
|
|
1806
2317
|
|
|
1807
|
-
:param field: Input value. The input can be a single- or multi-valued
|
|
1808
|
-
or an expression.
|
|
2318
|
+
:param field: Input value. The input can be a single- or multi-valued
|
|
2319
|
+
column or an expression.
|
|
1809
2320
|
"""
|
|
1810
2321
|
return InstrumentedExpression(f"TO_VERSION({_render(field)})")
|
|
1811
2322
|
|
|
1812
2323
|
|
|
2324
|
+
def top(
|
|
2325
|
+
field: ExpressionType,
|
|
2326
|
+
limit: ExpressionType,
|
|
2327
|
+
order: ExpressionType,
|
|
2328
|
+
output_field: ExpressionType = None,
|
|
2329
|
+
) -> InstrumentedExpression:
|
|
2330
|
+
"""Collects the top values for a field. Includes repeated values.
|
|
2331
|
+
|
|
2332
|
+
:param field: The field to collect the top values for.
|
|
2333
|
+
:param limit: The maximum number of values to collect.
|
|
2334
|
+
:param order: The order to calculate the top values. Either `asc` or
|
|
2335
|
+
`desc`, and defaults to `asc` if omitted.
|
|
2336
|
+
:param output_field: The extra field that, if present, will be the output
|
|
2337
|
+
of the TOP call instead of `field`.
|
|
2338
|
+
"""
|
|
2339
|
+
if output_field is None:
|
|
2340
|
+
return InstrumentedExpression(
|
|
2341
|
+
f"TOP({_render(field)}, {_render(limit)}, {_render(order)}, {_render(output_field)})"
|
|
2342
|
+
)
|
|
2343
|
+
else:
|
|
2344
|
+
return InstrumentedExpression(
|
|
2345
|
+
f"TOP({_render(field)}, {_render(limit)}, {_render(order)})"
|
|
2346
|
+
)
|
|
2347
|
+
|
|
2348
|
+
|
|
2349
|
+
def top_snippets(
|
|
2350
|
+
field: ExpressionType, query: ExpressionType, options: ExpressionType
|
|
2351
|
+
) -> InstrumentedExpression:
|
|
2352
|
+
"""Use `TOP_SNIPPETS` to extract the best snippets for a given query string
|
|
2353
|
+
from a text field.
|
|
2354
|
+
|
|
2355
|
+
:param field: The input to chunk.
|
|
2356
|
+
:param query: The input text containing only query terms for snippet
|
|
2357
|
+
extraction. Lucene query syntax, operators, and wildcards are
|
|
2358
|
+
not allowed.
|
|
2359
|
+
:param options: (Optional) `TOP_SNIPPETS` additional options as function
|
|
2360
|
+
named parameters.
|
|
2361
|
+
"""
|
|
2362
|
+
return InstrumentedExpression(
|
|
2363
|
+
f"TOP_SNIPPETS({_render(field)}, {_render(query)}, {_render(options)})"
|
|
2364
|
+
)
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
def trange(
|
|
2368
|
+
start_time_or_offset: ExpressionType, end_time: ExpressionType
|
|
2369
|
+
) -> InstrumentedExpression:
|
|
2370
|
+
"""Filters data for the given time range using the @timestamp attribute.
|
|
2371
|
+
|
|
2372
|
+
:param start_time_or_offset: Offset from NOW for the single parameter
|
|
2373
|
+
mode. Start time for two parameter mode. In
|
|
2374
|
+
two parameter mode, the start time value can
|
|
2375
|
+
be a date string, date, date_nanos or epoch milliseconds.
|
|
2376
|
+
:param end_time: Explicit end time that can be a date string, date,
|
|
2377
|
+
date_nanos or epoch milliseconds.
|
|
2378
|
+
"""
|
|
2379
|
+
return InstrumentedExpression(
|
|
2380
|
+
f"TRANGE({_render(start_time_or_offset)}, {_render(end_time)})"
|
|
2381
|
+
)
|
|
2382
|
+
|
|
2383
|
+
|
|
1813
2384
|
def trim(string: ExpressionType) -> InstrumentedExpression:
|
|
1814
2385
|
"""Removes leading and trailing whitespaces from a string.
|
|
1815
2386
|
|
|
@@ -1818,6 +2389,88 @@ def trim(string: ExpressionType) -> InstrumentedExpression:
|
|
|
1818
2389
|
return InstrumentedExpression(f"TRIM({_render(string)})")
|
|
1819
2390
|
|
|
1820
2391
|
|
|
2392
|
+
def url_decode(string: ExpressionType) -> InstrumentedExpression:
|
|
2393
|
+
"""URL-decodes the input, or returns `null` and adds a warning header to
|
|
2394
|
+
the response if the input cannot be decoded.
|
|
2395
|
+
|
|
2396
|
+
:param string: The URL-encoded string to decode.
|
|
2397
|
+
"""
|
|
2398
|
+
return InstrumentedExpression(f"URL_DECODE({_render(string)})")
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
def url_encode(string: ExpressionType) -> InstrumentedExpression:
|
|
2402
|
+
"""URL-encodes the input. All characters are percent-encoded except for
|
|
2403
|
+
alphanumerics, `.`, `-`, `_`, and `~`. Spaces are encoded as `+`.
|
|
2404
|
+
|
|
2405
|
+
:param string: The URL to encode.
|
|
2406
|
+
"""
|
|
2407
|
+
return InstrumentedExpression(f"URL_ENCODE({_render(string)})")
|
|
2408
|
+
|
|
2409
|
+
|
|
2410
|
+
def url_encode_component(string: ExpressionType) -> InstrumentedExpression:
|
|
2411
|
+
"""URL-encodes the input. All characters are percent-encoded except for
|
|
2412
|
+
alphanumerics, `.`, `-`, `_`, and `~`. Spaces are encoded as `%20`.
|
|
2413
|
+
|
|
2414
|
+
:param string: The URL to encode.
|
|
2415
|
+
"""
|
|
2416
|
+
return InstrumentedExpression(f"URL_ENCODE_COMPONENT({_render(string)})")
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
def v_cosine(left: ExpressionType, right: ExpressionType) -> InstrumentedExpression:
|
|
2420
|
+
"""Calculates the cosine similarity between two dense_vectors.
|
|
2421
|
+
|
|
2422
|
+
:param left: first dense_vector to calculate cosine similarity
|
|
2423
|
+
:param right: second dense_vector to calculate cosine similarity
|
|
2424
|
+
"""
|
|
2425
|
+
return InstrumentedExpression(f"V_COSINE({_render(left)}, {_render(right)})")
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
def v_dot_product(
|
|
2429
|
+
left: ExpressionType, right: ExpressionType
|
|
2430
|
+
) -> InstrumentedExpression:
|
|
2431
|
+
"""Calculates the dot product between two dense_vectors.
|
|
2432
|
+
|
|
2433
|
+
:param left: first dense_vector to calculate dot product similarity
|
|
2434
|
+
:param right: second dense_vector to calculate dot product similarity
|
|
2435
|
+
"""
|
|
2436
|
+
return InstrumentedExpression(f"V_DOT_PRODUCT({_render(left)}, {_render(right)})")
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
def v_hamming(left: ExpressionType, right: ExpressionType) -> InstrumentedExpression:
|
|
2440
|
+
"""Calculates the Hamming distance between two dense vectors.
|
|
2441
|
+
|
|
2442
|
+
:param left: First dense_vector to use to calculate the Hamming distance
|
|
2443
|
+
:param right: Second dense_vector to use to calculate the Hamming distance
|
|
2444
|
+
"""
|
|
2445
|
+
return InstrumentedExpression(f"V_HAMMING({_render(left)}, {_render(right)})")
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
def v_l1_norm(left: ExpressionType, right: ExpressionType) -> InstrumentedExpression:
|
|
2449
|
+
"""Calculates the l1 norm between two dense_vectors.
|
|
2450
|
+
|
|
2451
|
+
:param left: first dense_vector to calculate l1 norm similarity
|
|
2452
|
+
:param right: second dense_vector to calculate l1 norm similarity
|
|
2453
|
+
"""
|
|
2454
|
+
return InstrumentedExpression(f"V_L1_NORM({_render(left)}, {_render(right)})")
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
def v_l2_norm(left: ExpressionType, right: ExpressionType) -> InstrumentedExpression:
|
|
2458
|
+
"""Calculates the l2 norm between two dense_vectors.
|
|
2459
|
+
|
|
2460
|
+
:param left: first dense_vector to calculate l2 norm similarity
|
|
2461
|
+
:param right: second dense_vector to calculate l2 norm similarity
|
|
2462
|
+
"""
|
|
2463
|
+
return InstrumentedExpression(f"V_L2_NORM({_render(left)}, {_render(right)})")
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
def v_magnitude(input: ExpressionType) -> InstrumentedExpression:
|
|
2467
|
+
"""Calculates the magnitude of a dense_vector.
|
|
2468
|
+
|
|
2469
|
+
:param input: dense_vector for which to compute the magnitude
|
|
2470
|
+
"""
|
|
2471
|
+
return InstrumentedExpression(f"V_MAGNITUDE({_render(input)})")
|
|
2472
|
+
|
|
2473
|
+
|
|
1821
2474
|
def values(field: ExpressionType) -> InstrumentedExpression:
|
|
1822
2475
|
"""Returns unique values as a multivalued field. The order of the returned
|
|
1823
2476
|
values isn’t guaranteed. If you need the values returned in order use `MV_SORT`.
|
|
@@ -1827,6 +2480,27 @@ def values(field: ExpressionType) -> InstrumentedExpression:
|
|
|
1827
2480
|
return InstrumentedExpression(f"VALUES({_render(field)})")
|
|
1828
2481
|
|
|
1829
2482
|
|
|
2483
|
+
def variance(number: ExpressionType) -> InstrumentedExpression:
|
|
2484
|
+
"""The population variance of a numeric field.
|
|
2485
|
+
|
|
2486
|
+
:param number:
|
|
2487
|
+
"""
|
|
2488
|
+
return InstrumentedExpression(f"VARIANCE({_render(number)})")
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
def variance_over_time(
|
|
2492
|
+
field: ExpressionType, window: ExpressionType
|
|
2493
|
+
) -> InstrumentedExpression:
|
|
2494
|
+
"""Calculates the population variance over time of a numeric field.
|
|
2495
|
+
|
|
2496
|
+
:param field: the metric field to calculate the value for
|
|
2497
|
+
:param window: the time window over which to compute the variance over time
|
|
2498
|
+
"""
|
|
2499
|
+
return InstrumentedExpression(
|
|
2500
|
+
f"VARIANCE_OVER_TIME({_render(field)}, {_render(window)})"
|
|
2501
|
+
)
|
|
2502
|
+
|
|
2503
|
+
|
|
1830
2504
|
def weighted_avg(
|
|
1831
2505
|
number: ExpressionType, weight: ExpressionType
|
|
1832
2506
|
) -> InstrumentedExpression:
|