@elastic/esql 0.0.1
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.
- package/LICENCE.txt +93 -0
- package/NOTICE.txt +5 -0
- package/README.md +167 -0
- package/lib/__tests__/fixtures.d.ts +4 -0
- package/lib/__tests__/fixtures.d.ts.map +1 -0
- package/lib/ast/builder/builder.d.ts +87 -0
- package/lib/ast/builder/builder.d.ts.map +1 -0
- package/lib/ast/builder/index.d.ts +3 -0
- package/lib/ast/builder/index.d.ts.map +1 -0
- package/lib/ast/builder/types.d.ts +18 -0
- package/lib/ast/builder/types.d.ts.map +1 -0
- package/lib/ast/grouping.d.ts +70 -0
- package/lib/ast/grouping.d.ts.map +1 -0
- package/lib/ast/index.d.ts +9 -0
- package/lib/ast/index.d.ts.map +1 -0
- package/lib/ast/is.d.ts +49 -0
- package/lib/ast/is.d.ts.map +1 -0
- package/lib/ast/location.d.ts +7 -0
- package/lib/ast/location.d.ts.map +1 -0
- package/lib/ast/mutate/commands/from/index.d.ts +4 -0
- package/lib/ast/mutate/commands/from/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/from/metadata.d.ts +63 -0
- package/lib/ast/mutate/commands/from/metadata.d.ts.map +1 -0
- package/lib/ast/mutate/commands/from/sources.d.ts +9 -0
- package/lib/ast/mutate/commands/from/sources.d.ts.map +1 -0
- package/lib/ast/mutate/commands/index.d.ts +9 -0
- package/lib/ast/mutate/commands/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/join/index.d.ts +17 -0
- package/lib/ast/mutate/commands/join/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/limit/index.d.ts +56 -0
- package/lib/ast/mutate/commands/limit/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/rerank/index.d.ts +41 -0
- package/lib/ast/mutate/commands/rerank/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/sort/index.d.ts +117 -0
- package/lib/ast/mutate/commands/sort/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/stats/index.d.ts +17 -0
- package/lib/ast/mutate/commands/stats/index.d.ts.map +1 -0
- package/lib/ast/mutate/commands/where/index.d.ts +48 -0
- package/lib/ast/mutate/commands/where/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/commands/args/index.d.ts +14 -0
- package/lib/ast/mutate/generic/commands/args/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/commands/index.d.ts +54 -0
- package/lib/ast/mutate/generic/commands/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/commands/options/index.d.ts +38 -0
- package/lib/ast/mutate/generic/commands/options/index.d.ts.map +1 -0
- package/lib/ast/mutate/generic/index.d.ts +2 -0
- package/lib/ast/mutate/generic/index.d.ts.map +1 -0
- package/lib/ast/mutate/index.d.ts +5 -0
- package/lib/ast/mutate/index.d.ts.map +1 -0
- package/lib/ast/mutate/types.d.ts +2 -0
- package/lib/ast/mutate/types.d.ts.map +1 -0
- package/lib/ast/mutate/util.d.ts +20 -0
- package/lib/ast/mutate/util.d.ts.map +1 -0
- package/lib/ast/visitor/contexts.d.ts +176 -0
- package/lib/ast/visitor/contexts.d.ts.map +1 -0
- package/lib/ast/visitor/global_visitor_context.d.ts +77 -0
- package/lib/ast/visitor/global_visitor_context.d.ts.map +1 -0
- package/lib/ast/visitor/index.d.ts +5 -0
- package/lib/ast/visitor/index.d.ts.map +1 -0
- package/lib/ast/visitor/types.d.ts +104 -0
- package/lib/ast/visitor/types.d.ts.map +1 -0
- package/lib/ast/visitor/utils.d.ts +26 -0
- package/lib/ast/visitor/utils.d.ts.map +1 -0
- package/lib/ast/visitor/visitor.d.ts +79 -0
- package/lib/ast/visitor/visitor.d.ts.map +1 -0
- package/lib/ast/walker/helpers.d.ts +23 -0
- package/lib/ast/walker/helpers.d.ts.map +1 -0
- package/lib/ast/walker/index.d.ts +2 -0
- package/lib/ast/walker/index.d.ts.map +1 -0
- package/lib/ast/walker/walker.d.ts +266 -0
- package/lib/ast/walker/walker.d.ts.map +1 -0
- package/lib/composer/composer_query.d.ts +684 -0
- package/lib/composer/composer_query.d.ts.map +1 -0
- package/lib/composer/esql.d.ts +25 -0
- package/lib/composer/esql.d.ts.map +1 -0
- package/lib/composer/index.d.ts +8 -0
- package/lib/composer/index.d.ts.map +1 -0
- package/lib/composer/parameter_hole.d.ts +11 -0
- package/lib/composer/parameter_hole.d.ts.map +1 -0
- package/lib/composer/query/index.d.ts +2 -0
- package/lib/composer/query/index.d.ts.map +1 -0
- package/lib/composer/query/query.d.ts +54 -0
- package/lib/composer/query/query.d.ts.map +1 -0
- package/lib/composer/synth/command.d.ts +7 -0
- package/lib/composer/synth/command.d.ts.map +1 -0
- package/lib/composer/synth/expression.d.ts +6 -0
- package/lib/composer/synth/expression.d.ts.map +1 -0
- package/lib/composer/synth/header.d.ts +7 -0
- package/lib/composer/synth/header.d.ts.map +1 -0
- package/lib/composer/synth/holes.d.ts +27 -0
- package/lib/composer/synth/holes.d.ts.map +1 -0
- package/lib/composer/synth/index.d.ts +7 -0
- package/lib/composer/synth/index.d.ts.map +1 -0
- package/lib/composer/synth/nodes.d.ts +104 -0
- package/lib/composer/synth/nodes.d.ts.map +1 -0
- package/lib/composer/synth/query.d.ts +7 -0
- package/lib/composer/synth/query.d.ts.map +1 -0
- package/lib/composer/synth/synth_literal_fragment.d.ts +19 -0
- package/lib/composer/synth/synth_literal_fragment.d.ts.map +1 -0
- package/lib/composer/synth/synth_node.d.ts +19 -0
- package/lib/composer/synth/synth_node.d.ts.map +1 -0
- package/lib/composer/synth/tag.d.ts +4 -0
- package/lib/composer/synth/tag.d.ts.map +1 -0
- package/lib/composer/synth/types.d.ts +65 -0
- package/lib/composer/synth/types.d.ts.map +1 -0
- package/lib/composer/types.d.ts +218 -0
- package/lib/composer/types.d.ts.map +1 -0
- package/lib/composer/util.d.ts +24 -0
- package/lib/composer/util.d.ts.map +1 -0
- package/lib/debug/index.d.ts +2 -0
- package/lib/debug/index.d.ts.map +1 -0
- package/lib/debug/print_ast.d.ts +60 -0
- package/lib/debug/print_ast.d.ts.map +1 -0
- package/lib/embedded_languages/index.d.ts +2 -0
- package/lib/embedded_languages/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/builder/builder.d.ts +52 -0
- package/lib/embedded_languages/promql/ast/builder/builder.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/builder/index.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/builder/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/builder/types.d.ts +12 -0
- package/lib/embedded_languages/promql/ast/builder/types.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/is.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/is.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/traversal.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/traversal.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/walker/index.d.ts +3 -0
- package/lib/embedded_languages/promql/ast/walker/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/walker/types.d.ts +93 -0
- package/lib/embedded_languages/promql/ast/walker/types.d.ts.map +1 -0
- package/lib/embedded_languages/promql/ast/walker/walker.d.ts +43 -0
- package/lib/embedded_languages/promql/ast/walker/walker.d.ts.map +1 -0
- package/lib/embedded_languages/promql/index.d.ts +8 -0
- package/lib/embedded_languages/promql/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts +48 -0
- package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/index.d.ts +4 -0
- package/lib/embedded_languages/promql/parser/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/parser.d.ts +65 -0
- package/lib/embedded_languages/promql/parser/parser.d.ts.map +1 -0
- package/lib/embedded_languages/promql/parser/promql_error_listener.d.ts +11 -0
- package/lib/embedded_languages/promql/parser/promql_error_listener.d.ts.map +1 -0
- package/lib/embedded_languages/promql/pretty_print/basic_pretty_printer.d.ts +65 -0
- package/lib/embedded_languages/promql/pretty_print/basic_pretty_printer.d.ts.map +1 -0
- package/lib/embedded_languages/promql/pretty_print/helpers.d.ts +34 -0
- package/lib/embedded_languages/promql/pretty_print/helpers.d.ts.map +1 -0
- package/lib/embedded_languages/promql/pretty_print/index.d.ts +2 -0
- package/lib/embedded_languages/promql/pretty_print/index.d.ts.map +1 -0
- package/lib/embedded_languages/promql/types.d.ts +355 -0
- package/lib/embedded_languages/promql/types.d.ts.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +63055 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +62941 -0
- package/lib/index.mjs.map +1 -0
- package/lib/parser/antlr/esql_lexer.d.ts +223 -0
- package/lib/parser/antlr/esql_lexer.d.ts.map +1 -0
- package/lib/parser/antlr/esql_parser.d.ts +1847 -0
- package/lib/parser/antlr/esql_parser.d.ts.map +1 -0
- package/lib/parser/antlr/esql_parser_listener.d.ts +1634 -0
- package/lib/parser/antlr/esql_parser_listener.d.ts.map +1 -0
- package/lib/parser/antlr/lexer_config.d.ts +13 -0
- package/lib/parser/antlr/lexer_config.d.ts.map +1 -0
- package/lib/parser/antlr/parser_config.d.ts +7 -0
- package/lib/parser/antlr/parser_config.d.ts.map +1 -0
- package/lib/parser/antlr/promql_lexer.d.ts +71 -0
- package/lib/parser/antlr/promql_lexer.d.ts.map +1 -0
- package/lib/parser/antlr/promql_parser.d.ts +441 -0
- package/lib/parser/antlr/promql_parser.d.ts.map +1 -0
- package/lib/parser/antlr/promql_parser_listener.d.ts +354 -0
- package/lib/parser/antlr/promql_parser_listener.d.ts.map +1 -0
- package/lib/parser/core/constants.d.ts +8 -0
- package/lib/parser/core/constants.d.ts.map +1 -0
- package/lib/parser/core/cst_to_ast_converter.d.ts +262 -0
- package/lib/parser/core/cst_to_ast_converter.d.ts.map +1 -0
- package/lib/parser/core/decorations.d.ts +29 -0
- package/lib/parser/core/decorations.d.ts.map +1 -0
- package/lib/parser/core/esql_error_listener.d.ts +8 -0
- package/lib/parser/core/esql_error_listener.d.ts.map +1 -0
- package/lib/parser/core/helpers.d.ts +9 -0
- package/lib/parser/core/helpers.d.ts.map +1 -0
- package/lib/parser/core/parser.d.ts +136 -0
- package/lib/parser/core/parser.d.ts.map +1 -0
- package/lib/parser/core/tokens.d.ts +45 -0
- package/lib/parser/core/tokens.d.ts.map +1 -0
- package/lib/parser/core/types.d.ts +69 -0
- package/lib/parser/core/types.d.ts.map +1 -0
- package/lib/parser/index.d.ts +4 -0
- package/lib/parser/index.d.ts.map +1 -0
- package/lib/pretty_print/__tests__/fixtures.d.ts +5 -0
- package/lib/pretty_print/__tests__/fixtures.d.ts.map +1 -0
- package/lib/pretty_print/basic_pretty_printer.d.ts +87 -0
- package/lib/pretty_print/basic_pretty_printer.d.ts.map +1 -0
- package/lib/pretty_print/constants.d.ts +47 -0
- package/lib/pretty_print/constants.d.ts.map +1 -0
- package/lib/pretty_print/helpers.d.ts +22 -0
- package/lib/pretty_print/helpers.d.ts.map +1 -0
- package/lib/pretty_print/index.d.ts +4 -0
- package/lib/pretty_print/index.d.ts.map +1 -0
- package/lib/pretty_print/leaf_printer.d.ts +19 -0
- package/lib/pretty_print/leaf_printer.d.ts.map +1 -0
- package/lib/pretty_print/utils.d.ts +7 -0
- package/lib/pretty_print/utils.d.ts.map +1 -0
- package/lib/pretty_print/wrapping_pretty_printer.d.ts +113 -0
- package/lib/pretty_print/wrapping_pretty_printer.d.ts.map +1 -0
- package/lib/types.d.ts +523 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +19 -0
- package/lib/types.js.map +1 -0
- package/lib/types.mjs +1 -0
- package/lib/types.mjs.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import { composerQuerySymbol } from './util';
|
|
2
|
+
import type { ESQLAstExpression, ESQLAstQueryExpression } from '../types';
|
|
3
|
+
import type { ComposerColumnShorthand, ComposerRenameShorthand, ComposerSortShorthand, ComposerSourceShorthand, EsqlRequest, QueryCommandTag } from './types';
|
|
4
|
+
export declare class ComposerQuery {
|
|
5
|
+
readonly ast: ESQLAstQueryExpression;
|
|
6
|
+
protected readonly params: Map<string, unknown>;
|
|
7
|
+
readonly [composerQuerySymbol] = true;
|
|
8
|
+
constructor(ast: ESQLAstQueryExpression, params?: Map<string, unknown>);
|
|
9
|
+
/**
|
|
10
|
+
* Create a template tag function which can be parametrized:
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const more = 42;
|
|
14
|
+
*
|
|
15
|
+
* // Parameter specified as ${{more}} in the template:
|
|
16
|
+
* query.pipe `FROM index | WHERE foo > ${{more}}`;
|
|
17
|
+
*
|
|
18
|
+
* // Parameter specified ahead of the template:
|
|
19
|
+
* query.pipe({more}) `FROM index | WHERE foo > ?more`;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
private readonly _createCommandTag;
|
|
23
|
+
/**
|
|
24
|
+
* Appends a command to the query. This is the generic command appending method,
|
|
25
|
+
* which supports all ES|QL commands. Use it similar to `esql` template tag, but
|
|
26
|
+
* it adds one command at-a-time to the existing query. Use chainable calls to
|
|
27
|
+
* append multiple commands.
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Start a new query with a source command:
|
|
33
|
+
* const query = esql `FROM index`;
|
|
34
|
+
*
|
|
35
|
+
* // Append commands using .pipe:
|
|
36
|
+
* query
|
|
37
|
+
* .pipe `WHERE field > 10`
|
|
38
|
+
* .pipe `LIMIT 100`;
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Safely inline dynamic values using template literal holes:
|
|
42
|
+
*
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const threshold = 10;
|
|
45
|
+
* query.pipe `WHERE field > ${threshold}`;
|
|
46
|
+
* // WHERE field > 10
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Or insert named parameters using `${{param}}` syntax:
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const limit = 100;
|
|
53
|
+
* query.pipe `WHERE field > ${{threshold}} | LIMIT ${{limit}}`;
|
|
54
|
+
* // WHERE field > ?threshold | LIMIT ?limit
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* You can also insert parameters ahead of the template:
|
|
58
|
+
*
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const limit = 100;
|
|
61
|
+
* const threshold = 10;
|
|
62
|
+
* query.pipe({ limit, threshold }) `WHERE field > ?threshold | LIMIT ?limit`;
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Or specify commands as strings, and provide parameters separately:
|
|
66
|
+
*
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const limit = 100;
|
|
69
|
+
* const threshold = 10;
|
|
70
|
+
* query.pipe('WHERE field > ?threshold | LIMIT ?limit', { limit, threshold });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
readonly pipe: QueryCommandTag;
|
|
74
|
+
/**
|
|
75
|
+
* Appends a header command to the query. This is used to add commands like `SET`
|
|
76
|
+
* to the query header. Use it exactly like {@linkcode pipe}, for example:
|
|
77
|
+
*
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const query = esql `FROM index`;
|
|
80
|
+
* query.header `SET x = 10`;
|
|
81
|
+
*
|
|
82
|
+
* query.print(); // "SET x = 10; FROM index"
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
readonly header: QueryCommandTag;
|
|
86
|
+
/**
|
|
87
|
+
* Appends a `CHANGE_POINT` command to detect change points in time series data.
|
|
88
|
+
* Equivalent to calling `.pipe` with a `CHANGE_POINT` command.
|
|
89
|
+
*
|
|
90
|
+
* The `CHANGE_POINT` command is used to identify points in time where the statistical
|
|
91
|
+
* properties of a time series change significantly.
|
|
92
|
+
*
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Basic usage - detect change points in a column
|
|
95
|
+
* query.change_point('metric_value');
|
|
96
|
+
* // Result: CHANGE_POINT metric_value
|
|
97
|
+
*
|
|
98
|
+
* // Specify a key column to group by
|
|
99
|
+
* query.change_point('metric_value', { on: 'timestamp' });
|
|
100
|
+
* // Result: CHANGE_POINT metric_value ON timestamp
|
|
101
|
+
*
|
|
102
|
+
* // Specify output column names for type and p-value
|
|
103
|
+
* query.change_point('metric_value', { as: ['change_type', 'p_value'] });
|
|
104
|
+
* // Result: CHANGE_POINT metric_value AS change_type, p_value
|
|
105
|
+
*
|
|
106
|
+
* // Use all options together
|
|
107
|
+
* query.change_point('metric_value', {
|
|
108
|
+
* on: 'timestamp',
|
|
109
|
+
* as: ['change_type', 'p_value']
|
|
110
|
+
* });
|
|
111
|
+
* // Result: CHANGE_POINT metric_value ON timestamp AS change_type, p_value
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* Columns can be specified as strings or arrays for nested columns:
|
|
115
|
+
*
|
|
116
|
+
* ```typescript
|
|
117
|
+
* query.change_point(['metrics', 'cpu'], {
|
|
118
|
+
* on: ['timestamp', 'field'],
|
|
119
|
+
* as: [['change', 'type'], ['p', 'value']]
|
|
120
|
+
* });
|
|
121
|
+
* // Result: CHANGE_POINT metrics.cpu ON timestamp.field AS change.type, p.value
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @param value The column to analyze for change points. Can be a string
|
|
125
|
+
* column name or an array of column parts for nested columns
|
|
126
|
+
* (e.g., ['metrics', 'cpu'] for 'metrics.cpu').
|
|
127
|
+
* @param options Configuration options for the change point detection.
|
|
128
|
+
* @param options.on Optional column to use as the key for grouping or
|
|
129
|
+
* ordering data. Can be a string or array of column parts.
|
|
130
|
+
* @param options.as Optional tuple specifying the output column names for the change type
|
|
131
|
+
* and p-value. Must be a 2-element array where the first element is the column name
|
|
132
|
+
* for the change type and the second is for the p-value.
|
|
133
|
+
* @returns The updated ComposerQuery instance.
|
|
134
|
+
*/
|
|
135
|
+
readonly change_point: (value: ComposerColumnShorthand, options?: {
|
|
136
|
+
on?: ComposerColumnShorthand;
|
|
137
|
+
as?: [type: ComposerColumnShorthand, pvalue: ComposerColumnShorthand];
|
|
138
|
+
}) => ComposerQuery;
|
|
139
|
+
/**
|
|
140
|
+
* Appends a `DISSECT` command to extract structured data from unstructured text.
|
|
141
|
+
* Equivalent to calling `.pipe` with a `DISSECT` command.
|
|
142
|
+
*
|
|
143
|
+
* The `DISSECT` command uses pattern matching to extract key-value pairs from text
|
|
144
|
+
* fields based on a delimiter-based pattern. It's particularly useful for parsing
|
|
145
|
+
* log entries, CSV data, or other structured text formats.
|
|
146
|
+
*
|
|
147
|
+
* Read more: {@link https://www.elastic.co/docs/reference/query-languages/esql/commands/processing-commands#esql-dissect}.
|
|
148
|
+
*
|
|
149
|
+
* ```typescript
|
|
150
|
+
* // Basic usage - extract fields from a text column
|
|
151
|
+
* query.dissect('message', '%{timestamp} - %{level} - %{msg}');
|
|
152
|
+
* // Result: DISSECT message "%{timestamp} - %{level} - %{msg}"
|
|
153
|
+
*
|
|
154
|
+
* // Extract from nested column
|
|
155
|
+
* query.dissect(['log', 'entry'], '%{date} %{time} [%{level}] %{message}');
|
|
156
|
+
* // Result: DISSECT log.entry "%{date} %{time} [%{level}] %{message}"
|
|
157
|
+
*
|
|
158
|
+
* // Using APPEND_SEPARATOR option
|
|
159
|
+
* query.dissect('data', '%{field1},%{field2},%{field3}', {
|
|
160
|
+
* APPEND_SEPARATOR: ','
|
|
161
|
+
* });
|
|
162
|
+
* // Result: DISSECT data "%{field1},%{field2},%{field3}" APPEND_SEPARATOR = ","
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* Examples with different patterns:
|
|
166
|
+
*
|
|
167
|
+
* ```typescript
|
|
168
|
+
* // CSV-like data
|
|
169
|
+
* query.dissect('csv_data', '%{name},%{age},%{city}');
|
|
170
|
+
*
|
|
171
|
+
* // Log entries with timestamps
|
|
172
|
+
* query.dissect('log_line', '[%{timestamp}] %{level}: %{message}');
|
|
173
|
+
*
|
|
174
|
+
* // Key-value pairs
|
|
175
|
+
* query.dissect('kv_data', 'user=%{user} action=%{action} result=%{result}');
|
|
176
|
+
*
|
|
177
|
+
* // Skip unwanted parts
|
|
178
|
+
* query.dissect('complex_log', '%{date} %{time} %{} [%{level}] %{message}');
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @param input The column containing the text to dissect. Can be a string
|
|
182
|
+
* column name or an array of column parts for nested columns
|
|
183
|
+
* (e.g., ['log', 'message'] for 'log.message').
|
|
184
|
+
* @param pattern The dissect pattern that defines how to extract fields
|
|
185
|
+
* from the input text.
|
|
186
|
+
* @param options Configuration options for the dissect operation.
|
|
187
|
+
* @param options.APPEND_SEPARATOR Optional separator string to use when
|
|
188
|
+
* appending multiple values to the same field name.
|
|
189
|
+
* @returns The updated ComposerQuery instance.
|
|
190
|
+
*/
|
|
191
|
+
readonly dissect: (input: ComposerColumnShorthand, pattern: string, options?: {
|
|
192
|
+
APPEND_SEPARATOR?: string;
|
|
193
|
+
}) => ComposerQuery;
|
|
194
|
+
/**
|
|
195
|
+
* Appends a `GROK` command to extract structured data from unstructured text using patterns.
|
|
196
|
+
* Equivalent to calling `.pipe` with a `GROK` command.
|
|
197
|
+
*
|
|
198
|
+
* The `GROK` command uses regular expression-based patterns to parse and extract fields
|
|
199
|
+
* from text data. It's particularly powerful for parsing log files, as it combines
|
|
200
|
+
* regular expressions with pre-built patterns for common data formats.
|
|
201
|
+
*
|
|
202
|
+
* ```typescript
|
|
203
|
+
* // Basic usage - extract fields using a grok pattern
|
|
204
|
+
* query.grok('message', '%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} %{GREEDYDATA:msg}');
|
|
205
|
+
* // Result: GROK message "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} %{GREEDYDATA:msg}"
|
|
206
|
+
*
|
|
207
|
+
* // Extract from nested column
|
|
208
|
+
* query.grok(['log', 'entry'], '%{COMBINEDAPACHELOG}');
|
|
209
|
+
* // Result: GROK log.entry "%{COMBINEDAPACHELOG}"
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @param input The column containing the text to parse with grok. Can be a
|
|
213
|
+
* string column name or an array of column parts for nested columns
|
|
214
|
+
* (e.g., ['log', 'message'] for 'log.message').
|
|
215
|
+
* @param pattern The grok pattern that defines how to extract and name
|
|
216
|
+
* fields from the input text. Use `%{PATTERN:field_name}` syntax to
|
|
217
|
+
* extract and name fields.
|
|
218
|
+
* @returns The updated ComposerQuery instance.
|
|
219
|
+
*/
|
|
220
|
+
readonly grok: (input: ComposerColumnShorthand, pattern: string) => ComposerQuery;
|
|
221
|
+
/**
|
|
222
|
+
* Appends an `ENRICH` command to add data from an enrich policy to the query
|
|
223
|
+
* results. Equivalent to calling `.pipe` with an `ENRICH` command.
|
|
224
|
+
*
|
|
225
|
+
* The `ENRICH` command allows you to add fields from an enrich policy to your query results
|
|
226
|
+
* based on matching field values. Enrich policies are pre-configured datasets that can be
|
|
227
|
+
* used to supplement your query data with additional context or metadata.
|
|
228
|
+
*
|
|
229
|
+
* See docs: {@link https://www.elastic.co/docs/reference/query-languages/esql/commands/processing-commands#esql-enrich}
|
|
230
|
+
*
|
|
231
|
+
* ```typescript
|
|
232
|
+
* // Basic usage - enrich with a policy
|
|
233
|
+
* query.enrich('user_policy');
|
|
234
|
+
* // Result: ENRICH user_policy
|
|
235
|
+
*
|
|
236
|
+
* // Specify a match field using ON clause
|
|
237
|
+
* query.enrich('geo_policy', { on: 'ip_address' });
|
|
238
|
+
* // Result: ENRICH geo_policy ON ip_address
|
|
239
|
+
*
|
|
240
|
+
* // Select specific fields to add using WITH clause
|
|
241
|
+
* query.enrich('user_policy', {
|
|
242
|
+
* with: {
|
|
243
|
+
* full_name: 'user_name',
|
|
244
|
+
* department: ['org', 'dept']
|
|
245
|
+
* }
|
|
246
|
+
* });
|
|
247
|
+
* // Result: ENRICH user_policy WITH full_name = user_name, department = org.dept
|
|
248
|
+
*
|
|
249
|
+
* // Use both ON and WITH options
|
|
250
|
+
* query.enrich('geo_policy', {
|
|
251
|
+
* on: 'client_ip',
|
|
252
|
+
* with: {
|
|
253
|
+
* country: 'geo_country',
|
|
254
|
+
* city: 'geo_city'
|
|
255
|
+
* }
|
|
256
|
+
* });
|
|
257
|
+
* // Result: ENRICH geo_policy ON client_ip WITH country = geo_country, city = geo_city
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @param policy The name of the enrich policy to use for enrichment.
|
|
261
|
+
* @param options Configuration options for the enrich operation.
|
|
262
|
+
* @param options.on Optional field to match against the enrich policy. Can be a string
|
|
263
|
+
* column name or an array of column parts for nested columns. If not specified,
|
|
264
|
+
* the policy's default match field will be used.
|
|
265
|
+
* @param options.with Optional mapping of output field names to policy field names.
|
|
266
|
+
* Keys are the names for new fields in the result set, values are the field names
|
|
267
|
+
* from the enrich policy to copy. Both keys and values can use nested column syntax.
|
|
268
|
+
* @returns The updated ComposerQuery instance.
|
|
269
|
+
*/
|
|
270
|
+
readonly enrich: (policy: string, options?: {
|
|
271
|
+
on?: ComposerColumnShorthand;
|
|
272
|
+
with?: Record<string, ComposerColumnShorthand>;
|
|
273
|
+
}) => ComposerQuery;
|
|
274
|
+
/**
|
|
275
|
+
* Appends a new `LIMIT` command to the query. Equivalent to calling
|
|
276
|
+
* `.pipe` with a `LIMIT` command.
|
|
277
|
+
*
|
|
278
|
+
* @param limit The limit to apply to the query.
|
|
279
|
+
* @returns The updated ComposerQuery instance.
|
|
280
|
+
*/
|
|
281
|
+
limit: (limit: number) => ComposerQuery;
|
|
282
|
+
/**
|
|
283
|
+
* Appends a new `SAMPLE` command to the query. Equivalent to calling
|
|
284
|
+
* `.pipe` with a `SAMPLE` command.
|
|
285
|
+
*
|
|
286
|
+
* The `SAMPLE` command randomly selects a subset of rows from the result set
|
|
287
|
+
* based on the specified probability. This is useful for quickly analyzing
|
|
288
|
+
* large datasets without processing the entire set of results.
|
|
289
|
+
*
|
|
290
|
+
* ```typescript
|
|
291
|
+
* // Sample approximately 10% of the rows
|
|
292
|
+
* query.sample(0.1);
|
|
293
|
+
* // ... | SAMPLE 0.1 | ...
|
|
294
|
+
*
|
|
295
|
+
* // Sample approximately 50% of the rows
|
|
296
|
+
* query.pipe `SAMPLE ${0.5}`;
|
|
297
|
+
* // ... | SAMPLE 0.5 | ...
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* @param probability A number between 0 and 1 representing the fraction of
|
|
301
|
+
* rows to sample. For example, 0.1 samples approximately 10% of rows,
|
|
302
|
+
* while 0.5 samples approximately 50%.
|
|
303
|
+
* @returns The updated ComposerQuery instance.
|
|
304
|
+
* @throws Error if the probability is not between 0 and 1.
|
|
305
|
+
*/
|
|
306
|
+
sample: (probability: number) => ComposerQuery;
|
|
307
|
+
/**
|
|
308
|
+
* Specifies the columns to keep in the result set. Appends a `KEEP` command.
|
|
309
|
+
* Equivalent to calling `.pipe` with a `KEEP` command.
|
|
310
|
+
*
|
|
311
|
+
* ```typescript
|
|
312
|
+
* query.pipe`KEEP {['order', 'id']}`; // KEEP order.id
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* Columns can be a list of column names. To specify nested columns, use the
|
|
316
|
+
* shorthand syntax `['user', 'name']` for `user.name`.
|
|
317
|
+
*
|
|
318
|
+
* For example:
|
|
319
|
+
*
|
|
320
|
+
* ```typescript
|
|
321
|
+
* query.keep('my-column', ['order', 'id']); // KEEP `my-column`, order.id
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* Column name parts are automatically escaped if they contain special
|
|
325
|
+
* characters.
|
|
326
|
+
*
|
|
327
|
+
* @param column The first column to keep.
|
|
328
|
+
* @param columns Additional columns to keep.
|
|
329
|
+
* @returns The updated ComposerQuery instance.
|
|
330
|
+
*/
|
|
331
|
+
readonly keep: (column: ComposerColumnShorthand, ...columns: Array<ComposerColumnShorthand>) => ComposerQuery;
|
|
332
|
+
/**
|
|
333
|
+
* Specifies the columns to drop from the result set. Appends a `DROP` command.
|
|
334
|
+
* Equivalent to calling `.pipe` with a `DROP` command.
|
|
335
|
+
*
|
|
336
|
+
* ```typescript
|
|
337
|
+
* query.pipe`DROP {['order', 'id']}`; // DROP order.id
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* Columns can be a list of column names. To specify nested columns, use the
|
|
341
|
+
* shorthand syntax `['user', 'name']` for `user.name`.
|
|
342
|
+
*
|
|
343
|
+
* For example:
|
|
344
|
+
*
|
|
345
|
+
* ```typescript
|
|
346
|
+
* query.drop('my-column', ['order', 'id']); // DROP `my-column`, order.id
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* Column name parts are automatically escaped if they contain special
|
|
350
|
+
* characters.
|
|
351
|
+
*
|
|
352
|
+
* @param column The first column to drop.
|
|
353
|
+
* @param columns Additional columns to drop.
|
|
354
|
+
* @returns The updated ComposerQuery instance.
|
|
355
|
+
*/
|
|
356
|
+
readonly drop: (column: ComposerColumnShorthand, ...columns: Array<ComposerColumnShorthand>) => ComposerQuery;
|
|
357
|
+
/**
|
|
358
|
+
* Appends a `MV_EXPAND` command to expand multi-valued fields into multiple
|
|
359
|
+
* rows. Equivalent to calling `.pipe` with a `MV_EXPAND` command.
|
|
360
|
+
*
|
|
361
|
+
* ```typescript
|
|
362
|
+
* query.pipe `MV_EXPAND tags`; // ... | MV_EXPAND tags | ...
|
|
363
|
+
* ```
|
|
364
|
+
*
|
|
365
|
+
* Columns can be specified as strings or arrays for nested columns:
|
|
366
|
+
*
|
|
367
|
+
* ```typescript
|
|
368
|
+
* query.mv_expand(['user', 'roles']); // ... | MV_EXPAND user.roles | ...
|
|
369
|
+
* ```
|
|
370
|
+
* @param column The column to expand.
|
|
371
|
+
* @returns The updated ComposerQuery instance.
|
|
372
|
+
*/
|
|
373
|
+
readonly mv_expand: (column: ComposerColumnShorthand) => ComposerQuery;
|
|
374
|
+
/**
|
|
375
|
+
* Specifies renaming of columns in the result set. Appends a `RENAME` command.
|
|
376
|
+
* Equivalent to calling `.pipe` with a `RENAME` command.
|
|
377
|
+
*
|
|
378
|
+
* ```typescript
|
|
379
|
+
* query.pipe `RENAME foo = bar, baz = qux`;
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* Columns can be specified as strings or arrays for nested columns:
|
|
383
|
+
*
|
|
384
|
+
* ```typescript
|
|
385
|
+
* query.rename(['user', 'name'], 'username');
|
|
386
|
+
* // ... | RENAME user.name = username | ...
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* You can rename multiple columns at once:
|
|
390
|
+
*
|
|
391
|
+
* ```typescript
|
|
392
|
+
* query.rename(
|
|
393
|
+
* ['user', 'name'], 'username',
|
|
394
|
+
* 'addr', ['user', 'address']
|
|
395
|
+
* );
|
|
396
|
+
* // ... | RENAME user.name = username, addr = user.address | ...
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @param expression The first rename expression as a tuple of [newName, oldName].
|
|
400
|
+
* @param expressions Additional rename expressions.
|
|
401
|
+
* @returns The updated ComposerQuery instance.
|
|
402
|
+
*/
|
|
403
|
+
readonly rename: (expression: ComposerRenameShorthand, ...expressions: ComposerRenameShorthand[]) => ComposerQuery;
|
|
404
|
+
/**
|
|
405
|
+
* Specifies the columns to sort by. Appends a `SORT` command. Equivalent to
|
|
406
|
+
* calling `.pipe` with a `SORT` command.
|
|
407
|
+
*
|
|
408
|
+
* ```typescript
|
|
409
|
+
* query.pipe `SORT order.id,
|
|
410
|
+
* order.date DESC, user.name NULLS LAST`;
|
|
411
|
+
* ```
|
|
412
|
+
*
|
|
413
|
+
* Order conditions are specified as a 3-tuple [column, order, nulls].
|
|
414
|
+
* `column` can be specified as a string or as an array of column parts.
|
|
415
|
+
*
|
|
416
|
+
* For example:
|
|
417
|
+
*
|
|
418
|
+
* ```typescript
|
|
419
|
+
* query.sort([['order', 'id'], 'ASC', 'NULLS FIRST']);
|
|
420
|
+
* // SORT order.id ASC NULLS FIRST
|
|
421
|
+
* ```
|
|
422
|
+
*
|
|
423
|
+
* If you your column is not nested, you can simply pass a string:
|
|
424
|
+
*
|
|
425
|
+
* ```typescript
|
|
426
|
+
* query.sort(['column', '', 'NULLS FIRST']); // SORT column NULLS FIRST
|
|
427
|
+
* query.sort('abc'); // SORT abc
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* @param expression The primary sort expression.
|
|
431
|
+
* @param expressions Additional sort expressions.
|
|
432
|
+
* @returns The updated ComposerQuery instance.
|
|
433
|
+
*/
|
|
434
|
+
readonly sort: (expression: ComposerSortShorthand, ...expressions: ComposerSortShorthand[]) => ComposerQuery;
|
|
435
|
+
/**
|
|
436
|
+
* Appends a `LOOKUP JOIN` command to perform a lookup join with another index.
|
|
437
|
+
* Equivalent to calling `.pipe` with a `LOOKUP JOIN` command.
|
|
438
|
+
*
|
|
439
|
+
* The `LOOKUP JOIN` command allows you to enrich your query results by joining
|
|
440
|
+
* data from another index based on matching field values. This is useful for
|
|
441
|
+
* adding context or related information from different datasets.
|
|
442
|
+
*
|
|
443
|
+
* ```typescript
|
|
444
|
+
* // Basic usage - perform a lookup join with another index
|
|
445
|
+
* query.lookup_join('other_index', 'user_id');
|
|
446
|
+
* // Result: ... | LOOKUP JOIN other_index ON user_id | ...
|
|
447
|
+
*
|
|
448
|
+
* // Join on multiple fields
|
|
449
|
+
* query.lookup_join('other_index', 'user_id', 'session_id');
|
|
450
|
+
* // Result: ... | LOOKUP JOIN other_index ON user_id, session_id | ...
|
|
451
|
+
*
|
|
452
|
+
* // Join using a nested column
|
|
453
|
+
* query.lookup_join('other_index', ['user', 'id']);
|
|
454
|
+
* // Result: ... | LOOKUP JOIN other_index ON user.id | ...
|
|
455
|
+
*
|
|
456
|
+
* // Join with an alias
|
|
457
|
+
* query.lookup_join({ index: 'other_index', alias: 'o' }, 'user_id');
|
|
458
|
+
* // Result: ... | LOOKUP JOIN other_index AS o ON user_id | ...
|
|
459
|
+
*
|
|
460
|
+
* // Join using a qualified column
|
|
461
|
+
* query.lookup_join('other_index', ['usersIndex', ['id']]);
|
|
462
|
+
* // Result: ... | LOOKUP JOIN other_index ON [usersIndex].[id] | ...
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* @param lookupIndex The name of the index to join with, or an object with
|
|
466
|
+
* index and alias properties.
|
|
467
|
+
* @param onFieldName The first field to join on. Can be a string column name
|
|
468
|
+
* or an array of column parts for nested columns (e.g., ['user', 'id']
|
|
469
|
+
* for 'user.id').
|
|
470
|
+
* @param onFieldNames Additional fields to join on.
|
|
471
|
+
* @returns The updated ComposerQuery instance.
|
|
472
|
+
*/
|
|
473
|
+
readonly lookup_join: (lookupIndex: ComposerSourceShorthand, onFieldName: ComposerColumnShorthand, ...onFieldNames: Array<ComposerColumnShorthand>) => ComposerQuery;
|
|
474
|
+
/**
|
|
475
|
+
* Appends a `WHERE` command to filter rows based on a condition. Equivalent to
|
|
476
|
+
* calling `.pipe` with a `WHERE` command.
|
|
477
|
+
*
|
|
478
|
+
* ```typescript
|
|
479
|
+
* query.where `foo > 42 AND bar < 24`;
|
|
480
|
+
* ```
|
|
481
|
+
*
|
|
482
|
+
* You can use parameters in the WHERE condition:
|
|
483
|
+
*
|
|
484
|
+
* ```typescript
|
|
485
|
+
* const threshold = 42;
|
|
486
|
+
* query.where `foo > ${{threshold}}`;
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* You can also parametrize the template by providing parameters upfront:
|
|
490
|
+
*
|
|
491
|
+
* ```typescript
|
|
492
|
+
* query.where({threshold: 42}) `foo > ?threshold`;
|
|
493
|
+
* ```
|
|
494
|
+
*
|
|
495
|
+
* Or use string syntax with parameters:
|
|
496
|
+
*
|
|
497
|
+
* ```typescript
|
|
498
|
+
* query.where('foo > ?threshold', {threshold: 42});
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* @param templateOrQuery The WHERE condition as a template literal or string.
|
|
502
|
+
* @param holes Template holes for parameter substitution when using template
|
|
503
|
+
* literals.
|
|
504
|
+
* @returns The updated ComposerQuery instance.
|
|
505
|
+
*/
|
|
506
|
+
readonly where: QueryCommandTag;
|
|
507
|
+
/**
|
|
508
|
+
* Returns a record of all parameters used in the query, where keys are
|
|
509
|
+
* parameter names and values are the corresponding parameter values.
|
|
510
|
+
*/
|
|
511
|
+
getParams(): Record<string, unknown>;
|
|
512
|
+
setParam(name: string, value: unknown): this;
|
|
513
|
+
/**
|
|
514
|
+
* Inlines a parameter by replacing its placeholder with its actual value.
|
|
515
|
+
* This operation modifies the query AST to include the literal value
|
|
516
|
+
* instead of the parameter reference. See {@linkcode inlineParams} for
|
|
517
|
+
* more details.
|
|
518
|
+
*
|
|
519
|
+
* @param name The name of the parameter to inline.
|
|
520
|
+
* @returns The updated ComposerQuery instance.
|
|
521
|
+
* @throws Error if the parameter does not exist or has an unsupported type.
|
|
522
|
+
*/
|
|
523
|
+
inlineParam(name: string): this;
|
|
524
|
+
/**
|
|
525
|
+
* Inlines all parameters in the query by replacing parameter placeholders with
|
|
526
|
+
* their actual values directly in the AST. This operation modifies the query
|
|
527
|
+
* to contain literal values instead of parameter references and clears the
|
|
528
|
+
* parameter map.
|
|
529
|
+
*
|
|
530
|
+
* This method is useful when you want to convert a parameterized query into
|
|
531
|
+
* a static query with all values embedded directly in the query text.
|
|
532
|
+
*
|
|
533
|
+
* ```typescript
|
|
534
|
+
* // Create a parameterized query
|
|
535
|
+
* const query = esql`FROM logs | WHERE user == ${{ userName: 'admin' }} | LIMIT ${{ limit: 100 }}`;
|
|
536
|
+
*
|
|
537
|
+
* console.log(query.print());
|
|
538
|
+
* // FROM logs | WHERE user == ?userName | LIMIT ?limit
|
|
539
|
+
*
|
|
540
|
+
* console.log(query.getParams());
|
|
541
|
+
* // { userName: 'admin', limit: 100 }
|
|
542
|
+
*
|
|
543
|
+
* // Inline all parameters
|
|
544
|
+
* query.inlineParams();
|
|
545
|
+
*
|
|
546
|
+
* console.log(query.print());
|
|
547
|
+
* // FROM logs | WHERE user == "admin" | LIMIT 100
|
|
548
|
+
*
|
|
549
|
+
* console.log(query.getParams());
|
|
550
|
+
* // {} (empty - all parameters have been inlined)
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* **Note:** This operation is irreversible. Once parameters are inlined,
|
|
554
|
+
* they cannot be extracted back into parameter form. The parameter map
|
|
555
|
+
* will be empty after this operation.
|
|
556
|
+
*
|
|
557
|
+
* **Supported parameter types:**
|
|
558
|
+
* - `string` - Converted to string literals
|
|
559
|
+
* - `number` - Converted to numeric literals
|
|
560
|
+
* - `boolean` - Converted to boolean literals
|
|
561
|
+
* - Column (field) names (when used with `??` param syntax)
|
|
562
|
+
* - Nested column name parts (both, `?` and `??` param syntax)
|
|
563
|
+
* - Function names (both, `?` and `??` param syntax)
|
|
564
|
+
*
|
|
565
|
+
* @returns The updated ComposerQuery instance with all parameters inlined.
|
|
566
|
+
* @throws Error if any parameter has an unsupported type that cannot be inlined.
|
|
567
|
+
*/
|
|
568
|
+
inlineParams(): this;
|
|
569
|
+
/**
|
|
570
|
+
* Inserts a SET instruction into the query header.
|
|
571
|
+
*
|
|
572
|
+
* SET instructions are pseudo-commands that set configuration values for the query.
|
|
573
|
+
* They must appear before the main query and are separated by semicolons.
|
|
574
|
+
*
|
|
575
|
+
* ```typescript
|
|
576
|
+
* // Add a single SET instruction
|
|
577
|
+
* query.addSetCommand('a', 'foo');
|
|
578
|
+
* // Result: SET a = "foo"; <original query>
|
|
579
|
+
*
|
|
580
|
+
* // Add multiple SET instructions
|
|
581
|
+
* query.addSetCommand('b', 123);
|
|
582
|
+
* // Result: SET a = "foo"; SET b = 123; <original query>
|
|
583
|
+
* ```
|
|
584
|
+
*
|
|
585
|
+
* @param name The setting name (identifier) to set.
|
|
586
|
+
* @param value The value to assign to the setting (string, number, or boolean).
|
|
587
|
+
* @returns The updated ComposerQuery instance.
|
|
588
|
+
*/
|
|
589
|
+
addSetCommand(name: string, value: string | number | boolean): this;
|
|
590
|
+
/**
|
|
591
|
+
* Removes a SET instruction from the query header by setting name.
|
|
592
|
+
*
|
|
593
|
+
* ```typescript
|
|
594
|
+
* // Remove a specific SET instruction
|
|
595
|
+
* query.removeSetCommand('a');
|
|
596
|
+
* // Removes: SET a = "foo";
|
|
597
|
+
* ```
|
|
598
|
+
*
|
|
599
|
+
* @param name The setting name (identifier) to remove.
|
|
600
|
+
* @returns The updated ComposerQuery instance.
|
|
601
|
+
*/
|
|
602
|
+
removeSetCommand(name: string): this;
|
|
603
|
+
/**
|
|
604
|
+
* Gets all SET instructions from the query header.
|
|
605
|
+
*
|
|
606
|
+
* ```typescript
|
|
607
|
+
* const sets = query.getSetCommands();
|
|
608
|
+
* // Returns: [{ name: 'a', value: 'foo' }, { name: 'b', value: 123 }]
|
|
609
|
+
* ```
|
|
610
|
+
*
|
|
611
|
+
* @returns An array of objects containing the setting name and value pairs.
|
|
612
|
+
*/
|
|
613
|
+
getSetInstructions(): Array<[name: string, value: ESQLAstExpression]>;
|
|
614
|
+
/**
|
|
615
|
+
* Returns a flattened record of all SET instructions from the query header.
|
|
616
|
+
* Values are converted to their native types (string, number, boolean). If
|
|
617
|
+
* an instruction with the same name appears multiple times, the last one
|
|
618
|
+
* takes precedence. (Elasticsearch also uses the last value.)
|
|
619
|
+
*
|
|
620
|
+
* @returns A POJO of flattened set instructions.
|
|
621
|
+
*/
|
|
622
|
+
getSetInstructionRecord(): Record<string, string | number | boolean>;
|
|
623
|
+
/**
|
|
624
|
+
* Removes all SET instructions from the query header.
|
|
625
|
+
*
|
|
626
|
+
* ```typescript
|
|
627
|
+
* query.clearSetCommands();
|
|
628
|
+
* // Removes all: SET a = "foo"; SET b = 123;
|
|
629
|
+
* ```
|
|
630
|
+
*
|
|
631
|
+
* @returns The updated ComposerQuery instance.
|
|
632
|
+
*/
|
|
633
|
+
clearSetCommands(): this;
|
|
634
|
+
/**
|
|
635
|
+
* Prints the query to a string in a specified format.
|
|
636
|
+
*
|
|
637
|
+
* @param format The format of the printed query. Can be 'wrapping' for a
|
|
638
|
+
* more readable format or 'basic' for a single line.
|
|
639
|
+
* @returns The printed query string.
|
|
640
|
+
*/
|
|
641
|
+
print(format?: 'wrapping' | 'basic'): string;
|
|
642
|
+
/**
|
|
643
|
+
* Converts the query to an ESQL request format as an object, which
|
|
644
|
+
* Elasticsearch `POST /_query` API expects.
|
|
645
|
+
*
|
|
646
|
+
* @returns An object representing the ESQL request, including the query string
|
|
647
|
+
* and parameters.
|
|
648
|
+
*/
|
|
649
|
+
toRequest(): EsqlRequest;
|
|
650
|
+
/**
|
|
651
|
+
* Used for debugging and logging purposes, this method provides a
|
|
652
|
+
* string representation of the ComposerQuery instance.
|
|
653
|
+
*
|
|
654
|
+
* Simply cast the `query` instance to a string to get a formatted output.
|
|
655
|
+
*
|
|
656
|
+
* ```typescript
|
|
657
|
+
* const query = esql`
|
|
658
|
+
* FROM kibana_ecommerce_index
|
|
659
|
+
* | WHERE foo > 42 AND bar < 24
|
|
660
|
+
* | EVAL a = 123 | LIMIT 10`;
|
|
661
|
+
*
|
|
662
|
+
* console.log(query + '');
|
|
663
|
+
* // Output:
|
|
664
|
+
* // ComposerQuery
|
|
665
|
+
* // ├─ query
|
|
666
|
+
* // │ └─ FROM kibana_ecommerce_index
|
|
667
|
+
* // │ | WHERE foo > 42 AND bar < 24
|
|
668
|
+
* // │ | EVAL a = 123
|
|
669
|
+
* // │ | LIMIT 10
|
|
670
|
+
* // │
|
|
671
|
+
* // └─ params
|
|
672
|
+
* // └─ {}
|
|
673
|
+
* ```
|
|
674
|
+
*/
|
|
675
|
+
toString(): string;
|
|
676
|
+
dump(options?: ComposerQueryDumpOptions): string;
|
|
677
|
+
}
|
|
678
|
+
export interface ComposerQueryDumpOptions {
|
|
679
|
+
/**
|
|
680
|
+
* Whether to include the AST dump in the output. Default is `true`.
|
|
681
|
+
*/
|
|
682
|
+
ast?: boolean;
|
|
683
|
+
}
|
|
684
|
+
//# sourceMappingURL=composer_query.d.ts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