elasticsearch 8.17.0__py3-none-any.whl → 8.17.2__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.
Files changed (95) hide show
  1. elasticsearch/__init__.py +2 -2
  2. elasticsearch/_async/client/__init__.py +2034 -740
  3. elasticsearch/_async/client/async_search.py +33 -22
  4. elasticsearch/_async/client/autoscaling.py +27 -21
  5. elasticsearch/_async/client/cat.py +280 -336
  6. elasticsearch/_async/client/ccr.py +96 -70
  7. elasticsearch/_async/client/cluster.py +152 -144
  8. elasticsearch/_async/client/connector.py +488 -55
  9. elasticsearch/_async/client/dangling_indices.py +22 -16
  10. elasticsearch/_async/client/enrich.py +25 -6
  11. elasticsearch/_async/client/eql.py +22 -9
  12. elasticsearch/_async/client/esql.py +295 -3
  13. elasticsearch/_async/client/features.py +25 -25
  14. elasticsearch/_async/client/fleet.py +15 -9
  15. elasticsearch/_async/client/graph.py +9 -8
  16. elasticsearch/_async/client/ilm.py +91 -61
  17. elasticsearch/_async/client/indices.py +746 -324
  18. elasticsearch/_async/client/inference.py +101 -4
  19. elasticsearch/_async/client/ingest.py +231 -19
  20. elasticsearch/_async/client/license.py +48 -31
  21. elasticsearch/_async/client/logstash.py +20 -6
  22. elasticsearch/_async/client/migration.py +25 -7
  23. elasticsearch/_async/client/ml.py +532 -278
  24. elasticsearch/_async/client/monitoring.py +5 -1
  25. elasticsearch/_async/client/nodes.py +46 -30
  26. elasticsearch/_async/client/query_rules.py +65 -18
  27. elasticsearch/_async/client/rollup.py +126 -13
  28. elasticsearch/_async/client/search_application.py +170 -13
  29. elasticsearch/_async/client/searchable_snapshots.py +45 -23
  30. elasticsearch/_async/client/security.py +1299 -340
  31. elasticsearch/_async/client/shutdown.py +43 -15
  32. elasticsearch/_async/client/simulate.py +145 -0
  33. elasticsearch/_async/client/slm.py +163 -19
  34. elasticsearch/_async/client/snapshot.py +288 -23
  35. elasticsearch/_async/client/sql.py +94 -53
  36. elasticsearch/_async/client/ssl.py +16 -17
  37. elasticsearch/_async/client/synonyms.py +67 -26
  38. elasticsearch/_async/client/tasks.py +103 -28
  39. elasticsearch/_async/client/text_structure.py +475 -46
  40. elasticsearch/_async/client/transform.py +108 -72
  41. elasticsearch/_async/client/watcher.py +245 -43
  42. elasticsearch/_async/client/xpack.py +20 -6
  43. elasticsearch/_async/helpers.py +1 -1
  44. elasticsearch/_sync/client/__init__.py +2034 -740
  45. elasticsearch/_sync/client/async_search.py +33 -22
  46. elasticsearch/_sync/client/autoscaling.py +27 -21
  47. elasticsearch/_sync/client/cat.py +280 -336
  48. elasticsearch/_sync/client/ccr.py +96 -70
  49. elasticsearch/_sync/client/cluster.py +152 -144
  50. elasticsearch/_sync/client/connector.py +488 -55
  51. elasticsearch/_sync/client/dangling_indices.py +22 -16
  52. elasticsearch/_sync/client/enrich.py +25 -6
  53. elasticsearch/_sync/client/eql.py +22 -9
  54. elasticsearch/_sync/client/esql.py +295 -3
  55. elasticsearch/_sync/client/features.py +25 -25
  56. elasticsearch/_sync/client/fleet.py +15 -9
  57. elasticsearch/_sync/client/graph.py +9 -8
  58. elasticsearch/_sync/client/ilm.py +91 -61
  59. elasticsearch/_sync/client/indices.py +746 -324
  60. elasticsearch/_sync/client/inference.py +101 -4
  61. elasticsearch/_sync/client/ingest.py +231 -19
  62. elasticsearch/_sync/client/license.py +48 -31
  63. elasticsearch/_sync/client/logstash.py +20 -6
  64. elasticsearch/_sync/client/migration.py +25 -7
  65. elasticsearch/_sync/client/ml.py +532 -278
  66. elasticsearch/_sync/client/monitoring.py +5 -1
  67. elasticsearch/_sync/client/nodes.py +46 -30
  68. elasticsearch/_sync/client/query_rules.py +65 -18
  69. elasticsearch/_sync/client/rollup.py +126 -13
  70. elasticsearch/_sync/client/search_application.py +170 -13
  71. elasticsearch/_sync/client/searchable_snapshots.py +45 -23
  72. elasticsearch/_sync/client/security.py +1299 -340
  73. elasticsearch/_sync/client/shutdown.py +43 -15
  74. elasticsearch/_sync/client/simulate.py +145 -0
  75. elasticsearch/_sync/client/slm.py +163 -19
  76. elasticsearch/_sync/client/snapshot.py +288 -23
  77. elasticsearch/_sync/client/sql.py +94 -53
  78. elasticsearch/_sync/client/ssl.py +16 -17
  79. elasticsearch/_sync/client/synonyms.py +67 -26
  80. elasticsearch/_sync/client/tasks.py +103 -28
  81. elasticsearch/_sync/client/text_structure.py +475 -46
  82. elasticsearch/_sync/client/transform.py +108 -72
  83. elasticsearch/_sync/client/utils.py +1 -1
  84. elasticsearch/_sync/client/watcher.py +245 -43
  85. elasticsearch/_sync/client/xpack.py +20 -6
  86. elasticsearch/_version.py +1 -1
  87. elasticsearch/client.py +4 -0
  88. elasticsearch/helpers/actions.py +1 -1
  89. elasticsearch/helpers/vectorstore/_sync/vectorstore.py +4 -1
  90. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/METADATA +1 -1
  91. elasticsearch-8.17.2.dist-info/RECORD +119 -0
  92. elasticsearch-8.17.0.dist-info/RECORD +0 -117
  93. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/WHEEL +0 -0
  94. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/licenses/LICENSE +0 -0
  95. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/licenses/NOTICE +0 -0
@@ -25,6 +25,370 @@ from .utils import _rewrite_parameters
25
25
 
26
26
  class TextStructureClient(NamespacedClient):
27
27
 
28
+ @_rewrite_parameters()
29
+ def find_field_structure(
30
+ self,
31
+ *,
32
+ field: str,
33
+ index: str,
34
+ column_names: t.Optional[str] = None,
35
+ delimiter: t.Optional[str] = None,
36
+ documents_to_sample: t.Optional[int] = None,
37
+ ecs_compatibility: t.Optional[t.Union[str, t.Literal["disabled", "v1"]]] = None,
38
+ error_trace: t.Optional[bool] = None,
39
+ explain: t.Optional[bool] = None,
40
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
41
+ format: t.Optional[
42
+ t.Union[
43
+ str, t.Literal["delimited", "ndjson", "semi_structured_text", "xml"]
44
+ ]
45
+ ] = None,
46
+ grok_pattern: t.Optional[str] = None,
47
+ human: t.Optional[bool] = None,
48
+ pretty: t.Optional[bool] = None,
49
+ quote: t.Optional[str] = None,
50
+ should_trim_fields: t.Optional[bool] = None,
51
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
52
+ timestamp_field: t.Optional[str] = None,
53
+ timestamp_format: t.Optional[str] = None,
54
+ ) -> ObjectApiResponse[t.Any]:
55
+ """
56
+ .. raw:: html
57
+
58
+ <p>Find the structure of a text field.
59
+ Find the structure of a text field in an Elasticsearch index.</p>
60
+ <p>This API provides a starting point for extracting further information from log messages already ingested into Elasticsearch.
61
+ For example, if you have ingested data into a very simple index that has just <code>@timestamp</code> and message fields, you can use this API to see what common structure exists in the message field.</p>
62
+ <p>The response from the API contains:</p>
63
+ <ul>
64
+ <li>Sample messages.</li>
65
+ <li>Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields.</li>
66
+ <li>Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text.</li>
67
+ <li>Appropriate mappings for an Elasticsearch index, which you could use to ingest the text.</li>
68
+ </ul>
69
+ <p>All this information can be calculated by the structure finder with no guidance.
70
+ However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters.</p>
71
+ <p>If the structure finder produces unexpected results, specify the <code>explain</code> query parameter and an explanation will appear in the response.
72
+ It helps determine why the returned structure was chosen.</p>
73
+
74
+
75
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/find-field-structure.html>`_
76
+
77
+ :param field: The field that should be analyzed.
78
+ :param index: The name of the index that contains the analyzed field.
79
+ :param column_names: If `format` is set to `delimited`, you can specify the column
80
+ names in a comma-separated list. If this parameter is not specified, the
81
+ structure finder uses the column names from the header row of the text. If
82
+ the text does not have a header row, columns are named "column1", "column2",
83
+ "column3", for example.
84
+ :param delimiter: If you have set `format` to `delimited`, you can specify the
85
+ character used to delimit the values in each row. Only a single character
86
+ is supported; the delimiter cannot have multiple characters. By default,
87
+ the API considers the following possibilities: comma, tab, semi-colon, and
88
+ pipe (`|`). In this default scenario, all rows must have the same number
89
+ of fields for the delimited format to be detected. If you specify a delimiter,
90
+ up to 10% of the rows can have a different number of columns than the first
91
+ row.
92
+ :param documents_to_sample: The number of documents to include in the structural
93
+ analysis. The minimum value is 2.
94
+ :param ecs_compatibility: The mode of compatibility with ECS compliant Grok patterns.
95
+ Use this parameter to specify whether to use ECS Grok patterns instead of
96
+ legacy ones when the structure finder creates a Grok pattern. This setting
97
+ primarily has an impact when a whole message Grok pattern such as `%{CATALINALOG}`
98
+ matches the input. If the structure finder identifies a common structure
99
+ but has no idea of the meaning then generic field names such as `path`, `ipaddress`,
100
+ `field1`, and `field2` are used in the `grok_pattern` output. The intention
101
+ in that situation is that a user who knows the meanings will rename the fields
102
+ before using them.
103
+ :param explain: If `true`, the response includes a field named `explanation`,
104
+ which is an array of strings that indicate how the structure finder produced
105
+ its result.
106
+ :param format: The high level structure of the text. By default, the API chooses
107
+ the format. In this default scenario, all rows must have the same number
108
+ of fields for a delimited format to be detected. If the format is set to
109
+ delimited and the delimiter is not set, however, the API tolerates up to
110
+ 5% of rows that have a different number of columns than the first row.
111
+ :param grok_pattern: If the format is `semi_structured_text`, you can specify
112
+ a Grok pattern that is used to extract fields from every message in the text.
113
+ The name of the timestamp field in the Grok pattern must match what is specified
114
+ in the `timestamp_field` parameter. If that parameter is not specified, the
115
+ name of the timestamp field in the Grok pattern must match "timestamp". If
116
+ `grok_pattern` is not specified, the structure finder creates a Grok pattern.
117
+ :param quote: If the format is `delimited`, you can specify the character used
118
+ to quote the values in each row if they contain newlines or the delimiter
119
+ character. Only a single character is supported. If this parameter is not
120
+ specified, the default value is a double quote (`"`). If your delimited text
121
+ format does not use quoting, a workaround is to set this argument to a character
122
+ that does not appear anywhere in the sample.
123
+ :param should_trim_fields: If the format is `delimited`, you can specify whether
124
+ values between delimiters should have whitespace trimmed from them. If this
125
+ parameter is not specified and the delimiter is pipe (`|`), the default value
126
+ is true. Otherwise, the default value is `false`.
127
+ :param timeout: The maximum amount of time that the structure analysis can take.
128
+ If the analysis is still running when the timeout expires, it will be stopped.
129
+ :param timestamp_field: The name of the field that contains the primary timestamp
130
+ of each record in the text. In particular, if the text was ingested into
131
+ an index, this is the field that would be used to populate the `@timestamp`
132
+ field. If the format is `semi_structured_text`, this field must match the
133
+ name of the appropriate extraction in the `grok_pattern`. Therefore, for
134
+ semi-structured text, it is best not to specify this parameter unless `grok_pattern`
135
+ is also specified. For structured text, if you specify this parameter, the
136
+ field must exist within the text. If this parameter is not specified, the
137
+ structure finder makes a decision about which field (if any) is the primary
138
+ timestamp field. For structured text, it is not compulsory to have a timestamp
139
+ in the text.
140
+ :param timestamp_format: The Java time format of the timestamp field in the text.
141
+ Only a subset of Java time format letter groups are supported: * `a` * `d`
142
+ * `dd` * `EEE` * `EEEE` * `H` * `HH` * `h` * `M` * `MM` * `MMM` * `MMMM`
143
+ * `mm` * `ss` * `XX` * `XXX` * `yy` * `yyyy` * `zzz` Additionally `S` letter
144
+ groups (fractional seconds) of length one to nine are supported providing
145
+ they occur after `ss` and are separated from the `ss` by a period (`.`),
146
+ comma (`,`), or colon (`:`). Spacing and punctuation is also permitted with
147
+ the exception a question mark (`?`), newline, and carriage return, together
148
+ with literal text enclosed in single quotes. For example, `MM/dd HH.mm.ss,SSSSSS
149
+ 'in' yyyy` is a valid override format. One valuable use case for this parameter
150
+ is when the format is semi-structured text, there are multiple timestamp
151
+ formats in the text, and you know which format corresponds to the primary
152
+ timestamp, but you do not want to specify the full `grok_pattern`. Another
153
+ is when the timestamp format is one that the structure finder does not consider
154
+ by default. If this parameter is not specified, the structure finder chooses
155
+ the best format from a built-in set. If the special value `null` is specified,
156
+ the structure finder will not look for a primary timestamp in the text. When
157
+ the format is semi-structured text, this will result in the structure finder
158
+ treating the text as single-line messages.
159
+ """
160
+ if field is None:
161
+ raise ValueError("Empty value passed for parameter 'field'")
162
+ if index is None:
163
+ raise ValueError("Empty value passed for parameter 'index'")
164
+ __path_parts: t.Dict[str, str] = {}
165
+ __path = "/_text_structure/find_field_structure"
166
+ __query: t.Dict[str, t.Any] = {}
167
+ if field is not None:
168
+ __query["field"] = field
169
+ if index is not None:
170
+ __query["index"] = index
171
+ if column_names is not None:
172
+ __query["column_names"] = column_names
173
+ if delimiter is not None:
174
+ __query["delimiter"] = delimiter
175
+ if documents_to_sample is not None:
176
+ __query["documents_to_sample"] = documents_to_sample
177
+ if ecs_compatibility is not None:
178
+ __query["ecs_compatibility"] = ecs_compatibility
179
+ if error_trace is not None:
180
+ __query["error_trace"] = error_trace
181
+ if explain is not None:
182
+ __query["explain"] = explain
183
+ if filter_path is not None:
184
+ __query["filter_path"] = filter_path
185
+ if format is not None:
186
+ __query["format"] = format
187
+ if grok_pattern is not None:
188
+ __query["grok_pattern"] = grok_pattern
189
+ if human is not None:
190
+ __query["human"] = human
191
+ if pretty is not None:
192
+ __query["pretty"] = pretty
193
+ if quote is not None:
194
+ __query["quote"] = quote
195
+ if should_trim_fields is not None:
196
+ __query["should_trim_fields"] = should_trim_fields
197
+ if timeout is not None:
198
+ __query["timeout"] = timeout
199
+ if timestamp_field is not None:
200
+ __query["timestamp_field"] = timestamp_field
201
+ if timestamp_format is not None:
202
+ __query["timestamp_format"] = timestamp_format
203
+ __headers = {"accept": "application/json"}
204
+ return self.perform_request( # type: ignore[return-value]
205
+ "GET",
206
+ __path,
207
+ params=__query,
208
+ headers=__headers,
209
+ endpoint_id="text_structure.find_field_structure",
210
+ path_parts=__path_parts,
211
+ )
212
+
213
+ @_rewrite_parameters(
214
+ body_fields=("messages",),
215
+ )
216
+ def find_message_structure(
217
+ self,
218
+ *,
219
+ messages: t.Optional[t.Sequence[str]] = None,
220
+ column_names: t.Optional[str] = None,
221
+ delimiter: t.Optional[str] = None,
222
+ ecs_compatibility: t.Optional[t.Union[str, t.Literal["disabled", "v1"]]] = None,
223
+ error_trace: t.Optional[bool] = None,
224
+ explain: t.Optional[bool] = None,
225
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
226
+ format: t.Optional[
227
+ t.Union[
228
+ str, t.Literal["delimited", "ndjson", "semi_structured_text", "xml"]
229
+ ]
230
+ ] = None,
231
+ grok_pattern: t.Optional[str] = None,
232
+ human: t.Optional[bool] = None,
233
+ pretty: t.Optional[bool] = None,
234
+ quote: t.Optional[str] = None,
235
+ should_trim_fields: t.Optional[bool] = None,
236
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
237
+ timestamp_field: t.Optional[str] = None,
238
+ timestamp_format: t.Optional[str] = None,
239
+ body: t.Optional[t.Dict[str, t.Any]] = None,
240
+ ) -> ObjectApiResponse[t.Any]:
241
+ """
242
+ .. raw:: html
243
+
244
+ <p>Find the structure of text messages.
245
+ Find the structure of a list of text messages.
246
+ The messages must contain data that is suitable to be ingested into Elasticsearch.</p>
247
+ <p>This API provides a starting point for ingesting data into Elasticsearch in a format that is suitable for subsequent use with other Elastic Stack functionality.
248
+ Use this API rather than the find text structure API if your input text has already been split up into separate messages by some other process.</p>
249
+ <p>The response from the API contains:</p>
250
+ <ul>
251
+ <li>Sample messages.</li>
252
+ <li>Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields.</li>
253
+ <li>Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text.
254
+ Appropriate mappings for an Elasticsearch index, which you could use to ingest the text.</li>
255
+ </ul>
256
+ <p>All this information can be calculated by the structure finder with no guidance.
257
+ However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters.</p>
258
+ <p>If the structure finder produces unexpected results, specify the <code>explain</code> query parameter and an explanation will appear in the response.
259
+ It helps determine why the returned structure was chosen.</p>
260
+
261
+
262
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/find-message-structure.html>`_
263
+
264
+ :param messages: The list of messages you want to analyze.
265
+ :param column_names: If the format is `delimited`, you can specify the column
266
+ names in a comma-separated list. If this parameter is not specified, the
267
+ structure finder uses the column names from the header row of the text. If
268
+ the text does not have a header role, columns are named "column1", "column2",
269
+ "column3", for example.
270
+ :param delimiter: If you the format is `delimited`, you can specify the character
271
+ used to delimit the values in each row. Only a single character is supported;
272
+ the delimiter cannot have multiple characters. By default, the API considers
273
+ the following possibilities: comma, tab, semi-colon, and pipe (`|`). In this
274
+ default scenario, all rows must have the same number of fields for the delimited
275
+ format to be detected. If you specify a delimiter, up to 10% of the rows
276
+ can have a different number of columns than the first row.
277
+ :param ecs_compatibility: The mode of compatibility with ECS compliant Grok patterns.
278
+ Use this parameter to specify whether to use ECS Grok patterns instead of
279
+ legacy ones when the structure finder creates a Grok pattern. This setting
280
+ primarily has an impact when a whole message Grok pattern such as `%{CATALINALOG}`
281
+ matches the input. If the structure finder identifies a common structure
282
+ but has no idea of meaning then generic field names such as `path`, `ipaddress`,
283
+ `field1`, and `field2` are used in the `grok_pattern` output, with the intention
284
+ that a user who knows the meanings rename these fields before using it.
285
+ :param explain: If this parameter is set to true, the response includes a field
286
+ named `explanation`, which is an array of strings that indicate how the structure
287
+ finder produced its result.
288
+ :param format: The high level structure of the text. By default, the API chooses
289
+ the format. In this default scenario, all rows must have the same number
290
+ of fields for a delimited format to be detected. If the format is `delimited`
291
+ and the delimiter is not set, however, the API tolerates up to 5% of rows
292
+ that have a different number of columns than the first row.
293
+ :param grok_pattern: If the format is `semi_structured_text`, you can specify
294
+ a Grok pattern that is used to extract fields from every message in the text.
295
+ The name of the timestamp field in the Grok pattern must match what is specified
296
+ in the `timestamp_field` parameter. If that parameter is not specified, the
297
+ name of the timestamp field in the Grok pattern must match "timestamp". If
298
+ `grok_pattern` is not specified, the structure finder creates a Grok pattern.
299
+ :param quote: If the format is `delimited`, you can specify the character used
300
+ to quote the values in each row if they contain newlines or the delimiter
301
+ character. Only a single character is supported. If this parameter is not
302
+ specified, the default value is a double quote (`"`). If your delimited text
303
+ format does not use quoting, a workaround is to set this argument to a character
304
+ that does not appear anywhere in the sample.
305
+ :param should_trim_fields: If the format is `delimited`, you can specify whether
306
+ values between delimiters should have whitespace trimmed from them. If this
307
+ parameter is not specified and the delimiter is pipe (`|`), the default value
308
+ is true. Otherwise, the default value is `false`.
309
+ :param timeout: The maximum amount of time that the structure analysis can take.
310
+ If the analysis is still running when the timeout expires, it will be stopped.
311
+ :param timestamp_field: The name of the field that contains the primary timestamp
312
+ of each record in the text. In particular, if the text was ingested into
313
+ an index, this is the field that would be used to populate the `@timestamp`
314
+ field. If the format is `semi_structured_text`, this field must match the
315
+ name of the appropriate extraction in the `grok_pattern`. Therefore, for
316
+ semi-structured text, it is best not to specify this parameter unless `grok_pattern`
317
+ is also specified. For structured text, if you specify this parameter, the
318
+ field must exist within the text. If this parameter is not specified, the
319
+ structure finder makes a decision about which field (if any) is the primary
320
+ timestamp field. For structured text, it is not compulsory to have a timestamp
321
+ in the text.
322
+ :param timestamp_format: The Java time format of the timestamp field in the text.
323
+ Only a subset of Java time format letter groups are supported: * `a` * `d`
324
+ * `dd` * `EEE` * `EEEE` * `H` * `HH` * `h` * `M` * `MM` * `MMM` * `MMMM`
325
+ * `mm` * `ss` * `XX` * `XXX` * `yy` * `yyyy` * `zzz` Additionally `S` letter
326
+ groups (fractional seconds) of length one to nine are supported providing
327
+ they occur after `ss` and are separated from the `ss` by a period (`.`),
328
+ comma (`,`), or colon (`:`). Spacing and punctuation is also permitted with
329
+ the exception a question mark (`?`), newline, and carriage return, together
330
+ with literal text enclosed in single quotes. For example, `MM/dd HH.mm.ss,SSSSSS
331
+ 'in' yyyy` is a valid override format. One valuable use case for this parameter
332
+ is when the format is semi-structured text, there are multiple timestamp
333
+ formats in the text, and you know which format corresponds to the primary
334
+ timestamp, but you do not want to specify the full `grok_pattern`. Another
335
+ is when the timestamp format is one that the structure finder does not consider
336
+ by default. If this parameter is not specified, the structure finder chooses
337
+ the best format from a built-in set. If the special value `null` is specified,
338
+ the structure finder will not look for a primary timestamp in the text. When
339
+ the format is semi-structured text, this will result in the structure finder
340
+ treating the text as single-line messages.
341
+ """
342
+ if messages is None and body is None:
343
+ raise ValueError("Empty value passed for parameter 'messages'")
344
+ __path_parts: t.Dict[str, str] = {}
345
+ __path = "/_text_structure/find_message_structure"
346
+ __query: t.Dict[str, t.Any] = {}
347
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
348
+ if column_names is not None:
349
+ __query["column_names"] = column_names
350
+ if delimiter is not None:
351
+ __query["delimiter"] = delimiter
352
+ if ecs_compatibility is not None:
353
+ __query["ecs_compatibility"] = ecs_compatibility
354
+ if error_trace is not None:
355
+ __query["error_trace"] = error_trace
356
+ if explain is not None:
357
+ __query["explain"] = explain
358
+ if filter_path is not None:
359
+ __query["filter_path"] = filter_path
360
+ if format is not None:
361
+ __query["format"] = format
362
+ if grok_pattern is not None:
363
+ __query["grok_pattern"] = grok_pattern
364
+ if human is not None:
365
+ __query["human"] = human
366
+ if pretty is not None:
367
+ __query["pretty"] = pretty
368
+ if quote is not None:
369
+ __query["quote"] = quote
370
+ if should_trim_fields is not None:
371
+ __query["should_trim_fields"] = should_trim_fields
372
+ if timeout is not None:
373
+ __query["timeout"] = timeout
374
+ if timestamp_field is not None:
375
+ __query["timestamp_field"] = timestamp_field
376
+ if timestamp_format is not None:
377
+ __query["timestamp_format"] = timestamp_format
378
+ if not __body:
379
+ if messages is not None:
380
+ __body["messages"] = messages
381
+ __headers = {"accept": "application/json", "content-type": "application/json"}
382
+ return self.perform_request( # type: ignore[return-value]
383
+ "POST",
384
+ __path,
385
+ params=__query,
386
+ headers=__headers,
387
+ body=__body,
388
+ endpoint_id="text_structure.find_message_structure",
389
+ path_parts=__path_parts,
390
+ )
391
+
28
392
  @_rewrite_parameters(
29
393
  body_name="text_files",
30
394
  )
@@ -50,47 +414,73 @@ class TextStructureClient(NamespacedClient):
50
414
  timestamp_format: t.Optional[str] = None,
51
415
  ) -> ObjectApiResponse[t.Any]:
52
416
  """
53
- Finds the structure of a text file. The text file must contain data that is suitable
54
- to be ingested into Elasticsearch.
417
+ .. raw:: html
418
+
419
+ <p>Find the structure of a text file.
420
+ The text file must contain data that is suitable to be ingested into Elasticsearch.</p>
421
+ <p>This API provides a starting point for ingesting data into Elasticsearch in a format that is suitable for subsequent use with other Elastic Stack functionality.
422
+ Unlike other Elasticsearch endpoints, the data that is posted to this endpoint does not need to be UTF-8 encoded and in JSON format.
423
+ It must, however, be text; binary text formats are not currently supported.
424
+ The size is limited to the Elasticsearch HTTP receive buffer size, which defaults to 100 Mb.</p>
425
+ <p>The response from the API contains:</p>
426
+ <ul>
427
+ <li>A couple of messages from the beginning of the text.</li>
428
+ <li>Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields.</li>
429
+ <li>Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text.</li>
430
+ <li>Appropriate mappings for an Elasticsearch index, which you could use to ingest the text.</li>
431
+ </ul>
432
+ <p>All this information can be calculated by the structure finder with no guidance.
433
+ However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters.</p>
434
+
55
435
 
56
436
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/find-structure.html>`_
57
437
 
58
438
  :param text_files:
59
- :param charset: The texts character set. It must be a character set that is
60
- supported by the JVM that Elasticsearch uses. For example, UTF-8, UTF-16LE,
61
- windows-1252, or EUC-JP. If this parameter is not specified, the structure
439
+ :param charset: The text's character set. It must be a character set that is
440
+ supported by the JVM that Elasticsearch uses. For example, `UTF-8`, `UTF-16LE`,
441
+ `windows-1252`, or `EUC-JP`. If this parameter is not specified, the structure
62
442
  finder chooses an appropriate character set.
63
- :param column_names: If you have set format to delimited, you can specify the
443
+ :param column_names: If you have set format to `delimited`, you can specify the
64
444
  column names in a comma-separated list. If this parameter is not specified,
65
445
  the structure finder uses the column names from the header row of the text.
66
446
  If the text does not have a header role, columns are named "column1", "column2",
67
- "column3", etc.
68
- :param delimiter: If you have set format to delimited, you can specify the character
69
- used to delimit the values in each row. Only a single character is supported;
70
- the delimiter cannot have multiple characters. By default, the API considers
71
- the following possibilities: comma, tab, semi-colon, and pipe (|). In this
72
- default scenario, all rows must have the same number of fields for the delimited
73
- format to be detected. If you specify a delimiter, up to 10% of the rows
74
- can have a different number of columns than the first row.
75
- :param ecs_compatibility: The mode of compatibility with ECS compliant Grok patterns
76
- (disabled or v1, default: disabled).
77
- :param explain: If this parameter is set to true, the response includes a field
447
+ "column3", for example.
448
+ :param delimiter: If you have set `format` to `delimited`, you can specify the
449
+ character used to delimit the values in each row. Only a single character
450
+ is supported; the delimiter cannot have multiple characters. By default,
451
+ the API considers the following possibilities: comma, tab, semi-colon, and
452
+ pipe (`|`). In this default scenario, all rows must have the same number
453
+ of fields for the delimited format to be detected. If you specify a delimiter,
454
+ up to 10% of the rows can have a different number of columns than the first
455
+ row.
456
+ :param ecs_compatibility: The mode of compatibility with ECS compliant Grok patterns.
457
+ Use this parameter to specify whether to use ECS Grok patterns instead of
458
+ legacy ones when the structure finder creates a Grok pattern. Valid values
459
+ are `disabled` and `v1`. This setting primarily has an impact when a whole
460
+ message Grok pattern such as `%{CATALINALOG}` matches the input. If the structure
461
+ finder identifies a common structure but has no idea of meaning then generic
462
+ field names such as `path`, `ipaddress`, `field1`, and `field2` are used
463
+ in the `grok_pattern` output, with the intention that a user who knows the
464
+ meanings rename these fields before using it.
465
+ :param explain: If this parameter is set to `true`, the response includes a field
78
466
  named explanation, which is an array of strings that indicate how the structure
79
- finder produced its result.
80
- :param format: The high level structure of the text. Valid values are ndjson,
81
- xml, delimited, and semi_structured_text. By default, the API chooses the
82
- format. In this default scenario, all rows must have the same number of fields
83
- for a delimited format to be detected. If the format is set to delimited
84
- and the delimiter is not set, however, the API tolerates up to 5% of rows
85
- that have a different number of columns than the first row.
86
- :param grok_pattern: If you have set format to semi_structured_text, you can
87
- specify a Grok pattern that is used to extract fields from every message
467
+ finder produced its result. If the structure finder produces unexpected results
468
+ for some text, use this query parameter to help you determine why the returned
469
+ structure was chosen.
470
+ :param format: The high level structure of the text. Valid values are `ndjson`,
471
+ `xml`, `delimited`, and `semi_structured_text`. By default, the API chooses
472
+ the format. In this default scenario, all rows must have the same number
473
+ of fields for a delimited format to be detected. If the format is set to
474
+ `delimited` and the delimiter is not set, however, the API tolerates up to
475
+ 5% of rows that have a different number of columns than the first row.
476
+ :param grok_pattern: If you have set `format` to `semi_structured_text`, you
477
+ can specify a Grok pattern that is used to extract fields from every message
88
478
  in the text. The name of the timestamp field in the Grok pattern must match
89
- what is specified in the timestamp_field parameter. If that parameter is
479
+ what is specified in the `timestamp_field` parameter. If that parameter is
90
480
  not specified, the name of the timestamp field in the Grok pattern must match
91
- "timestamp". If grok_pattern is not specified, the structure finder creates
481
+ "timestamp". If `grok_pattern` is not specified, the structure finder creates
92
482
  a Grok pattern.
93
- :param has_header_row: If you have set format to delimited, you can use this
483
+ :param has_header_row: If you have set `format` to `delimited`, you can use this
94
484
  parameter to indicate whether the column names are in the first row of the
95
485
  text. If this parameter is not specified, the structure finder guesses based
96
486
  on the similarity of the first row of the text to other rows.
@@ -100,26 +490,58 @@ class TextStructureClient(NamespacedClient):
100
490
  that this may lead to very long processing times if the way to group lines
101
491
  into messages is misdetected.
102
492
  :param lines_to_sample: The number of lines to include in the structural analysis,
103
- starting from the beginning of the text. The minimum is 2; If the value of
493
+ starting from the beginning of the text. The minimum is 2. If the value of
104
494
  this parameter is greater than the number of lines in the text, the analysis
105
495
  proceeds (as long as there are at least two lines in the text) for all of
106
- the lines.
107
- :param quote: If you have set format to delimited, you can specify the character
496
+ the lines. NOTE: The number of lines and the variation of the lines affects
497
+ the speed of the analysis. For example, if you upload text where the first
498
+ 1000 lines are all variations on the same message, the analysis will find
499
+ more commonality than would be seen with a bigger sample. If possible, however,
500
+ it is more efficient to upload sample text with more variety in the first
501
+ 1000 lines than to request analysis of 100000 lines to achieve some variety.
502
+ :param quote: If you have set `format` to `delimited`, you can specify the character
108
503
  used to quote the values in each row if they contain newlines or the delimiter
109
504
  character. Only a single character is supported. If this parameter is not
110
- specified, the default value is a double quote ("). If your delimited text
505
+ specified, the default value is a double quote (`"`). If your delimited text
111
506
  format does not use quoting, a workaround is to set this argument to a character
112
507
  that does not appear anywhere in the sample.
113
- :param should_trim_fields: If you have set format to delimited, you can specify
508
+ :param should_trim_fields: If you have set `format` to `delimited`, you can specify
114
509
  whether values between delimiters should have whitespace trimmed from them.
115
- If this parameter is not specified and the delimiter is pipe (|), the default
116
- value is true. Otherwise, the default value is false.
117
- :param timeout: Sets the maximum amount of time that the structure analysis make
118
- take. If the analysis is still running when the timeout expires then it will
119
- be aborted.
120
- :param timestamp_field: Optional parameter to specify the timestamp field in
121
- the file
510
+ If this parameter is not specified and the delimiter is pipe (`|`), the default
511
+ value is `true`. Otherwise, the default value is `false`.
512
+ :param timeout: The maximum amount of time that the structure analysis can take.
513
+ If the analysis is still running when the timeout expires then it will be
514
+ stopped.
515
+ :param timestamp_field: The name of the field that contains the primary timestamp
516
+ of each record in the text. In particular, if the text were ingested into
517
+ an index, this is the field that would be used to populate the `@timestamp`
518
+ field. If the `format` is `semi_structured_text`, this field must match the
519
+ name of the appropriate extraction in the `grok_pattern`. Therefore, for
520
+ semi-structured text, it is best not to specify this parameter unless `grok_pattern`
521
+ is also specified. For structured text, if you specify this parameter, the
522
+ field must exist within the text. If this parameter is not specified, the
523
+ structure finder makes a decision about which field (if any) is the primary
524
+ timestamp field. For structured text, it is not compulsory to have a timestamp
525
+ in the text.
122
526
  :param timestamp_format: The Java time format of the timestamp field in the text.
527
+ Only a subset of Java time format letter groups are supported: * `a` * `d`
528
+ * `dd` * `EEE` * `EEEE` * `H` * `HH` * `h` * `M` * `MM` * `MMM` * `MMMM`
529
+ * `mm` * `ss` * `XX` * `XXX` * `yy` * `yyyy` * `zzz` Additionally `S` letter
530
+ groups (fractional seconds) of length one to nine are supported providing
531
+ they occur after `ss` and separated from the `ss` by a `.`, `,` or `:`. Spacing
532
+ and punctuation is also permitted with the exception of `?`, newline and
533
+ carriage return, together with literal text enclosed in single quotes. For
534
+ example, `MM/dd HH.mm.ss,SSSSSS 'in' yyyy` is a valid override format. One
535
+ valuable use case for this parameter is when the format is semi-structured
536
+ text, there are multiple timestamp formats in the text, and you know which
537
+ format corresponds to the primary timestamp, but you do not want to specify
538
+ the full `grok_pattern`. Another is when the timestamp format is one that
539
+ the structure finder does not consider by default. If this parameter is not
540
+ specified, the structure finder chooses the best format from a built-in set.
541
+ If the special value `null` is specified the structure finder will not look
542
+ for a primary timestamp in the text. When the format is semi-structured text
543
+ this will result in the structure finder treating the text as single-line
544
+ messages.
123
545
  """
124
546
  if text_files is None and body is None:
125
547
  raise ValueError(
@@ -191,14 +613,21 @@ class TextStructureClient(NamespacedClient):
191
613
  body: t.Optional[t.Dict[str, t.Any]] = None,
192
614
  ) -> ObjectApiResponse[t.Any]:
193
615
  """
194
- Tests a Grok pattern on some text.
616
+ .. raw:: html
617
+
618
+ <p>Test a Grok pattern.
619
+ Test a Grok pattern on one or more lines of text.
620
+ The API indicates whether the lines match the pattern together with the offsets and lengths of the matched substrings.</p>
621
+
195
622
 
196
623
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/test-grok-pattern.html>`_
197
624
 
198
- :param grok_pattern: Grok pattern to run on the text.
199
- :param text: Lines of text to run the Grok pattern on.
200
- :param ecs_compatibility: The mode of compatibility with ECS compliant Grok patterns
201
- (disabled or v1, default: disabled).
625
+ :param grok_pattern: The Grok pattern to run on the text.
626
+ :param text: The lines of text to run the Grok pattern on.
627
+ :param ecs_compatibility: The mode of compatibility with ECS compliant Grok patterns.
628
+ Use this parameter to specify whether to use ECS Grok patterns instead of
629
+ legacy ones when the structure finder creates a Grok pattern. Valid values
630
+ are `disabled` and `v1`.
202
631
  """
203
632
  if grok_pattern is None and body is None:
204
633
  raise ValueError("Empty value passed for parameter 'grok_pattern'")