elasticsearch 8.17.1__py3-none-any.whl → 9.0.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.
Files changed (142) hide show
  1. elasticsearch/__init__.py +2 -2
  2. elasticsearch/_async/client/__init__.py +2125 -1053
  3. elasticsearch/_async/client/_base.py +1 -2
  4. elasticsearch/_async/client/async_search.py +46 -35
  5. elasticsearch/_async/client/autoscaling.py +32 -26
  6. elasticsearch/_async/client/cat.py +244 -176
  7. elasticsearch/_async/client/ccr.py +268 -128
  8. elasticsearch/_async/client/cluster.py +191 -164
  9. elasticsearch/_async/client/connector.py +226 -116
  10. elasticsearch/_async/client/dangling_indices.py +22 -16
  11. elasticsearch/_async/client/enrich.py +51 -11
  12. elasticsearch/_async/client/eql.py +54 -13
  13. elasticsearch/_async/client/esql.py +351 -7
  14. elasticsearch/_async/client/features.py +37 -27
  15. elasticsearch/_async/client/fleet.py +32 -22
  16. elasticsearch/_async/client/graph.py +10 -9
  17. elasticsearch/_async/client/ilm.py +115 -77
  18. elasticsearch/_async/client/indices.py +1119 -772
  19. elasticsearch/_async/client/inference.py +1933 -84
  20. elasticsearch/_async/client/ingest.py +83 -50
  21. elasticsearch/_async/client/license.py +90 -38
  22. elasticsearch/_async/client/logstash.py +20 -9
  23. elasticsearch/_async/client/migration.py +26 -17
  24. elasticsearch/_async/client/ml.py +646 -374
  25. elasticsearch/_async/client/monitoring.py +6 -3
  26. elasticsearch/_async/client/nodes.py +52 -54
  27. elasticsearch/_async/client/query_rules.py +59 -33
  28. elasticsearch/_async/client/rollup.py +124 -86
  29. elasticsearch/_async/client/search_application.py +60 -32
  30. elasticsearch/_async/client/searchable_snapshots.py +25 -12
  31. elasticsearch/_async/client/security.py +903 -562
  32. elasticsearch/_async/client/shutdown.py +34 -36
  33. elasticsearch/_async/client/simulate.py +22 -28
  34. elasticsearch/_async/client/slm.py +65 -40
  35. elasticsearch/_async/client/snapshot.py +454 -327
  36. elasticsearch/_async/client/sql.py +43 -22
  37. elasticsearch/_async/client/ssl.py +17 -18
  38. elasticsearch/_async/client/synonyms.py +58 -37
  39. elasticsearch/_async/client/tasks.py +77 -48
  40. elasticsearch/_async/client/text_structure.py +65 -56
  41. elasticsearch/_async/client/transform.py +124 -93
  42. elasticsearch/_async/client/watcher.py +117 -73
  43. elasticsearch/_async/client/xpack.py +18 -9
  44. elasticsearch/_async/helpers.py +1 -2
  45. elasticsearch/_sync/client/__init__.py +2125 -1053
  46. elasticsearch/_sync/client/_base.py +1 -2
  47. elasticsearch/_sync/client/async_search.py +46 -35
  48. elasticsearch/_sync/client/autoscaling.py +32 -26
  49. elasticsearch/_sync/client/cat.py +244 -176
  50. elasticsearch/_sync/client/ccr.py +268 -128
  51. elasticsearch/_sync/client/cluster.py +191 -164
  52. elasticsearch/_sync/client/connector.py +226 -116
  53. elasticsearch/_sync/client/dangling_indices.py +22 -16
  54. elasticsearch/_sync/client/enrich.py +51 -11
  55. elasticsearch/_sync/client/eql.py +54 -13
  56. elasticsearch/_sync/client/esql.py +351 -7
  57. elasticsearch/_sync/client/features.py +37 -27
  58. elasticsearch/_sync/client/fleet.py +32 -22
  59. elasticsearch/_sync/client/graph.py +10 -9
  60. elasticsearch/_sync/client/ilm.py +115 -77
  61. elasticsearch/_sync/client/indices.py +1119 -772
  62. elasticsearch/_sync/client/inference.py +1933 -84
  63. elasticsearch/_sync/client/ingest.py +83 -50
  64. elasticsearch/_sync/client/license.py +90 -38
  65. elasticsearch/_sync/client/logstash.py +20 -9
  66. elasticsearch/_sync/client/migration.py +26 -17
  67. elasticsearch/_sync/client/ml.py +646 -374
  68. elasticsearch/_sync/client/monitoring.py +6 -3
  69. elasticsearch/_sync/client/nodes.py +52 -54
  70. elasticsearch/_sync/client/query_rules.py +59 -33
  71. elasticsearch/_sync/client/rollup.py +124 -86
  72. elasticsearch/_sync/client/search_application.py +60 -32
  73. elasticsearch/_sync/client/searchable_snapshots.py +25 -12
  74. elasticsearch/_sync/client/security.py +903 -562
  75. elasticsearch/_sync/client/shutdown.py +34 -36
  76. elasticsearch/_sync/client/simulate.py +22 -28
  77. elasticsearch/_sync/client/slm.py +65 -40
  78. elasticsearch/_sync/client/snapshot.py +454 -327
  79. elasticsearch/_sync/client/sql.py +43 -22
  80. elasticsearch/_sync/client/ssl.py +17 -18
  81. elasticsearch/_sync/client/synonyms.py +58 -37
  82. elasticsearch/_sync/client/tasks.py +77 -48
  83. elasticsearch/_sync/client/text_structure.py +65 -56
  84. elasticsearch/_sync/client/transform.py +124 -93
  85. elasticsearch/_sync/client/utils.py +1 -41
  86. elasticsearch/_sync/client/watcher.py +117 -73
  87. elasticsearch/_sync/client/xpack.py +18 -9
  88. elasticsearch/_version.py +1 -1
  89. elasticsearch/client.py +2 -0
  90. elasticsearch/dsl/__init__.py +203 -0
  91. elasticsearch/dsl/_async/__init__.py +16 -0
  92. elasticsearch/dsl/_async/document.py +522 -0
  93. elasticsearch/dsl/_async/faceted_search.py +50 -0
  94. elasticsearch/dsl/_async/index.py +639 -0
  95. elasticsearch/dsl/_async/mapping.py +49 -0
  96. elasticsearch/dsl/_async/search.py +237 -0
  97. elasticsearch/dsl/_async/update_by_query.py +47 -0
  98. elasticsearch/dsl/_sync/__init__.py +16 -0
  99. elasticsearch/dsl/_sync/document.py +514 -0
  100. elasticsearch/dsl/_sync/faceted_search.py +50 -0
  101. elasticsearch/dsl/_sync/index.py +597 -0
  102. elasticsearch/dsl/_sync/mapping.py +49 -0
  103. elasticsearch/dsl/_sync/search.py +230 -0
  104. elasticsearch/dsl/_sync/update_by_query.py +45 -0
  105. elasticsearch/dsl/aggs.py +3734 -0
  106. elasticsearch/dsl/analysis.py +341 -0
  107. elasticsearch/dsl/async_connections.py +37 -0
  108. elasticsearch/dsl/connections.py +142 -0
  109. elasticsearch/dsl/document.py +20 -0
  110. elasticsearch/dsl/document_base.py +444 -0
  111. elasticsearch/dsl/exceptions.py +32 -0
  112. elasticsearch/dsl/faceted_search.py +28 -0
  113. elasticsearch/dsl/faceted_search_base.py +489 -0
  114. elasticsearch/dsl/field.py +4392 -0
  115. elasticsearch/dsl/function.py +180 -0
  116. elasticsearch/dsl/index.py +23 -0
  117. elasticsearch/dsl/index_base.py +178 -0
  118. elasticsearch/dsl/mapping.py +19 -0
  119. elasticsearch/dsl/mapping_base.py +219 -0
  120. elasticsearch/dsl/query.py +2822 -0
  121. elasticsearch/dsl/response/__init__.py +388 -0
  122. elasticsearch/dsl/response/aggs.py +100 -0
  123. elasticsearch/dsl/response/hit.py +53 -0
  124. elasticsearch/dsl/search.py +20 -0
  125. elasticsearch/dsl/search_base.py +1053 -0
  126. elasticsearch/dsl/serializer.py +34 -0
  127. elasticsearch/dsl/types.py +6453 -0
  128. elasticsearch/dsl/update_by_query.py +19 -0
  129. elasticsearch/dsl/update_by_query_base.py +149 -0
  130. elasticsearch/dsl/utils.py +687 -0
  131. elasticsearch/dsl/wrappers.py +144 -0
  132. elasticsearch/helpers/actions.py +1 -1
  133. elasticsearch/helpers/vectorstore/_async/strategies.py +12 -12
  134. elasticsearch/helpers/vectorstore/_sync/strategies.py +12 -12
  135. elasticsearch/helpers/vectorstore/_sync/vectorstore.py +4 -1
  136. {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/METADATA +12 -15
  137. elasticsearch-9.0.0.dist-info/RECORD +160 -0
  138. elasticsearch/transport.py +0 -57
  139. elasticsearch-8.17.1.dist-info/RECORD +0 -119
  140. {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/WHEEL +0 -0
  141. {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/licenses/LICENSE +0 -0
  142. {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/licenses/NOTICE +0 -0
@@ -18,7 +18,6 @@
18
18
 
19
19
  import logging
20
20
  import typing as t
21
- import warnings
22
21
 
23
22
  from elastic_transport import (
24
23
  BaseNode,
@@ -181,37 +180,13 @@ class Elasticsearch(BaseClient):
181
180
  t.Callable[[t.Dict[str, t.Any], NodeConfig], t.Optional[NodeConfig]]
182
181
  ] = None,
183
182
  meta_header: t.Union[DefaultType, bool] = DEFAULT,
184
- timeout: t.Union[DefaultType, None, float] = DEFAULT,
185
- randomize_hosts: t.Union[DefaultType, bool] = DEFAULT,
186
- host_info_callback: t.Optional[
187
- t.Callable[
188
- [t.Dict[str, t.Any], t.Dict[str, t.Union[str, int]]],
189
- t.Optional[t.Dict[str, t.Union[str, int]]],
190
- ]
191
- ] = None,
192
- sniffer_timeout: t.Union[DefaultType, None, float] = DEFAULT,
193
- sniff_on_connection_fail: t.Union[DefaultType, bool] = DEFAULT,
194
183
  http_auth: t.Union[DefaultType, t.Any] = DEFAULT,
195
- maxsize: t.Union[DefaultType, int] = DEFAULT,
196
184
  # Internal use only
197
185
  _transport: t.Optional[Transport] = None,
198
186
  ) -> None:
199
187
  if hosts is None and cloud_id is None and _transport is None:
200
188
  raise ValueError("Either 'hosts' or 'cloud_id' must be specified")
201
189
 
202
- if timeout is not DEFAULT:
203
- if request_timeout is not DEFAULT:
204
- raise ValueError(
205
- "Can't specify both 'timeout' and 'request_timeout', "
206
- "instead only specify 'request_timeout'"
207
- )
208
- warnings.warn(
209
- "The 'timeout' parameter is deprecated in favor of 'request_timeout'",
210
- category=DeprecationWarning,
211
- stacklevel=2,
212
- )
213
- request_timeout = timeout
214
-
215
190
  if serializer is not None:
216
191
  if serializers is not DEFAULT:
217
192
  raise ValueError(
@@ -220,58 +195,6 @@ class Elasticsearch(BaseClient):
220
195
  )
221
196
  serializers = {default_mimetype: serializer}
222
197
 
223
- if randomize_hosts is not DEFAULT:
224
- if randomize_nodes_in_pool is not DEFAULT:
225
- raise ValueError(
226
- "Can't specify both 'randomize_hosts' and 'randomize_nodes_in_pool', "
227
- "instead only specify 'randomize_nodes_in_pool'"
228
- )
229
- warnings.warn(
230
- "The 'randomize_hosts' parameter is deprecated in favor of 'randomize_nodes_in_pool'",
231
- category=DeprecationWarning,
232
- stacklevel=2,
233
- )
234
- randomize_nodes_in_pool = randomize_hosts
235
-
236
- if sniffer_timeout is not DEFAULT:
237
- if min_delay_between_sniffing is not DEFAULT:
238
- raise ValueError(
239
- "Can't specify both 'sniffer_timeout' and 'min_delay_between_sniffing', "
240
- "instead only specify 'min_delay_between_sniffing'"
241
- )
242
- warnings.warn(
243
- "The 'sniffer_timeout' parameter is deprecated in favor of 'min_delay_between_sniffing'",
244
- category=DeprecationWarning,
245
- stacklevel=2,
246
- )
247
- min_delay_between_sniffing = sniffer_timeout
248
-
249
- if sniff_on_connection_fail is not DEFAULT:
250
- if sniff_on_node_failure is not DEFAULT:
251
- raise ValueError(
252
- "Can't specify both 'sniff_on_connection_fail' and 'sniff_on_node_failure', "
253
- "instead only specify 'sniff_on_node_failure'"
254
- )
255
- warnings.warn(
256
- "The 'sniff_on_connection_fail' parameter is deprecated in favor of 'sniff_on_node_failure'",
257
- category=DeprecationWarning,
258
- stacklevel=2,
259
- )
260
- sniff_on_node_failure = sniff_on_connection_fail
261
-
262
- if maxsize is not DEFAULT:
263
- if connections_per_node is not DEFAULT:
264
- raise ValueError(
265
- "Can't specify both 'maxsize' and 'connections_per_node', "
266
- "instead only specify 'connections_per_node'"
267
- )
268
- warnings.warn(
269
- "The 'maxsize' parameter is deprecated in favor of 'connections_per_node'",
270
- category=DeprecationWarning,
271
- stacklevel=2,
272
- )
273
- connections_per_node = maxsize
274
-
275
198
  # Setting min_delay_between_sniffing=True implies sniff_before_requests=True
276
199
  if min_delay_between_sniffing is not DEFAULT:
277
200
  sniff_before_requests = True
@@ -293,22 +216,7 @@ class Elasticsearch(BaseClient):
293
216
  )
294
217
 
295
218
  sniff_callback = None
296
- if host_info_callback is not None:
297
- if sniffed_node_callback is not None:
298
- raise ValueError(
299
- "Can't specify both 'host_info_callback' and 'sniffed_node_callback', "
300
- "instead only specify 'sniffed_node_callback'"
301
- )
302
- warnings.warn(
303
- "The 'host_info_callback' parameter is deprecated in favor of 'sniffed_node_callback'",
304
- category=DeprecationWarning,
305
- stacklevel=2,
306
- )
307
-
308
- sniff_callback = create_sniff_callback(
309
- host_info_callback=host_info_callback
310
- )
311
- elif sniffed_node_callback is not None:
219
+ if sniffed_node_callback is not None:
312
220
  sniff_callback = create_sniff_callback(
313
221
  sniffed_node_callback=sniffed_node_callback
314
222
  )
@@ -626,6 +534,7 @@ class Elasticsearch(BaseClient):
626
534
  error_trace: t.Optional[bool] = None,
627
535
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
628
536
  human: t.Optional[bool] = None,
537
+ include_source_on_error: t.Optional[bool] = None,
629
538
  list_executed_pipelines: t.Optional[bool] = None,
630
539
  pipeline: t.Optional[str] = None,
631
540
  pretty: t.Optional[bool] = None,
@@ -644,89 +553,97 @@ class Elasticsearch(BaseClient):
644
553
  ] = None,
645
554
  ) -> ObjectApiResponse[t.Any]:
646
555
  """
647
- Bulk index or delete documents. Perform multiple `index`, `create`, `delete`,
648
- and `update` actions in a single request. This reduces overhead and can greatly
649
- increase indexing speed. If the Elasticsearch security features are enabled,
650
- you must have the following index privileges for the target data stream, index,
651
- or index alias: * To use the `create` action, you must have the `create_doc`,
652
- `create`, `index`, or `write` index privilege. Data streams support only the
653
- `create` action. * To use the `index` action, you must have the `create`, `index`,
654
- or `write` index privilege. * To use the `delete` action, you must have the `delete`
655
- or `write` index privilege. * To use the `update` action, you must have the `index`
656
- or `write` index privilege. * To automatically create a data stream or index
657
- with a bulk API request, you must have the `auto_configure`, `create_index`,
658
- or `manage` index privilege. * To make the result of a bulk operation visible
659
- to search using the `refresh` parameter, you must have the `maintenance` or `manage`
660
- index privilege. Automatic data stream creation requires a matching index template
661
- with data stream enabled. The actions are specified in the request body using
662
- a newline delimited JSON (NDJSON) structure: ``` action_and_meta_data\\n optional_source\\n
663
- action_and_meta_data\\n optional_source\\n .... action_and_meta_data\\n optional_source\\n
664
- ``` The `index` and `create` actions expect a source on the next line and have
665
- the same semantics as the `op_type` parameter in the standard index API. A `create`
666
- action fails if a document with the same ID already exists in the target An `index`
667
- action adds or replaces a document as necessary. NOTE: Data streams support only
668
- the `create` action. To update or delete a document in a data stream, you must
669
- target the backing index containing the document. An `update` action expects
670
- that the partial doc, upsert, and script and its options are specified on the
671
- next line. A `delete` action does not expect a source on the next line and has
672
- the same semantics as the standard delete API. NOTE: The final line of data must
673
- end with a newline character (`\\n`). Each newline character may be preceded
674
- by a carriage return (`\\r`). When sending NDJSON data to the `_bulk` endpoint,
675
- use a `Content-Type` header of `application/json` or `application/x-ndjson`.
676
- Because this format uses literal newline characters (`\\n`) as delimiters, make
677
- sure that the JSON actions and sources are not pretty printed. If you provide
678
- a target in the request path, it is used for any actions that don't explicitly
679
- specify an `_index` argument. A note on the format: the idea here is to make
680
- processing as fast as possible. As some of the actions are redirected to other
681
- shards on other nodes, only `action_meta_data` is parsed on the receiving node
682
- side. Client libraries using this protocol should try and strive to do something
683
- similar on the client side, and reduce buffering as much as possible. There is
684
- no "correct" number of actions to perform in a single bulk request. Experiment
685
- with different settings to find the optimal size for your particular workload.
686
- Note that Elasticsearch limits the maximum size of a HTTP request to 100mb by
687
- default so clients must ensure that no request exceeds this size. It is not possible
688
- to index a single document that exceeds the size limit, so you must pre-process
689
- any such documents into smaller pieces before sending them to Elasticsearch.
690
- For instance, split documents into pages or chapters before indexing them, or
691
- store raw binary data in a system outside Elasticsearch and replace the raw data
692
- with a link to the external system in the documents that you send to Elasticsearch.
693
- **Client suppport for bulk requests** Some of the officially supported clients
694
- provide helpers to assist with bulk requests and reindexing: * Go: Check out
695
- `esutil.BulkIndexer` * Perl: Check out `Search::Elasticsearch::Client::5_0::Bulk`
696
- and `Search::Elasticsearch::Client::5_0::Scroll` * Python: Check out `elasticsearch.helpers.*`
697
- * JavaScript: Check out `client.helpers.*` * .NET: Check out `BulkAllObservable`
698
- * PHP: Check out bulk indexing. **Submitting bulk requests with cURL** If you're
699
- providing text file input to `curl`, you must use the `--data-binary` flag instead
700
- of plain `-d`. The latter doesn't preserve newlines. For example: ``` $ cat requests
701
- { "index" : { "_index" : "test", "_id" : "1" } } { "field1" : "value1" } $ curl
702
- -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary
703
- "@requests"; echo {"took":7, "errors": false, "items":[{"index":{"_index":"test","_id":"1","_version":1,"result":"created","forced_refresh":false}}]}
704
- ``` **Optimistic concurrency control** Each `index` and `delete` action within
705
- a bulk API call may include the `if_seq_no` and `if_primary_term` parameters
706
- in their respective action and meta data lines. The `if_seq_no` and `if_primary_term`
707
- parameters control how operations are run, based on the last modification to
708
- existing documents. See Optimistic concurrency control for more details. **Versioning**
709
- Each bulk item can include the version value using the `version` field. It automatically
710
- follows the behavior of the index or delete operation based on the `_version`
711
- mapping. It also support the `version_type`. **Routing** Each bulk item can include
712
- the routing value using the `routing` field. It automatically follows the behavior
713
- of the index or delete operation based on the `_routing` mapping. NOTE: Data
714
- streams do not support custom routing unless they were created with the `allow_custom_routing`
715
- setting enabled in the template. **Wait for active shards** When making bulk
716
- calls, you can set the `wait_for_active_shards` parameter to require a minimum
717
- number of shard copies to be active before starting to process the bulk request.
718
- **Refresh** Control when the changes made by this request are visible to search.
719
- NOTE: Only the shards that receive the bulk request will be affected by refresh.
720
- Imagine a `_bulk?refresh=wait_for` request with three documents in it that happen
721
- to be routed to different shards in an index with five shards. The request will
722
- only wait for those three shards to refresh. The other two shards that make up
723
- the index do not participate in the `_bulk` request at all.
724
-
725
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-bulk.html>`_
556
+ .. raw:: html
557
+
558
+ <p>Bulk index or delete documents.
559
+ Perform multiple <code>index</code>, <code>create</code>, <code>delete</code>, and <code>update</code> actions in a single request.
560
+ This reduces overhead and can greatly increase indexing speed.</p>
561
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
562
+ <ul>
563
+ <li>To use the <code>create</code> action, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege. Data streams support only the <code>create</code> action.</li>
564
+ <li>To use the <code>index</code> action, you must have the <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
565
+ <li>To use the <code>delete</code> action, you must have the <code>delete</code> or <code>write</code> index privilege.</li>
566
+ <li>To use the <code>update</code> action, you must have the <code>index</code> or <code>write</code> index privilege.</li>
567
+ <li>To automatically create a data stream or index with a bulk API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
568
+ <li>To make the result of a bulk operation visible to search using the <code>refresh</code> parameter, you must have the <code>maintenance</code> or <code>manage</code> index privilege.</li>
569
+ </ul>
570
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
571
+ <p>The actions are specified in the request body using a newline delimited JSON (NDJSON) structure:</p>
572
+ <pre><code>action_and_meta_data\\n
573
+ optional_source\\n
574
+ action_and_meta_data\\n
575
+ optional_source\\n
576
+ ....
577
+ action_and_meta_data\\n
578
+ optional_source\\n
579
+ </code></pre>
580
+ <p>The <code>index</code> and <code>create</code> actions expect a source on the next line and have the same semantics as the <code>op_type</code> parameter in the standard index API.
581
+ A <code>create</code> action fails if a document with the same ID already exists in the target
582
+ An <code>index</code> action adds or replaces a document as necessary.</p>
583
+ <p>NOTE: Data streams support only the <code>create</code> action.
584
+ To update or delete a document in a data stream, you must target the backing index containing the document.</p>
585
+ <p>An <code>update</code> action expects that the partial doc, upsert, and script and its options are specified on the next line.</p>
586
+ <p>A <code>delete</code> action does not expect a source on the next line and has the same semantics as the standard delete API.</p>
587
+ <p>NOTE: The final line of data must end with a newline character (<code>\\n</code>).
588
+ Each newline character may be preceded by a carriage return (<code>\\r</code>).
589
+ When sending NDJSON data to the <code>_bulk</code> endpoint, use a <code>Content-Type</code> header of <code>application/json</code> or <code>application/x-ndjson</code>.
590
+ Because this format uses literal newline characters (<code>\\n</code>) as delimiters, make sure that the JSON actions and sources are not pretty printed.</p>
591
+ <p>If you provide a target in the request path, it is used for any actions that don't explicitly specify an <code>_index</code> argument.</p>
592
+ <p>A note on the format: the idea here is to make processing as fast as possible.
593
+ As some of the actions are redirected to other shards on other nodes, only <code>action_meta_data</code> is parsed on the receiving node side.</p>
594
+ <p>Client libraries using this protocol should try and strive to do something similar on the client side, and reduce buffering as much as possible.</p>
595
+ <p>There is no &quot;correct&quot; number of actions to perform in a single bulk request.
596
+ Experiment with different settings to find the optimal size for your particular workload.
597
+ Note that Elasticsearch limits the maximum size of a HTTP request to 100mb by default so clients must ensure that no request exceeds this size.
598
+ It is not possible to index a single document that exceeds the size limit, so you must pre-process any such documents into smaller pieces before sending them to Elasticsearch.
599
+ For instance, split documents into pages or chapters before indexing them, or store raw binary data in a system outside Elasticsearch and replace the raw data with a link to the external system in the documents that you send to Elasticsearch.</p>
600
+ <p><strong>Client suppport for bulk requests</strong></p>
601
+ <p>Some of the officially supported clients provide helpers to assist with bulk requests and reindexing:</p>
602
+ <ul>
603
+ <li>Go: Check out <code>esutil.BulkIndexer</code></li>
604
+ <li>Perl: Check out <code>Search::Elasticsearch::Client::5_0::Bulk</code> and <code>Search::Elasticsearch::Client::5_0::Scroll</code></li>
605
+ <li>Python: Check out <code>elasticsearch.helpers.*</code></li>
606
+ <li>JavaScript: Check out <code>client.helpers.*</code></li>
607
+ <li>.NET: Check out <code>BulkAllObservable</code></li>
608
+ <li>PHP: Check out bulk indexing.</li>
609
+ </ul>
610
+ <p><strong>Submitting bulk requests with cURL</strong></p>
611
+ <p>If you're providing text file input to <code>curl</code>, you must use the <code>--data-binary</code> flag instead of plain <code>-d</code>.
612
+ The latter doesn't preserve newlines. For example:</p>
613
+ <pre><code>$ cat requests
614
+ { &quot;index&quot; : { &quot;_index&quot; : &quot;test&quot;, &quot;_id&quot; : &quot;1&quot; } }
615
+ { &quot;field1&quot; : &quot;value1&quot; }
616
+ $ curl -s -H &quot;Content-Type: application/x-ndjson&quot; -XPOST localhost:9200/_bulk --data-binary &quot;@requests&quot;; echo
617
+ {&quot;took&quot;:7, &quot;errors&quot;: false, &quot;items&quot;:[{&quot;index&quot;:{&quot;_index&quot;:&quot;test&quot;,&quot;_id&quot;:&quot;1&quot;,&quot;_version&quot;:1,&quot;result&quot;:&quot;created&quot;,&quot;forced_refresh&quot;:false}}]}
618
+ </code></pre>
619
+ <p><strong>Optimistic concurrency control</strong></p>
620
+ <p>Each <code>index</code> and <code>delete</code> action within a bulk API call may include the <code>if_seq_no</code> and <code>if_primary_term</code> parameters in their respective action and meta data lines.
621
+ The <code>if_seq_no</code> and <code>if_primary_term</code> parameters control how operations are run, based on the last modification to existing documents. See Optimistic concurrency control for more details.</p>
622
+ <p><strong>Versioning</strong></p>
623
+ <p>Each bulk item can include the version value using the <code>version</code> field.
624
+ It automatically follows the behavior of the index or delete operation based on the <code>_version</code> mapping.
625
+ It also support the <code>version_type</code>.</p>
626
+ <p><strong>Routing</strong></p>
627
+ <p>Each bulk item can include the routing value using the <code>routing</code> field.
628
+ It automatically follows the behavior of the index or delete operation based on the <code>_routing</code> mapping.</p>
629
+ <p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
630
+ <p><strong>Wait for active shards</strong></p>
631
+ <p>When making bulk calls, you can set the <code>wait_for_active_shards</code> parameter to require a minimum number of shard copies to be active before starting to process the bulk request.</p>
632
+ <p><strong>Refresh</strong></p>
633
+ <p>Control when the changes made by this request are visible to search.</p>
634
+ <p>NOTE: Only the shards that receive the bulk request will be affected by refresh.
635
+ Imagine a <code>_bulk?refresh=wait_for</code> request with three documents in it that happen to be routed to different shards in an index with five shards.
636
+ The request will only wait for those three shards to refresh.
637
+ The other two shards that make up the index do not participate in the <code>_bulk</code> request at all.</p>
638
+
639
+
640
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-bulk>`_
726
641
 
727
642
  :param operations:
728
643
  :param index: The name of the data stream, index, or index alias to perform bulk
729
644
  actions on.
645
+ :param include_source_on_error: True or false if to include the document source
646
+ in the error message in case of parsing errors.
730
647
  :param list_executed_pipelines: If `true`, the response will include the ingest
731
648
  pipelines that were run for each index or create.
732
649
  :param pipeline: The pipeline identifier to use to preprocess incoming documents.
@@ -784,6 +701,8 @@ class Elasticsearch(BaseClient):
784
701
  __query["filter_path"] = filter_path
785
702
  if human is not None:
786
703
  __query["human"] = human
704
+ if include_source_on_error is not None:
705
+ __query["include_source_on_error"] = include_source_on_error
787
706
  if list_executed_pipelines is not None:
788
707
  __query["list_executed_pipelines"] = list_executed_pipelines
789
708
  if pipeline is not None:
@@ -837,10 +756,13 @@ class Elasticsearch(BaseClient):
837
756
  body: t.Optional[t.Dict[str, t.Any]] = None,
838
757
  ) -> ObjectApiResponse[t.Any]:
839
758
  """
840
- Clear a scrolling search. Clear the search context and results for a scrolling
841
- search.
759
+ .. raw:: html
760
+
761
+ <p>Clear a scrolling search.
762
+ Clear the search context and results for a scrolling search.</p>
763
+
842
764
 
843
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/clear-scroll-api.html>`_
765
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-clear-scroll>`_
844
766
 
845
767
  :param scroll_id: The scroll IDs to clear. To clear all scroll IDs, use `_all`.
846
768
  """
@@ -888,13 +810,16 @@ class Elasticsearch(BaseClient):
888
810
  body: t.Optional[t.Dict[str, t.Any]] = None,
889
811
  ) -> ObjectApiResponse[t.Any]:
890
812
  """
891
- Close a point in time. A point in time must be opened explicitly before being
892
- used in search requests. The `keep_alive` parameter tells Elasticsearch how long
893
- it should persist. A point in time is automatically closed when the `keep_alive`
894
- period has elapsed. However, keeping points in time has a cost; close them as
895
- soon as they are no longer required for search requests.
813
+ .. raw:: html
896
814
 
897
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
815
+ <p>Close a point in time.
816
+ A point in time must be opened explicitly before being used in search requests.
817
+ The <code>keep_alive</code> parameter tells Elasticsearch how long it should persist.
818
+ A point in time is automatically closed when the <code>keep_alive</code> period has elapsed.
819
+ However, keeping points in time has a cost; close them as soon as they are no longer required for search requests.</p>
820
+
821
+
822
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-open-point-in-time>`_
898
823
 
899
824
  :param id: The ID of the point-in-time.
900
825
  """
@@ -966,16 +891,19 @@ class Elasticsearch(BaseClient):
966
891
  body: t.Optional[t.Dict[str, t.Any]] = None,
967
892
  ) -> ObjectApiResponse[t.Any]:
968
893
  """
969
- Count search results. Get the number of documents matching a query. The query
970
- can either be provided using a simple query string as a parameter or using the
971
- Query DSL defined within the request body. The latter must be nested in a `query`
972
- key, which is the same as the search API. The count API supports multi-target
973
- syntax. You can run a single count API search across multiple data streams and
974
- indices. The operation is broadcast across all shards. For each shard ID group,
975
- a replica is chosen and the search is run against it. This means that replicas
976
- increase the scalability of the count.
894
+ .. raw:: html
895
+
896
+ <p>Count search results.
897
+ Get the number of documents matching a query.</p>
898
+ <p>The query can be provided either by using a simple query string as a parameter, or by defining Query DSL within the request body.
899
+ The query is optional. When no query is provided, the API uses <code>match_all</code> to count all the documents.</p>
900
+ <p>The count API supports multi-target syntax. You can run a single count API search across multiple data streams and indices.</p>
901
+ <p>The operation is broadcast across all shards.
902
+ For each shard ID group, a replica is chosen and the search is run against it.
903
+ This means that replicas increase the scalability of the count.</p>
904
+
977
905
 
978
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-count.html>`_
906
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-count>`_
979
907
 
980
908
  :param index: A comma-separated list of data streams, indices, and aliases to
981
909
  search. It supports wildcards (`*`). To search all data streams and indices,
@@ -1010,10 +938,10 @@ class Elasticsearch(BaseClient):
1010
938
  in the result.
1011
939
  :param preference: The node or shard the operation should be performed on. By
1012
940
  default, it is random.
1013
- :param q: The query in Lucene query string syntax.
1014
- :param query: Defines the search definition using the Query DSL. The query is
1015
- optional, and when not provided, it will use `match_all` to count all the
1016
- docs.
941
+ :param q: The query in Lucene query string syntax. This parameter cannot be used
942
+ with a request body.
943
+ :param query: Defines the search query using Query DSL. A request body query
944
+ cannot be used with the `q` query string parameter.
1017
945
  :param routing: A custom value used to route operations to a specific shard.
1018
946
  :param terminate_after: The maximum number of documents to collect for each shard.
1019
947
  If a query reaches this limit, Elasticsearch terminates the query early.
@@ -1099,11 +1027,17 @@ class Elasticsearch(BaseClient):
1099
1027
  error_trace: t.Optional[bool] = None,
1100
1028
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1101
1029
  human: t.Optional[bool] = None,
1030
+ if_primary_term: t.Optional[int] = None,
1031
+ if_seq_no: t.Optional[int] = None,
1032
+ include_source_on_error: t.Optional[bool] = None,
1033
+ op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
1102
1034
  pipeline: t.Optional[str] = None,
1103
1035
  pretty: t.Optional[bool] = None,
1104
1036
  refresh: t.Optional[
1105
1037
  t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1106
1038
  ] = None,
1039
+ require_alias: t.Optional[bool] = None,
1040
+ require_data_stream: t.Optional[bool] = None,
1107
1041
  routing: t.Optional[str] = None,
1108
1042
  timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1109
1043
  version: t.Optional[int] = None,
@@ -1115,38 +1049,115 @@ class Elasticsearch(BaseClient):
1115
1049
  ] = None,
1116
1050
  ) -> ObjectApiResponse[t.Any]:
1117
1051
  """
1118
- Index a document. Adds a JSON document to the specified data stream or index
1119
- and makes it searchable. If the target is an index and the document already exists,
1120
- the request updates the document and increments its version.
1121
-
1122
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
1123
-
1124
- :param index: Name of the data stream or index to target. If the target doesn’t
1052
+ .. raw:: html
1053
+
1054
+ <p>Create a new document in the index.</p>
1055
+ <p>You can index a new JSON document with the <code>/&lt;target&gt;/_doc/</code> or <code>/&lt;target&gt;/_create/&lt;_id&gt;</code> APIs
1056
+ Using <code>_create</code> guarantees that the document is indexed only if it does not already exist.
1057
+ It returns a 409 response when a document with a same ID already exists in the index.
1058
+ To update an existing document, you must use the <code>/&lt;target&gt;/_doc/</code> API.</p>
1059
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
1060
+ <ul>
1061
+ <li>To add a document using the <code>PUT /&lt;target&gt;/_create/&lt;_id&gt;</code> or <code>POST /&lt;target&gt;/_create/&lt;_id&gt;</code> request formats, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
1062
+ <li>To automatically create a data stream or index with this API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
1063
+ </ul>
1064
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
1065
+ <p><strong>Automatically create data streams and indices</strong></p>
1066
+ <p>If the request's target doesn't exist and matches an index template with a <code>data_stream</code> definition, the index operation automatically creates the data stream.</p>
1067
+ <p>If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates.</p>
1068
+ <p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
1069
+ <p>If no mapping exists, the index operation creates a dynamic mapping.
1070
+ By default, new fields and objects are automatically added to the mapping if needed.</p>
1071
+ <p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
1072
+ If it is <code>true</code>, any index can be created automatically.
1073
+ You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to <code>false</code> to turn off automatic index creation entirely.
1074
+ Specify a comma-separated list of patterns you want to allow or prefix each pattern with <code>+</code> or <code>-</code> to indicate whether it should be allowed or blocked.
1075
+ When a list is specified, the default behaviour is to disallow.</p>
1076
+ <p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
1077
+ It does not affect the creation of data streams.</p>
1078
+ <p><strong>Routing</strong></p>
1079
+ <p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
1080
+ For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the <code>routing</code> parameter.</p>
1081
+ <p>When setting up explicit mapping, you can also use the <code>_routing</code> field to direct the index operation to extract the routing value from the document itself.
1082
+ This does come at the (very minimal) cost of an additional document parsing pass.
1083
+ If the <code>_routing</code> mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted.</p>
1084
+ <p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
1085
+ <p><strong>Distributed</strong></p>
1086
+ <p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
1087
+ After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
1088
+ <p><strong>Active shards</strong></p>
1089
+ <p>To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation.
1090
+ If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs.
1091
+ By default, write operations only wait for the primary shards to be active before proceeding (that is to say <code>wait_for_active_shards</code> is <code>1</code>).
1092
+ This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
1093
+ To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
1094
+ <p>Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is <code>number_of_replicas</code>+1).
1095
+ Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
1096
+ <p>For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes).
1097
+ If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
1098
+ This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data.
1099
+ If <code>wait_for_active_shards</code> is set on the request to <code>3</code> (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding.
1100
+ This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
1101
+ However, if you set <code>wait_for_active_shards</code> to <code>all</code> (or to <code>4</code>, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index.
1102
+ The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
1103
+ <p>It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts.
1104
+ After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary.
1105
+ The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
1106
+
1107
+
1108
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-create>`_
1109
+
1110
+ :param index: The name of the data stream or index to target. If the target doesn't
1125
1111
  exist and matches the name or wildcard (`*`) pattern of an index template
1126
1112
  with a `data_stream` definition, this request creates the data stream. If
1127
- the target doesnt exist and doesn’t match a data stream template, this request
1113
+ the target doesn't exist and doesn’t match a data stream template, this request
1128
1114
  creates the index.
1129
- :param id: Unique identifier for the document.
1115
+ :param id: A unique identifier for the document. To automatically generate a
1116
+ document ID, use the `POST /<target>/_doc/` request format.
1130
1117
  :param document:
1131
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
1132
- If the index has a default ingest pipeline specified, then setting the value
1133
- to `_none` disables the default ingest pipeline for this request. If a final
1134
- pipeline is configured it will always run, regardless of the value of this
1118
+ :param if_primary_term: Only perform the operation if the document has this primary
1119
+ term.
1120
+ :param if_seq_no: Only perform the operation if the document has this sequence
1121
+ number.
1122
+ :param include_source_on_error: True or false if to include the document source
1123
+ in the error message in case of parsing errors.
1124
+ :param op_type: Set to `create` to only index the document if it does not already
1125
+ exist (put if absent). If a document with the specified `_id` already exists,
1126
+ the indexing operation will fail. The behavior is the same as using the `<index>/_create`
1127
+ endpoint. If a document ID is specified, this paramater defaults to `index`.
1128
+ Otherwise, it defaults to `create`. If the request targets a data stream,
1129
+ an `op_type` of `create` is required.
1130
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
1131
+ If the index has a default ingest pipeline specified, setting the value to
1132
+ `_none` turns off the default ingest pipeline for this request. If a final
1133
+ pipeline is configured, it will always run regardless of the value of this
1135
1134
  parameter.
1136
1135
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
1137
- this operation visible to search, if `wait_for` then wait for a refresh to
1138
- make this operation visible to search, if `false` do nothing with refreshes.
1139
- Valid values: `true`, `false`, `wait_for`.
1140
- :param routing: Custom value used to route operations to a specific shard.
1141
- :param timeout: Period the request waits for the following operations: automatic
1142
- index creation, dynamic mapping updates, waiting for active shards.
1143
- :param version: Explicit version number for concurrency control. The specified
1144
- version must match the current version of the document for the request to
1145
- succeed.
1146
- :param version_type: Specific version type: `external`, `external_gte`.
1136
+ this operation visible to search. If `wait_for`, it waits for a refresh to
1137
+ make this operation visible to search. If `false`, it does nothing with refreshes.
1138
+ :param require_alias: If `true`, the destination must be an index alias.
1139
+ :param require_data_stream: If `true`, the request's actions must target a data
1140
+ stream (existing or to be created).
1141
+ :param routing: A custom value that is used to route operations to a specific
1142
+ shard.
1143
+ :param timeout: The period the request waits for the following operations: automatic
1144
+ index creation, dynamic mapping updates, waiting for active shards. Elasticsearch
1145
+ waits for at least the specified timeout period before failing. The actual
1146
+ wait time could be longer, particularly when multiple waits occur. This parameter
1147
+ is useful for situations where the primary shard assigned to perform the
1148
+ operation might not be available when the operation runs. Some reasons for
1149
+ this might be that the primary shard is currently recovering from a gateway
1150
+ or undergoing relocation. By default, the operation will wait on the primary
1151
+ shard to become available for at least 1 minute before failing and responding
1152
+ with an error. The actual wait time could be longer, particularly when multiple
1153
+ waits occur.
1154
+ :param version: The explicit version number for concurrency control. It must
1155
+ be a non-negative long number.
1156
+ :param version_type: The version type.
1147
1157
  :param wait_for_active_shards: The number of shard copies that must be active
1148
- before proceeding with the operation. Set to `all` or any positive integer
1149
- up to the total number of shards in the index (`number_of_replicas+1`).
1158
+ before proceeding with the operation. You can set it to `all` or any positive
1159
+ integer up to the total number of shards in the index (`number_of_replicas+1`).
1160
+ The default value of `1` means it waits for each primary shard to be active.
1150
1161
  """
1151
1162
  if index in SKIP_IN_PATH:
1152
1163
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1167,12 +1178,24 @@ class Elasticsearch(BaseClient):
1167
1178
  __query["filter_path"] = filter_path
1168
1179
  if human is not None:
1169
1180
  __query["human"] = human
1181
+ if if_primary_term is not None:
1182
+ __query["if_primary_term"] = if_primary_term
1183
+ if if_seq_no is not None:
1184
+ __query["if_seq_no"] = if_seq_no
1185
+ if include_source_on_error is not None:
1186
+ __query["include_source_on_error"] = include_source_on_error
1187
+ if op_type is not None:
1188
+ __query["op_type"] = op_type
1170
1189
  if pipeline is not None:
1171
1190
  __query["pipeline"] = pipeline
1172
1191
  if pretty is not None:
1173
1192
  __query["pretty"] = pretty
1174
1193
  if refresh is not None:
1175
1194
  __query["refresh"] = refresh
1195
+ if require_alias is not None:
1196
+ __query["require_alias"] = require_alias
1197
+ if require_data_stream is not None:
1198
+ __query["require_data_stream"] = require_data_stream
1176
1199
  if routing is not None:
1177
1200
  __query["routing"] = routing
1178
1201
  if timeout is not None:
@@ -1221,29 +1244,60 @@ class Elasticsearch(BaseClient):
1221
1244
  ] = None,
1222
1245
  ) -> ObjectApiResponse[t.Any]:
1223
1246
  """
1224
- Delete a document. Removes a JSON document from the specified index.
1225
-
1226
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete.html>`_
1227
-
1228
- :param index: Name of the target index.
1229
- :param id: Unique identifier for the document.
1247
+ .. raw:: html
1248
+
1249
+ <p>Delete a document.</p>
1250
+ <p>Remove a JSON document from the specified index.</p>
1251
+ <p>NOTE: You cannot send deletion requests directly to a data stream.
1252
+ To delete a document in a data stream, you must target the backing index containing the document.</p>
1253
+ <p><strong>Optimistic concurrency control</strong></p>
1254
+ <p>Delete operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the <code>if_seq_no</code> and <code>if_primary_term</code> parameters.
1255
+ If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
1256
+ <p><strong>Versioning</strong></p>
1257
+ <p>Each document indexed is versioned.
1258
+ When deleting a document, the version can be specified to make sure the relevant document you are trying to delete is actually being deleted and it has not changed in the meantime.
1259
+ Every write operation run on a document, deletes included, causes its version to be incremented.
1260
+ The version number of a deleted document remains available for a short time after deletion to allow for control of concurrent operations.
1261
+ The length of time for which a deleted document's version remains available is determined by the <code>index.gc_deletes</code> index setting.</p>
1262
+ <p><strong>Routing</strong></p>
1263
+ <p>If routing is used during indexing, the routing value also needs to be specified to delete a document.</p>
1264
+ <p>If the <code>_routing</code> mapping is set to <code>required</code> and no routing value is specified, the delete API throws a <code>RoutingMissingException</code> and rejects the request.</p>
1265
+ <p>For example:</p>
1266
+ <pre><code>DELETE /my-index-000001/_doc/1?routing=shard-1
1267
+ </code></pre>
1268
+ <p>This request deletes the document with ID 1, but it is routed based on the user.
1269
+ The document is not deleted if the correct routing is not specified.</p>
1270
+ <p><strong>Distributed</strong></p>
1271
+ <p>The delete operation gets hashed into a specific shard ID.
1272
+ It then gets redirected into the primary shard within that ID group and replicated (if needed) to shard replicas within that ID group.</p>
1273
+
1274
+
1275
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete>`_
1276
+
1277
+ :param index: The name of the target index.
1278
+ :param id: A unique identifier for the document.
1230
1279
  :param if_primary_term: Only perform the operation if the document has this primary
1231
1280
  term.
1232
1281
  :param if_seq_no: Only perform the operation if the document has this sequence
1233
1282
  number.
1234
1283
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
1235
- this operation visible to search, if `wait_for` then wait for a refresh to
1236
- make this operation visible to search, if `false` do nothing with refreshes.
1237
- Valid values: `true`, `false`, `wait_for`.
1238
- :param routing: Custom value used to route operations to a specific shard.
1239
- :param timeout: Period to wait for active shards.
1240
- :param version: Explicit version number for concurrency control. The specified
1241
- version must match the current version of the document for the request to
1242
- succeed.
1243
- :param version_type: Specific version type: `external`, `external_gte`.
1244
- :param wait_for_active_shards: The number of shard copies that must be active
1245
- before proceeding with the operation. Set to `all` or any positive integer
1246
- up to the total number of shards in the index (`number_of_replicas+1`).
1284
+ this operation visible to search. If `wait_for`, it waits for a refresh to
1285
+ make this operation visible to search. If `false`, it does nothing with refreshes.
1286
+ :param routing: A custom value used to route operations to a specific shard.
1287
+ :param timeout: The period to wait for active shards. This parameter is useful
1288
+ for situations where the primary shard assigned to perform the delete operation
1289
+ might not be available when the delete operation runs. Some reasons for this
1290
+ might be that the primary shard is currently recovering from a store or undergoing
1291
+ relocation. By default, the delete operation will wait on the primary shard
1292
+ to become available for up to 1 minute before failing and responding with
1293
+ an error.
1294
+ :param version: An explicit version number for concurrency control. It must match
1295
+ the current version of the document for the request to succeed.
1296
+ :param version_type: The version type.
1297
+ :param wait_for_active_shards: The minimum number of shard copies that must be
1298
+ active before proceeding with the operation. You can set it to `all` or any
1299
+ positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1300
+ The default value of `1` means it waits for each primary shard to be active.
1247
1301
  """
1248
1302
  if index in SKIP_IN_PATH:
1249
1303
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1343,72 +1397,148 @@ class Elasticsearch(BaseClient):
1343
1397
  body: t.Optional[t.Dict[str, t.Any]] = None,
1344
1398
  ) -> ObjectApiResponse[t.Any]:
1345
1399
  """
1346
- Delete documents. Deletes documents that match the specified query.
1347
-
1348
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1400
+ .. raw:: html
1401
+
1402
+ <p>Delete documents.</p>
1403
+ <p>Deletes documents that match the specified query.</p>
1404
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
1405
+ <ul>
1406
+ <li><code>read</code></li>
1407
+ <li><code>delete</code> or <code>write</code></li>
1408
+ </ul>
1409
+ <p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.
1410
+ When you submit a delete by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and deletes matching documents using internal versioning.
1411
+ If a document changes between the time that the snapshot is taken and the delete operation is processed, it results in a version conflict and the delete operation fails.</p>
1412
+ <p>NOTE: Documents with a version equal to 0 cannot be deleted using delete by query because internal versioning does not support 0 as a valid version number.</p>
1413
+ <p>While processing a delete by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents to delete.
1414
+ A bulk delete request is performed for each batch of matching documents.
1415
+ If a search or bulk request is rejected, the requests are retried up to 10 times, with exponential back off.
1416
+ If the maximum retry limit is reached, processing halts and all failed requests are returned in the response.
1417
+ Any delete requests that completed successfully still stick, they are not rolled back.</p>
1418
+ <p>You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
1419
+ Note that if you opt to count version conflicts the operation could attempt to delete more documents from the source than <code>max_docs</code> until it has successfully deleted <code>max_docs documents</code>, or it has gone through every document in the source query.</p>
1420
+ <p><strong>Throttling delete requests</strong></p>
1421
+ <p>To control the rate at which delete by query issues batches of delete operations, you can set <code>requests_per_second</code> to any positive decimal number.
1422
+ This pads each batch with a wait time to throttle the rate.
1423
+ Set <code>requests_per_second</code> to <code>-1</code> to disable throttling.</p>
1424
+ <p>Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
1425
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
1426
+ By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
1427
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
1428
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
1429
+ </code></pre>
1430
+ <p>Since the batch is issued as a single <code>_bulk</code> request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
1431
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
1432
+ <p><strong>Slicing</strong></p>
1433
+ <p>Delete by query supports sliced scroll to parallelize the delete process.
1434
+ This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
1435
+ <p>Setting <code>slices</code> to <code>auto</code> lets Elasticsearch choose the number of slices to use.
1436
+ This setting will use one slice per shard, up to a certain limit.
1437
+ If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.
1438
+ Adding slices to the delete by query operation creates sub-requests which means it has some quirks:</p>
1439
+ <ul>
1440
+ <li>You can see these requests in the tasks APIs. These sub-requests are &quot;child&quot; tasks of the task for the request with slices.</li>
1441
+ <li>Fetching the status of the task for the request with slices only contains the status of completed slices.</li>
1442
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
1443
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
1444
+ <li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
1445
+ <li>Due to the nature of <code>slices</code> each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
1446
+ <li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with <code>slices</code> are distributed proportionally to each sub-request. Combine that with the earlier point about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being deleted.</li>
1447
+ <li>Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.</li>
1448
+ </ul>
1449
+ <p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
1450
+ <ul>
1451
+ <li>Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many <code>slices</code> hurts performance. Setting <code>slices</code> higher than the number of shards generally does not improve efficiency and adds overhead.</li>
1452
+ <li>Delete performance scales linearly across available resources with the number of slices.</li>
1453
+ </ul>
1454
+ <p>Whether query or delete performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
1455
+ <p><strong>Cancel a delete by query operation</strong></p>
1456
+ <p>Any delete by query can be canceled using the task cancel API. For example:</p>
1457
+ <pre><code>POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
1458
+ </code></pre>
1459
+ <p>The task ID can be found by using the get tasks API.</p>
1460
+ <p>Cancellation should happen quickly but might take a few seconds.
1461
+ The get task status API will continue to list the delete by query task until this task checks that it has been cancelled and terminates itself.</p>
1462
+
1463
+
1464
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-by-query>`_
1349
1465
 
1350
- :param index: Comma-separated list of data streams, indices, and aliases to search.
1351
- Supports wildcards (`*`). To search all data streams or indices, omit this
1352
- parameter or use `*` or `_all`.
1466
+ :param index: A comma-separated list of data streams, indices, and aliases to
1467
+ search. It supports wildcards (`*`). To search all data streams or indices,
1468
+ omit this parameter or use `*` or `_all`.
1353
1469
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
1354
1470
  expression, index alias, or `_all` value targets only missing or closed indices.
1355
1471
  This behavior applies even if the request targets other open indices. For
1356
1472
  example, a request targeting `foo*,bar*` returns an error if an index starts
1357
1473
  with `foo` but no index starts with `bar`.
1358
1474
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1359
- :param analyzer: Analyzer to use for the query string.
1475
+ This parameter can be used only when the `q` query string parameter is specified.
1476
+ :param analyzer: Analyzer to use for the query string. This parameter can be
1477
+ used only when the `q` query string parameter is specified.
1360
1478
  :param conflicts: What to do if delete by query hits version conflicts: `abort`
1361
1479
  or `proceed`.
1362
1480
  :param default_operator: The default operator for query string query: `AND` or
1363
- `OR`.
1364
- :param df: Field to use as default where no field prefix is given in the query
1365
- string.
1366
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
1367
- request can target data streams, this argument determines whether wildcard
1368
- expressions match hidden data streams. Supports comma-separated values, such
1369
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
1370
- :param from_: Starting offset (default: 0)
1481
+ `OR`. This parameter can be used only when the `q` query string parameter
1482
+ is specified.
1483
+ :param df: The field to use as default where no field prefix is given in the
1484
+ query string. This parameter can be used only when the `q` query string parameter
1485
+ is specified.
1486
+ :param expand_wildcards: The type of index that wildcard patterns can match.
1487
+ If the request can target data streams, this argument determines whether
1488
+ wildcard expressions match hidden data streams. It supports comma-separated
1489
+ values, such as `open,hidden`.
1490
+ :param from_: Skips the specified number of documents.
1371
1491
  :param ignore_unavailable: If `false`, the request returns an error if it targets
1372
1492
  a missing or closed index.
1373
1493
  :param lenient: If `true`, format-based query failures (such as providing text
1374
- to a numeric field) in the query string will be ignored.
1494
+ to a numeric field) in the query string will be ignored. This parameter can
1495
+ be used only when the `q` query string parameter is specified.
1375
1496
  :param max_docs: The maximum number of documents to delete.
1376
- :param preference: Specifies the node or shard the operation should be performed
1377
- on. Random by default.
1378
- :param q: Query in the Lucene query string syntax.
1379
- :param query: Specifies the documents to delete using the Query DSL.
1497
+ :param preference: The node or shard the operation should be performed on. It
1498
+ is random by default.
1499
+ :param q: A query in the Lucene query string syntax.
1500
+ :param query: The documents to delete specified with Query DSL.
1380
1501
  :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1381
- delete by query after the request completes.
1502
+ delete by query after the request completes. This is different than the delete
1503
+ API's `refresh` parameter, which causes just the shard that received the
1504
+ delete request to be refreshed. Unlike the delete API, it does not support
1505
+ `wait_for`.
1382
1506
  :param request_cache: If `true`, the request cache is used for this request.
1383
1507
  Defaults to the index-level setting.
1384
1508
  :param requests_per_second: The throttle for this request in sub-requests per
1385
1509
  second.
1386
- :param routing: Custom value used to route operations to a specific shard.
1387
- :param scroll: Period to retain the search context for scrolling.
1388
- :param scroll_size: Size of the scroll request that powers the operation.
1389
- :param search_timeout: Explicit timeout for each search request. Defaults to
1390
- no timeout.
1391
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
1392
- `dfs_query_then_fetch`.
1510
+ :param routing: A custom value used to route operations to a specific shard.
1511
+ :param scroll: The period to retain the search context for scrolling.
1512
+ :param scroll_size: The size of the scroll request that powers the operation.
1513
+ :param search_timeout: The explicit timeout for each search request. It defaults
1514
+ to no timeout.
1515
+ :param search_type: The type of the search operation. Available options include
1516
+ `query_then_fetch` and `dfs_query_then_fetch`.
1393
1517
  :param slice: Slice the request manually using the provided slice ID and total
1394
1518
  number of slices.
1395
1519
  :param slices: The number of slices this task should be divided into.
1396
- :param sort: A comma-separated list of <field>:<direction> pairs.
1397
- :param stats: Specific `tag` of the request for logging and statistical purposes.
1398
- :param terminate_after: Maximum number of documents to collect for each shard.
1520
+ :param sort: A comma-separated list of `<field>:<direction>` pairs.
1521
+ :param stats: The specific `tag` of the request for logging and statistical purposes.
1522
+ :param terminate_after: The maximum number of documents to collect for each shard.
1399
1523
  If a query reaches this limit, Elasticsearch terminates the query early.
1400
1524
  Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
1401
1525
  applies this parameter to each shard handling the request. When possible,
1402
1526
  let Elasticsearch perform early termination automatically. Avoid specifying
1403
1527
  this parameter for requests that target data streams with backing indices
1404
1528
  across multiple data tiers.
1405
- :param timeout: Period each deletion request waits for active shards.
1529
+ :param timeout: The period each deletion request waits for active shards.
1406
1530
  :param version: If `true`, returns the document version as part of a hit.
1407
1531
  :param wait_for_active_shards: The number of shard copies that must be active
1408
- before proceeding with the operation. Set to all or any positive integer
1409
- up to the total number of shards in the index (`number_of_replicas+1`).
1532
+ before proceeding with the operation. Set to `all` or any positive integer
1533
+ up to the total number of shards in the index (`number_of_replicas+1`). The
1534
+ `timeout` value controls how long each write request waits for unavailable
1535
+ shards to become available.
1410
1536
  :param wait_for_completion: If `true`, the request blocks until the operation
1411
- is complete.
1537
+ is complete. If `false`, Elasticsearch performs some preflight checks, launches
1538
+ the request, and returns a task you can use to cancel or get the status of
1539
+ the task. Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`.
1540
+ When you are done with a task, you should delete the task document so Elasticsearch
1541
+ can reclaim the space.
1412
1542
  """
1413
1543
  if index in SKIP_IN_PATH:
1414
1544
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1521,16 +1651,18 @@ class Elasticsearch(BaseClient):
1521
1651
  requests_per_second: t.Optional[float] = None,
1522
1652
  ) -> ObjectApiResponse[t.Any]:
1523
1653
  """
1524
- Throttle a delete by query operation. Change the number of requests per second
1525
- for a particular delete by query operation. Rethrottling that speeds up the query
1526
- takes effect immediately but rethrotting that slows down the query takes effect
1527
- after completing the current batch to prevent scroll timeouts.
1654
+ .. raw:: html
1655
+
1656
+ <p>Throttle a delete by query operation.</p>
1657
+ <p>Change the number of requests per second for a particular delete by query operation.
1658
+ Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.</p>
1528
1659
 
1529
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1660
+
1661
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-by-query-rethrottle>`_
1530
1662
 
1531
1663
  :param task_id: The ID for the task.
1532
1664
  :param requests_per_second: The throttle for this request in sub-requests per
1533
- second.
1665
+ second. To disable throttling, set it to `-1`.
1534
1666
  """
1535
1667
  if task_id in SKIP_IN_PATH:
1536
1668
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -1570,16 +1702,22 @@ class Elasticsearch(BaseClient):
1570
1702
  timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1571
1703
  ) -> ObjectApiResponse[t.Any]:
1572
1704
  """
1573
- Delete a script or search template. Deletes a stored script or search template.
1705
+ .. raw:: html
1574
1706
 
1575
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
1707
+ <p>Delete a script or search template.
1708
+ Deletes a stored script or search template.</p>
1576
1709
 
1577
- :param id: Identifier for the stored script or search template.
1578
- :param master_timeout: Period to wait for a connection to the master node. If
1579
- no response is received before the timeout expires, the request fails and
1580
- returns an error.
1581
- :param timeout: Period to wait for a response. If no response is received before
1582
- the timeout expires, the request fails and returns an error.
1710
+
1711
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-script>`_
1712
+
1713
+ :param id: The identifier for the stored script or search template.
1714
+ :param master_timeout: The period to wait for a connection to the master node.
1715
+ If no response is received before the timeout expires, the request fails
1716
+ and returns an error. It can also be set to `-1` to indicate that the request
1717
+ should never timeout.
1718
+ :param timeout: The period to wait for a response. If no response is received
1719
+ before the timeout expires, the request fails and returns an error. It can
1720
+ also be set to `-1` to indicate that the request should never timeout.
1583
1721
  """
1584
1722
  if id in SKIP_IN_PATH:
1585
1723
  raise ValueError("Empty value passed for parameter 'id'")
@@ -1638,32 +1776,60 @@ class Elasticsearch(BaseClient):
1638
1776
  ] = None,
1639
1777
  ) -> HeadApiResponse:
1640
1778
  """
1641
- Check a document. Checks if a specified document exists.
1642
-
1643
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1644
-
1645
- :param index: Comma-separated list of data streams, indices, and aliases. Supports
1646
- wildcards (`*`).
1647
- :param id: Identifier of the document.
1648
- :param preference: Specifies the node or shard the operation should be performed
1649
- on. Random by default.
1779
+ .. raw:: html
1780
+
1781
+ <p>Check a document.</p>
1782
+ <p>Verify that a document exists.
1783
+ For example, check to see if a document with the <code>_id</code> 0 exists:</p>
1784
+ <pre><code>HEAD my-index-000001/_doc/0
1785
+ </code></pre>
1786
+ <p>If the document exists, the API returns a status code of <code>200 - OK</code>.
1787
+ If the document doesn’t exist, the API returns <code>404 - Not Found</code>.</p>
1788
+ <p><strong>Versioning support</strong></p>
1789
+ <p>You can use the <code>version</code> parameter to check the document only if its current version is equal to the specified one.</p>
1790
+ <p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
1791
+ The old version of the document doesn't disappear immediately, although you won't be able to access it.
1792
+ Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
1793
+
1794
+
1795
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
1796
+
1797
+ :param index: A comma-separated list of data streams, indices, and aliases. It
1798
+ supports wildcards (`*`).
1799
+ :param id: A unique document identifier.
1800
+ :param preference: The node or shard the operation should be performed on. By
1801
+ default, the operation is randomized between the shard replicas. If it is
1802
+ set to `_local`, the operation will prefer to be run on a local allocated
1803
+ shard when possible. If it is set to a custom value, the value is used to
1804
+ guarantee that the same shards will be used for the same custom value. This
1805
+ can help with "jumping values" when hitting different shards in different
1806
+ refresh states. A sample value can be something like the web session ID or
1807
+ the user name.
1650
1808
  :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1651
- :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1652
- delete by query after the request completes.
1653
- :param routing: Target the specified primary shard.
1654
- :param source: `true` or `false` to return the `_source` field or not, or a list
1655
- of fields to return.
1656
- :param source_excludes: A comma-separated list of source fields to exclude in
1657
- the response.
1809
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
1810
+ the document. Setting it to `true` should be done after careful thought and
1811
+ verification that this does not cause a heavy load on the system (and slow
1812
+ down indexing).
1813
+ :param routing: A custom value used to route operations to a specific shard.
1814
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
1815
+ or lists the fields to return.
1816
+ :param source_excludes: A comma-separated list of source fields to exclude from
1817
+ the response. You can also use this parameter to exclude fields from the
1818
+ subset specified in `_source_includes` query parameter. If the `_source`
1819
+ parameter is `false`, this parameter is ignored.
1658
1820
  :param source_includes: A comma-separated list of source fields to include in
1659
- the response.
1660
- :param stored_fields: List of stored fields to return as part of a hit. If no
1661
- fields are specified, no stored fields are included in the response. If this
1662
- field is specified, the `_source` parameter defaults to false.
1821
+ the response. If this parameter is specified, only these source fields are
1822
+ returned. You can exclude fields from this subset using the `_source_excludes`
1823
+ query parameter. If the `_source` parameter is `false`, this parameter is
1824
+ ignored.
1825
+ :param stored_fields: A comma-separated list of stored fields to return as part
1826
+ of a hit. If no fields are specified, no stored fields are included in the
1827
+ response. If this field is specified, the `_source` parameter defaults to
1828
+ `false`.
1663
1829
  :param version: Explicit version number for concurrency control. The specified
1664
1830
  version must match the current version of the document for the request to
1665
1831
  succeed.
1666
- :param version_type: Specific version type: `external`, `external_gte`.
1832
+ :param version_type: The version type.
1667
1833
  """
1668
1834
  if index in SKIP_IN_PATH:
1669
1835
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1739,29 +1905,38 @@ class Elasticsearch(BaseClient):
1739
1905
  ] = None,
1740
1906
  ) -> HeadApiResponse:
1741
1907
  """
1742
- Check for a document source. Checks if a document's `_source` is stored.
1908
+ .. raw:: html
1743
1909
 
1744
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1910
+ <p>Check for a document source.</p>
1911
+ <p>Check whether a document source exists in an index.
1912
+ For example:</p>
1913
+ <pre><code>HEAD my-index-000001/_source/1
1914
+ </code></pre>
1915
+ <p>A document's source is not available if it is disabled in the mapping.</p>
1745
1916
 
1746
- :param index: Comma-separated list of data streams, indices, and aliases. Supports
1747
- wildcards (`*`).
1748
- :param id: Identifier of the document.
1749
- :param preference: Specifies the node or shard the operation should be performed
1750
- on. Random by default.
1751
- :param realtime: If true, the request is real-time as opposed to near-real-time.
1752
- :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1753
- delete by query after the request completes.
1754
- :param routing: Target the specified primary shard.
1755
- :param source: `true` or `false` to return the `_source` field or not, or a list
1756
- of fields to return.
1917
+
1918
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
1919
+
1920
+ :param index: A comma-separated list of data streams, indices, and aliases. It
1921
+ supports wildcards (`*`).
1922
+ :param id: A unique identifier for the document.
1923
+ :param preference: The node or shard the operation should be performed on. By
1924
+ default, the operation is randomized between the shard replicas.
1925
+ :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1926
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
1927
+ the document. Setting it to `true` should be done after careful thought and
1928
+ verification that this does not cause a heavy load on the system (and slow
1929
+ down indexing).
1930
+ :param routing: A custom value used to route operations to a specific shard.
1931
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
1932
+ or lists the fields to return.
1757
1933
  :param source_excludes: A comma-separated list of source fields to exclude in
1758
1934
  the response.
1759
1935
  :param source_includes: A comma-separated list of source fields to include in
1760
1936
  the response.
1761
- :param version: Explicit version number for concurrency control. The specified
1762
- version must match the current version of the document for the request to
1763
- succeed.
1764
- :param version_type: Specific version type: `external`, `external_gte`.
1937
+ :param version: The version number for concurrency control. It must match the
1938
+ current version of the document for the request to succeed.
1939
+ :param version_type: The version type.
1765
1940
  """
1766
1941
  if index in SKIP_IN_PATH:
1767
1942
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1839,34 +2014,47 @@ class Elasticsearch(BaseClient):
1839
2014
  body: t.Optional[t.Dict[str, t.Any]] = None,
1840
2015
  ) -> ObjectApiResponse[t.Any]:
1841
2016
  """
1842
- Explain a document match result. Returns information about why a specific document
1843
- matches, or doesn’t match, a query.
2017
+ .. raw:: html
2018
+
2019
+ <p>Explain a document match result.
2020
+ Get information about why a specific document matches, or doesn't match, a query.
2021
+ It computes a score explanation for a query and a specific document.</p>
2022
+
1844
2023
 
1845
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-explain.html>`_
2024
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-explain>`_
1846
2025
 
1847
- :param index: Index names used to limit the request. Only a single index name
1848
- can be provided to this parameter.
1849
- :param id: Defines the document ID.
2026
+ :param index: Index names that are used to limit the request. Only a single index
2027
+ name can be provided to this parameter.
2028
+ :param id: The document identifier.
1850
2029
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1851
- :param analyzer: Analyzer to use for the query string. This parameter can only
1852
- be used when the `q` query string parameter is specified.
2030
+ This parameter can be used only when the `q` query string parameter is specified.
2031
+ :param analyzer: The analyzer to use for the query string. This parameter can
2032
+ be used only when the `q` query string parameter is specified.
1853
2033
  :param default_operator: The default operator for query string query: `AND` or
1854
- `OR`.
1855
- :param df: Field to use as default where no field prefix is given in the query
1856
- string.
2034
+ `OR`. This parameter can be used only when the `q` query string parameter
2035
+ is specified.
2036
+ :param df: The field to use as default where no field prefix is given in the
2037
+ query string. This parameter can be used only when the `q` query string parameter
2038
+ is specified.
1857
2039
  :param lenient: If `true`, format-based query failures (such as providing text
1858
- to a numeric field) in the query string will be ignored.
1859
- :param preference: Specifies the node or shard the operation should be performed
1860
- on. Random by default.
1861
- :param q: Query in the Lucene query string syntax.
2040
+ to a numeric field) in the query string will be ignored. This parameter can
2041
+ be used only when the `q` query string parameter is specified.
2042
+ :param preference: The node or shard the operation should be performed on. It
2043
+ is random by default.
2044
+ :param q: The query in the Lucene query string syntax.
1862
2045
  :param query: Defines the search definition using the Query DSL.
1863
- :param routing: Custom value used to route operations to a specific shard.
1864
- :param source: True or false to return the `_source` field or not, or a list
2046
+ :param routing: A custom value used to route operations to a specific shard.
2047
+ :param source: `True` or `false` to return the `_source` field or not or a list
1865
2048
  of fields to return.
1866
2049
  :param source_excludes: A comma-separated list of source fields to exclude from
1867
- the response.
2050
+ the response. You can also use this parameter to exclude fields from the
2051
+ subset specified in `_source_includes` query parameter. If the `_source`
2052
+ parameter is `false`, this parameter is ignored.
1868
2053
  :param source_includes: A comma-separated list of source fields to include in
1869
- the response.
2054
+ the response. If this parameter is specified, only these source fields are
2055
+ returned. You can exclude fields from this subset using the `_source_excludes`
2056
+ query parameter. If the `_source` parameter is `false`, this parameter is
2057
+ ignored.
1870
2058
  :param stored_fields: A comma-separated list of stored fields to return in the
1871
2059
  response.
1872
2060
  """
@@ -1959,15 +2147,18 @@ class Elasticsearch(BaseClient):
1959
2147
  body: t.Optional[t.Dict[str, t.Any]] = None,
1960
2148
  ) -> ObjectApiResponse[t.Any]:
1961
2149
  """
1962
- Get the field capabilities. Get information about the capabilities of fields
1963
- among multiple indices. For data streams, the API returns field capabilities
1964
- among the stream’s backing indices. It returns runtime fields like any other
1965
- field. For example, a runtime field with a type of keyword is returned the same
1966
- as any other field that belongs to the `keyword` family.
2150
+ .. raw:: html
2151
+
2152
+ <p>Get the field capabilities.</p>
2153
+ <p>Get information about the capabilities of fields among multiple indices.</p>
2154
+ <p>For data streams, the API returns field capabilities among the stream’s backing indices.
2155
+ It returns runtime fields like any other field.
2156
+ For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the <code>keyword</code> family.</p>
2157
+
1967
2158
 
1968
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-field-caps.html>`_
2159
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-field-caps>`_
1969
2160
 
1970
- :param index: Comma-separated list of data streams, indices, and aliases used
2161
+ :param index: A comma-separated list of data streams, indices, and aliases used
1971
2162
  to limit the request. Supports wildcards (*). To target all data streams
1972
2163
  and indices, omit this parameter or use * or _all.
1973
2164
  :param allow_no_indices: If false, the request returns an error if any wildcard
@@ -1975,25 +2166,32 @@ class Elasticsearch(BaseClient):
1975
2166
  This behavior applies even if the request targets other open indices. For
1976
2167
  example, a request targeting `foo*,bar*` returns an error if an index starts
1977
2168
  with foo but no index starts with bar.
1978
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
1979
- request can target data streams, this argument determines whether wildcard
1980
- expressions match hidden data streams. Supports comma-separated values, such
1981
- as `open,hidden`.
1982
- :param fields: List of fields to retrieve capabilities for. Wildcard (`*`) expressions
1983
- are supported.
1984
- :param filters: An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent
2169
+ :param expand_wildcards: The type of index that wildcard patterns can match.
2170
+ If the request can target data streams, this argument determines whether
2171
+ wildcard expressions match hidden data streams. Supports comma-separated
2172
+ values, such as `open,hidden`.
2173
+ :param fields: A list of fields to retrieve capabilities for. Wildcard (`*`)
2174
+ expressions are supported.
2175
+ :param filters: A comma-separated list of filters to apply to the response.
1985
2176
  :param ignore_unavailable: If `true`, missing or closed indices are not included
1986
2177
  in the response.
1987
2178
  :param include_empty_fields: If false, empty fields are not included in the response.
1988
2179
  :param include_unmapped: If true, unmapped fields are included in the response.
1989
- :param index_filter: Allows to filter indices if the provided query rewrites
1990
- to match_none on every shard.
1991
- :param runtime_mappings: Defines ad-hoc runtime fields in the request similar
2180
+ :param index_filter: Filter indices if the provided query rewrites to `match_none`
2181
+ on every shard. IMPORTANT: The filtering is done on a best-effort basis,
2182
+ it uses index statistics and mappings to rewrite queries to `match_none`
2183
+ instead of fully running the request. For instance a range query over a date
2184
+ field can rewrite to `match_none` if all documents within a shard (including
2185
+ deleted documents) are outside of the provided range. However, not all queries
2186
+ can rewrite to `match_none` so this API may return an index even if the provided
2187
+ filter matches no document.
2188
+ :param runtime_mappings: Define ad-hoc runtime fields in the request similar
1992
2189
  to the way it is done in search requests. These fields exist only as part
1993
2190
  of the query and take precedence over fields defined with the same name in
1994
2191
  the index mappings.
1995
- :param types: Only return results for fields that have one of the types in the
1996
- list
2192
+ :param types: A comma-separated list of field types to include. Any fields that
2193
+ do not match one of these types will be excluded from the results. It defaults
2194
+ to empty, meaning that all field types are returned.
1997
2195
  """
1998
2196
  __path_parts: t.Dict[str, str]
1999
2197
  if index not in SKIP_IN_PATH:
@@ -2079,36 +2277,87 @@ class Elasticsearch(BaseClient):
2079
2277
  ] = None,
2080
2278
  ) -> ObjectApiResponse[t.Any]:
2081
2279
  """
2082
- Get a document by its ID. Retrieves the document with the specified ID from an
2083
- index.
2084
-
2085
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
2086
-
2087
- :param index: Name of the index that contains the document.
2088
- :param id: Unique identifier of the document.
2089
- :param force_synthetic_source: Should this request force synthetic _source? Use
2090
- this to test if the mapping supports synthetic _source and to get a sense
2091
- of the worst case performance. Fetches with this enabled will be slower the
2092
- enabling synthetic source natively in the index.
2093
- :param preference: Specifies the node or shard the operation should be performed
2094
- on. Random by default.
2280
+ .. raw:: html
2281
+
2282
+ <p>Get a document by its ID.</p>
2283
+ <p>Get a document and its source or stored fields from an index.</p>
2284
+ <p>By default, this API is realtime and is not affected by the refresh rate of the index (when data will become visible for search).
2285
+ In the case where stored fields are requested with the <code>stored_fields</code> parameter and the document has been updated but is not yet refreshed, the API will have to parse and analyze the source to extract the stored fields.
2286
+ To turn off realtime behavior, set the <code>realtime</code> parameter to false.</p>
2287
+ <p><strong>Source filtering</strong></p>
2288
+ <p>By default, the API returns the contents of the <code>_source</code> field unless you have used the <code>stored_fields</code> parameter or the <code>_source</code> field is turned off.
2289
+ You can turn off <code>_source</code> retrieval by using the <code>_source</code> parameter:</p>
2290
+ <pre><code>GET my-index-000001/_doc/0?_source=false
2291
+ </code></pre>
2292
+ <p>If you only need one or two fields from the <code>_source</code>, use the <code>_source_includes</code> or <code>_source_excludes</code> parameters to include or filter out particular fields.
2293
+ This can be helpful with large documents where partial retrieval can save on network overhead
2294
+ Both parameters take a comma separated list of fields or wildcard expressions.
2295
+ For example:</p>
2296
+ <pre><code>GET my-index-000001/_doc/0?_source_includes=*.id&amp;_source_excludes=entities
2297
+ </code></pre>
2298
+ <p>If you only want to specify includes, you can use a shorter notation:</p>
2299
+ <pre><code>GET my-index-000001/_doc/0?_source=*.id
2300
+ </code></pre>
2301
+ <p><strong>Routing</strong></p>
2302
+ <p>If routing is used during indexing, the routing value also needs to be specified to retrieve a document.
2303
+ For example:</p>
2304
+ <pre><code>GET my-index-000001/_doc/2?routing=user1
2305
+ </code></pre>
2306
+ <p>This request gets the document with ID 2, but it is routed based on the user.
2307
+ The document is not fetched if the correct routing is not specified.</p>
2308
+ <p><strong>Distributed</strong></p>
2309
+ <p>The GET operation is hashed into a specific shard ID.
2310
+ It is then redirected to one of the replicas within that shard ID and returns the result.
2311
+ The replicas are the primary shard and its replicas within that shard ID group.
2312
+ This means that the more replicas you have, the better your GET scaling will be.</p>
2313
+ <p><strong>Versioning support</strong></p>
2314
+ <p>You can use the <code>version</code> parameter to retrieve the document only if its current version is equal to the specified one.</p>
2315
+ <p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
2316
+ The old version of the document doesn't disappear immediately, although you won't be able to access it.
2317
+ Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
2318
+
2319
+
2320
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
2321
+
2322
+ :param index: The name of the index that contains the document.
2323
+ :param id: A unique document identifier.
2324
+ :param force_synthetic_source: Indicates whether the request forces synthetic
2325
+ `_source`. Use this paramater to test if the mapping supports synthetic `_source`
2326
+ and to get a sense of the worst case performance. Fetches with this parameter
2327
+ enabled will be slower than enabling synthetic source natively in the index.
2328
+ :param preference: The node or shard the operation should be performed on. By
2329
+ default, the operation is randomized between the shard replicas. If it is
2330
+ set to `_local`, the operation will prefer to be run on a local allocated
2331
+ shard when possible. If it is set to a custom value, the value is used to
2332
+ guarantee that the same shards will be used for the same custom value. This
2333
+ can help with "jumping values" when hitting different shards in different
2334
+ refresh states. A sample value can be something like the web session ID or
2335
+ the user name.
2095
2336
  :param realtime: If `true`, the request is real-time as opposed to near-real-time.
2096
- :param refresh: If true, Elasticsearch refreshes the affected shards to make
2097
- this operation visible to search. If false, do nothing with refreshes.
2098
- :param routing: Target the specified primary shard.
2099
- :param source: True or false to return the _source field or not, or a list of
2100
- fields to return.
2101
- :param source_excludes: A comma-separated list of source fields to exclude in
2102
- the response.
2337
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
2338
+ the document. Setting it to `true` should be done after careful thought and
2339
+ verification that this does not cause a heavy load on the system (and slow
2340
+ down indexing).
2341
+ :param routing: A custom value used to route operations to a specific shard.
2342
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
2343
+ or lists the fields to return.
2344
+ :param source_excludes: A comma-separated list of source fields to exclude from
2345
+ the response. You can also use this parameter to exclude fields from the
2346
+ subset specified in `_source_includes` query parameter. If the `_source`
2347
+ parameter is `false`, this parameter is ignored.
2103
2348
  :param source_includes: A comma-separated list of source fields to include in
2104
- the response.
2105
- :param stored_fields: List of stored fields to return as part of a hit. If no
2106
- fields are specified, no stored fields are included in the response. If this
2107
- field is specified, the `_source` parameter defaults to false.
2108
- :param version: Explicit version number for concurrency control. The specified
2109
- version must match the current version of the document for the request to
2110
- succeed.
2111
- :param version_type: Specific version type: internal, external, external_gte.
2349
+ the response. If this parameter is specified, only these source fields are
2350
+ returned. You can exclude fields from this subset using the `_source_excludes`
2351
+ query parameter. If the `_source` parameter is `false`, this parameter is
2352
+ ignored.
2353
+ :param stored_fields: A comma-separated list of stored fields to return as part
2354
+ of a hit. If no fields are specified, no stored fields are included in the
2355
+ response. If this field is specified, the `_source` parameter defaults to
2356
+ `false`. Only leaf fields can be retrieved with the `stored_field` option.
2357
+ Object fields can't be returned;​if specified, the request fails.
2358
+ :param version: The version number for concurrency control. It must match the
2359
+ current version of the document for the request to succeed.
2360
+ :param version_type: The version type.
2112
2361
  """
2113
2362
  if index in SKIP_IN_PATH:
2114
2363
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2169,12 +2418,19 @@ class Elasticsearch(BaseClient):
2169
2418
  pretty: t.Optional[bool] = None,
2170
2419
  ) -> ObjectApiResponse[t.Any]:
2171
2420
  """
2172
- Get a script or search template. Retrieves a stored script or search template.
2421
+ .. raw:: html
2422
+
2423
+ <p>Get a script or search template.
2424
+ Retrieves a stored script or search template.</p>
2173
2425
 
2174
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2175
2426
 
2176
- :param id: Identifier for the stored script or search template.
2177
- :param master_timeout: Specify timeout for connection to master
2427
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get-script>`_
2428
+
2429
+ :param id: The identifier for the stored script or search template.
2430
+ :param master_timeout: The period to wait for the master node. If the master
2431
+ node is not available before the timeout expires, the request fails and returns
2432
+ an error. It can also be set to `-1` to indicate that the request should
2433
+ never timeout.
2178
2434
  """
2179
2435
  if id in SKIP_IN_PATH:
2180
2436
  raise ValueError("Empty value passed for parameter 'id'")
@@ -2211,9 +2467,13 @@ class Elasticsearch(BaseClient):
2211
2467
  pretty: t.Optional[bool] = None,
2212
2468
  ) -> ObjectApiResponse[t.Any]:
2213
2469
  """
2214
- Get script contexts. Get a list of supported script contexts and their methods.
2470
+ .. raw:: html
2471
+
2472
+ <p>Get script contexts.</p>
2473
+ <p>Get a list of supported script contexts and their methods.</p>
2474
+
2215
2475
 
2216
- `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-contexts.html>`_
2476
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get-script-context>`_
2217
2477
  """
2218
2478
  __path_parts: t.Dict[str, str] = {}
2219
2479
  __path = "/_script_context"
@@ -2246,9 +2506,13 @@ class Elasticsearch(BaseClient):
2246
2506
  pretty: t.Optional[bool] = None,
2247
2507
  ) -> ObjectApiResponse[t.Any]:
2248
2508
  """
2249
- Get script languages. Get a list of available script types, languages, and contexts.
2509
+ .. raw:: html
2510
+
2511
+ <p>Get script languages.</p>
2512
+ <p>Get a list of available script types, languages, and contexts.</p>
2513
+
2250
2514
 
2251
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2515
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get-script-languages>`_
2252
2516
  """
2253
2517
  __path_parts: t.Dict[str, str] = {}
2254
2518
  __path = "/_script_language"
@@ -2301,29 +2565,41 @@ class Elasticsearch(BaseClient):
2301
2565
  ] = None,
2302
2566
  ) -> ObjectApiResponse[t.Any]:
2303
2567
  """
2304
- Get a document's source. Returns the source of a document.
2568
+ .. raw:: html
2305
2569
 
2306
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
2570
+ <p>Get a document's source.</p>
2571
+ <p>Get the source of a document.
2572
+ For example:</p>
2573
+ <pre><code>GET my-index-000001/_source/1
2574
+ </code></pre>
2575
+ <p>You can use the source filtering parameters to control which parts of the <code>_source</code> are returned:</p>
2576
+ <pre><code>GET my-index-000001/_source/1/?_source_includes=*.id&amp;_source_excludes=entities
2577
+ </code></pre>
2307
2578
 
2308
- :param index: Name of the index that contains the document.
2309
- :param id: Unique identifier of the document.
2310
- :param preference: Specifies the node or shard the operation should be performed
2311
- on. Random by default.
2312
- :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time.
2313
- :param refresh: If true, Elasticsearch refreshes the affected shards to make
2314
- this operation visible to search. If false, do nothing with refreshes.
2315
- :param routing: Target the specified primary shard.
2316
- :param source: True or false to return the _source field or not, or a list of
2317
- fields to return.
2579
+
2580
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
2581
+
2582
+ :param index: The name of the index that contains the document.
2583
+ :param id: A unique document identifier.
2584
+ :param preference: The node or shard the operation should be performed on. By
2585
+ default, the operation is randomized between the shard replicas.
2586
+ :param realtime: If `true`, the request is real-time as opposed to near-real-time.
2587
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
2588
+ the document. Setting it to `true` should be done after careful thought and
2589
+ verification that this does not cause a heavy load on the system (and slow
2590
+ down indexing).
2591
+ :param routing: A custom value used to route operations to a specific shard.
2592
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
2593
+ or lists the fields to return.
2318
2594
  :param source_excludes: A comma-separated list of source fields to exclude in
2319
2595
  the response.
2320
2596
  :param source_includes: A comma-separated list of source fields to include in
2321
2597
  the response.
2322
- :param stored_fields:
2323
- :param version: Explicit version number for concurrency control. The specified
2324
- version must match the current version of the document for the request to
2325
- succeed.
2326
- :param version_type: Specific version type: internal, external, external_gte.
2598
+ :param stored_fields: A comma-separated list of stored fields to return as part
2599
+ of a hit.
2600
+ :param version: The version number for concurrency control. It must match the
2601
+ current version of the document for the request to succeed.
2602
+ :param version_type: The version type.
2327
2603
  """
2328
2604
  if index in SKIP_IN_PATH:
2329
2605
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2384,28 +2660,24 @@ class Elasticsearch(BaseClient):
2384
2660
  verbose: t.Optional[bool] = None,
2385
2661
  ) -> ObjectApiResponse[t.Any]:
2386
2662
  """
2387
- Get the cluster health. Get a report with the health status of an Elasticsearch
2388
- cluster. The report contains a list of indicators that compose Elasticsearch
2389
- functionality. Each indicator has a health status of: green, unknown, yellow
2390
- or red. The indicator will provide an explanation and metadata describing the
2391
- reason for its current health status. The cluster’s status is controlled by the
2392
- worst indicator status. In the event that an indicator’s status is non-green,
2393
- a list of impacts may be present in the indicator result which detail the functionalities
2394
- that are negatively affected by the health issue. Each impact carries with it
2395
- a severity level, an area of the system that is affected, and a simple description
2396
- of the impact on the system. Some health indicators can determine the root cause
2397
- of a health problem and prescribe a set of steps that can be performed in order
2398
- to improve the health of the system. The root cause and remediation steps are
2399
- encapsulated in a diagnosis. A diagnosis contains a cause detailing a root cause
2400
- analysis, an action containing a brief description of the steps to take to fix
2401
- the problem, the list of affected resources (if applicable), and a detailed step-by-step
2402
- troubleshooting guide to fix the diagnosed problem. NOTE: The health indicators
2403
- perform root cause analysis of non-green health statuses. This can be computationally
2404
- expensive when called frequently. When setting up automated polling of the API
2405
- for health status, set verbose to false to disable the more expensive analysis
2406
- logic.
2407
-
2408
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/health-api.html>`_
2663
+ .. raw:: html
2664
+
2665
+ <p>Get the cluster health.
2666
+ Get a report with the health status of an Elasticsearch cluster.
2667
+ The report contains a list of indicators that compose Elasticsearch functionality.</p>
2668
+ <p>Each indicator has a health status of: green, unknown, yellow or red.
2669
+ The indicator will provide an explanation and metadata describing the reason for its current health status.</p>
2670
+ <p>The cluster’s status is controlled by the worst indicator status.</p>
2671
+ <p>In the event that an indicator’s status is non-green, a list of impacts may be present in the indicator result which detail the functionalities that are negatively affected by the health issue.
2672
+ Each impact carries with it a severity level, an area of the system that is affected, and a simple description of the impact on the system.</p>
2673
+ <p>Some health indicators can determine the root cause of a health problem and prescribe a set of steps that can be performed in order to improve the health of the system.
2674
+ The root cause and remediation steps are encapsulated in a diagnosis.
2675
+ A diagnosis contains a cause detailing a root cause analysis, an action containing a brief description of the steps to take to fix the problem, the list of affected resources (if applicable), and a detailed step-by-step troubleshooting guide to fix the diagnosed problem.</p>
2676
+ <p>NOTE: The health indicators perform root cause analysis of non-green health statuses. This can be computationally expensive when called frequently.
2677
+ When setting up automated polling of the API for health status, set verbose to false to disable the more expensive analysis logic.</p>
2678
+
2679
+
2680
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-health-report>`_
2409
2681
 
2410
2682
  :param feature: A feature of the cluster, as returned by the top-level health
2411
2683
  report API.
@@ -2460,6 +2732,7 @@ class Elasticsearch(BaseClient):
2460
2732
  human: t.Optional[bool] = None,
2461
2733
  if_primary_term: t.Optional[int] = None,
2462
2734
  if_seq_no: t.Optional[int] = None,
2735
+ include_source_on_error: t.Optional[bool] = None,
2463
2736
  op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
2464
2737
  pipeline: t.Optional[str] = None,
2465
2738
  pretty: t.Optional[bool] = None,
@@ -2478,44 +2751,148 @@ class Elasticsearch(BaseClient):
2478
2751
  ] = None,
2479
2752
  ) -> ObjectApiResponse[t.Any]:
2480
2753
  """
2481
- Index a document. Adds a JSON document to the specified data stream or index
2482
- and makes it searchable. If the target is an index and the document already exists,
2483
- the request updates the document and increments its version.
2484
-
2485
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
2486
-
2487
- :param index: Name of the data stream or index to target.
2754
+ .. raw:: html
2755
+
2756
+ <p>Create or update a document in an index.</p>
2757
+ <p>Add a JSON document to the specified data stream or index and make it searchable.
2758
+ If the target is an index and the document already exists, the request updates the document and increments its version.</p>
2759
+ <p>NOTE: You cannot use this API to send update requests for existing documents in a data stream.</p>
2760
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
2761
+ <ul>
2762
+ <li>To add or overwrite a document using the <code>PUT /&lt;target&gt;/_doc/&lt;_id&gt;</code> request format, you must have the <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
2763
+ <li>To add a document using the <code>POST /&lt;target&gt;/_doc/</code> request format, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
2764
+ <li>To automatically create a data stream or index with this API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
2765
+ </ul>
2766
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
2767
+ <p>NOTE: Replica shards might not all be started when an indexing operation returns successfully.
2768
+ By default, only the primary is required. Set <code>wait_for_active_shards</code> to change this default behavior.</p>
2769
+ <p><strong>Automatically create data streams and indices</strong></p>
2770
+ <p>If the request's target doesn't exist and matches an index template with a <code>data_stream</code> definition, the index operation automatically creates the data stream.</p>
2771
+ <p>If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates.</p>
2772
+ <p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
2773
+ <p>If no mapping exists, the index operation creates a dynamic mapping.
2774
+ By default, new fields and objects are automatically added to the mapping if needed.</p>
2775
+ <p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
2776
+ If it is <code>true</code>, any index can be created automatically.
2777
+ You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to <code>false</code> to turn off automatic index creation entirely.
2778
+ Specify a comma-separated list of patterns you want to allow or prefix each pattern with <code>+</code> or <code>-</code> to indicate whether it should be allowed or blocked.
2779
+ When a list is specified, the default behaviour is to disallow.</p>
2780
+ <p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
2781
+ It does not affect the creation of data streams.</p>
2782
+ <p><strong>Optimistic concurrency control</strong></p>
2783
+ <p>Index operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the <code>if_seq_no</code> and <code>if_primary_term</code> parameters.
2784
+ If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
2785
+ <p><strong>Routing</strong></p>
2786
+ <p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
2787
+ For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the <code>routing</code> parameter.</p>
2788
+ <p>When setting up explicit mapping, you can also use the <code>_routing</code> field to direct the index operation to extract the routing value from the document itself.
2789
+ This does come at the (very minimal) cost of an additional document parsing pass.
2790
+ If the <code>_routing</code> mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted.</p>
2791
+ <p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
2792
+ <p><strong>Distributed</strong></p>
2793
+ <p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
2794
+ After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
2795
+ <p><strong>Active shards</strong></p>
2796
+ <p>To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation.
2797
+ If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs.
2798
+ By default, write operations only wait for the primary shards to be active before proceeding (that is to say <code>wait_for_active_shards</code> is <code>1</code>).
2799
+ This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
2800
+ To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
2801
+ <p>Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is <code>number_of_replicas</code>+1).
2802
+ Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
2803
+ <p>For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes).
2804
+ If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
2805
+ This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data.
2806
+ If <code>wait_for_active_shards</code> is set on the request to <code>3</code> (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding.
2807
+ This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
2808
+ However, if you set <code>wait_for_active_shards</code> to <code>all</code> (or to <code>4</code>, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index.
2809
+ The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
2810
+ <p>It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts.
2811
+ After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary.
2812
+ The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
2813
+ <p><strong>No operation (noop) updates</strong></p>
2814
+ <p>When updating a document by using this API, a new version of the document is always created even if the document hasn't changed.
2815
+ If this isn't acceptable use the <code>_update</code> API with <code>detect_noop</code> set to <code>true</code>.
2816
+ The <code>detect_noop</code> option isn't available on this API because it doesn’t fetch the old source and isn't able to compare it against the new source.</p>
2817
+ <p>There isn't a definitive rule for when noop updates aren't acceptable.
2818
+ It's a combination of lots of factors like how frequently your data source sends updates that are actually noops and how many queries per second Elasticsearch runs on the shard receiving the updates.</p>
2819
+ <p><strong>Versioning</strong></p>
2820
+ <p>Each indexed document is given a version number.
2821
+ By default, internal versioning is used that starts at 1 and increments with each update, deletes included.
2822
+ Optionally, the version number can be set to an external value (for example, if maintained in a database).
2823
+ To enable this functionality, <code>version_type</code> should be set to <code>external</code>.
2824
+ The value provided must be a numeric, long value greater than or equal to 0, and less than around <code>9.2e+18</code>.</p>
2825
+ <p>NOTE: Versioning is completely real time, and is not affected by the near real time aspects of search operations.
2826
+ If no version is provided, the operation runs without any version checks.</p>
2827
+ <p>When using the external version type, the system checks to see if the version number passed to the index request is greater than the version of the currently stored document.
2828
+ If true, the document will be indexed and the new version number used.
2829
+ If the value provided is less than or equal to the stored document's version number, a version conflict will occur and the index operation will fail. For example:</p>
2830
+ <pre><code>PUT my-index-000001/_doc/1?version=2&amp;version_type=external
2831
+ {
2832
+ &quot;user&quot;: {
2833
+ &quot;id&quot;: &quot;elkbee&quot;
2834
+ }
2835
+ }
2836
+
2837
+ In this example, the operation will succeed since the supplied version of 2 is higher than the current document version of 1.
2838
+ If the document was already updated and its version was set to 2 or higher, the indexing command will fail and result in a conflict (409 HTTP status code).
2839
+
2840
+ A nice side effect is that there is no need to maintain strict ordering of async indexing operations run as a result of changes to a source database, as long as version numbers from the source database are used.
2841
+ Even the simple case of updating the Elasticsearch index using data from a database is simplified if external versioning is used, as only the latest version will be used if the index operations arrive out of order.
2842
+ </code></pre>
2843
+
2844
+
2845
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-create>`_
2846
+
2847
+ :param index: The name of the data stream or index to target. If the target doesn't
2848
+ exist and matches the name or wildcard (`*`) pattern of an index template
2849
+ with a `data_stream` definition, this request creates the data stream. If
2850
+ the target doesn't exist and doesn't match a data stream template, this request
2851
+ creates the index. You can check for existing targets with the resolve index
2852
+ API.
2488
2853
  :param document:
2489
- :param id: Unique identifier for the document.
2854
+ :param id: A unique identifier for the document. To automatically generate a
2855
+ document ID, use the `POST /<target>/_doc/` request format and omit this
2856
+ parameter.
2490
2857
  :param if_primary_term: Only perform the operation if the document has this primary
2491
2858
  term.
2492
2859
  :param if_seq_no: Only perform the operation if the document has this sequence
2493
2860
  number.
2494
- :param op_type: Set to create to only index the document if it does not already
2861
+ :param include_source_on_error: True or false if to include the document source
2862
+ in the error message in case of parsing errors.
2863
+ :param op_type: Set to `create` to only index the document if it does not already
2495
2864
  exist (put if absent). If a document with the specified `_id` already exists,
2496
- the indexing operation will fail. Same as using the `<index>/_create` endpoint.
2497
- Valid values: `index`, `create`. If document id is specified, it defaults
2498
- to `index`. Otherwise, it defaults to `create`.
2499
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
2865
+ the indexing operation will fail. The behavior is the same as using the `<index>/_create`
2866
+ endpoint. If a document ID is specified, this paramater defaults to `index`.
2867
+ Otherwise, it defaults to `create`. If the request targets a data stream,
2868
+ an `op_type` of `create` is required.
2869
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
2500
2870
  If the index has a default ingest pipeline specified, then setting the value
2501
2871
  to `_none` disables the default ingest pipeline for this request. If a final
2502
2872
  pipeline is configured it will always run, regardless of the value of this
2503
2873
  parameter.
2504
2874
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
2505
- this operation visible to search, if `wait_for` then wait for a refresh to
2506
- make this operation visible to search, if `false` do nothing with refreshes.
2507
- Valid values: `true`, `false`, `wait_for`.
2875
+ this operation visible to search. If `wait_for`, it waits for a refresh to
2876
+ make this operation visible to search. If `false`, it does nothing with refreshes.
2508
2877
  :param require_alias: If `true`, the destination must be an index alias.
2509
- :param routing: Custom value used to route operations to a specific shard.
2510
- :param timeout: Period the request waits for the following operations: automatic
2511
- index creation, dynamic mapping updates, waiting for active shards.
2512
- :param version: Explicit version number for concurrency control. The specified
2513
- version must match the current version of the document for the request to
2514
- succeed.
2515
- :param version_type: Specific version type: `external`, `external_gte`.
2878
+ :param routing: A custom value that is used to route operations to a specific
2879
+ shard.
2880
+ :param timeout: The period the request waits for the following operations: automatic
2881
+ index creation, dynamic mapping updates, waiting for active shards. This
2882
+ parameter is useful for situations where the primary shard assigned to perform
2883
+ the operation might not be available when the operation runs. Some reasons
2884
+ for this might be that the primary shard is currently recovering from a gateway
2885
+ or undergoing relocation. By default, the operation will wait on the primary
2886
+ shard to become available for at least 1 minute before failing and responding
2887
+ with an error. The actual wait time could be longer, particularly when multiple
2888
+ waits occur.
2889
+ :param version: An explicit version number for concurrency control. It must be
2890
+ a non-negative long number.
2891
+ :param version_type: The version type.
2516
2892
  :param wait_for_active_shards: The number of shard copies that must be active
2517
- before proceeding with the operation. Set to all or any positive integer
2518
- up to the total number of shards in the index (`number_of_replicas+1`).
2893
+ before proceeding with the operation. You can set it to `all` or any positive
2894
+ integer up to the total number of shards in the index (`number_of_replicas+1`).
2895
+ The default value of `1` means it waits for each primary shard to be active.
2519
2896
  """
2520
2897
  if index in SKIP_IN_PATH:
2521
2898
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2547,6 +2924,8 @@ class Elasticsearch(BaseClient):
2547
2924
  __query["if_primary_term"] = if_primary_term
2548
2925
  if if_seq_no is not None:
2549
2926
  __query["if_seq_no"] = if_seq_no
2927
+ if include_source_on_error is not None:
2928
+ __query["include_source_on_error"] = include_source_on_error
2550
2929
  if op_type is not None:
2551
2930
  __query["op_type"] = op_type
2552
2931
  if pipeline is not None:
@@ -2589,104 +2968,17 @@ class Elasticsearch(BaseClient):
2589
2968
  pretty: t.Optional[bool] = None,
2590
2969
  ) -> ObjectApiResponse[t.Any]:
2591
2970
  """
2592
- Get cluster info. Get basic build, version, and cluster information.
2593
-
2594
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/rest-api-root.html>`_
2595
- """
2596
- __path_parts: t.Dict[str, str] = {}
2597
- __path = "/"
2598
- __query: t.Dict[str, t.Any] = {}
2599
- if error_trace is not None:
2600
- __query["error_trace"] = error_trace
2601
- if filter_path is not None:
2602
- __query["filter_path"] = filter_path
2603
- if human is not None:
2604
- __query["human"] = human
2605
- if pretty is not None:
2606
- __query["pretty"] = pretty
2607
- __headers = {"accept": "application/json"}
2608
- return self.perform_request( # type: ignore[return-value]
2609
- "GET",
2610
- __path,
2611
- params=__query,
2612
- headers=__headers,
2613
- endpoint_id="info",
2614
- path_parts=__path_parts,
2615
- )
2616
-
2617
- @_rewrite_parameters(
2618
- body_fields=(
2619
- "knn",
2620
- "docvalue_fields",
2621
- "fields",
2622
- "filter",
2623
- "source",
2624
- "stored_fields",
2625
- ),
2626
- parameter_aliases={"_source": "source"},
2627
- )
2628
- @_stability_warning(Stability.EXPERIMENTAL)
2629
- def knn_search(
2630
- self,
2631
- *,
2632
- index: t.Union[str, t.Sequence[str]],
2633
- knn: t.Optional[t.Mapping[str, t.Any]] = None,
2634
- docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2635
- error_trace: t.Optional[bool] = None,
2636
- fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2637
- filter: t.Optional[
2638
- t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]]
2639
- ] = None,
2640
- filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2641
- human: t.Optional[bool] = None,
2642
- pretty: t.Optional[bool] = None,
2643
- routing: t.Optional[str] = None,
2644
- source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None,
2645
- stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2646
- body: t.Optional[t.Dict[str, t.Any]] = None,
2647
- ) -> ObjectApiResponse[t.Any]:
2648
- """
2649
- Run a knn search. NOTE: The kNN search API has been replaced by the `knn` option
2650
- in the search API. Perform a k-nearest neighbor (kNN) search on a dense_vector
2651
- field and return the matching documents. Given a query vector, the API finds
2652
- the k closest vectors and returns those documents as search hits. Elasticsearch
2653
- uses the HNSW algorithm to support efficient kNN search. Like most kNN algorithms,
2654
- HNSW is an approximate method that sacrifices result accuracy for improved search
2655
- speed. This means the results returned are not always the true k closest neighbors.
2656
- The kNN search API supports restricting the search using a filter. The search
2657
- will return the top k documents that also match the filter query.
2658
-
2659
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
2660
-
2661
- :param index: A comma-separated list of index names to search; use `_all` or
2662
- to perform the operation on all indices
2663
- :param knn: kNN query to execute
2664
- :param docvalue_fields: The request returns doc values for field names matching
2665
- these patterns in the hits.fields property of the response. Accepts wildcard
2666
- (*) patterns.
2667
- :param fields: The request returns values for field names matching these patterns
2668
- in the hits.fields property of the response. Accepts wildcard (*) patterns.
2669
- :param filter: Query to filter the documents that can match. The kNN search will
2670
- return the top `k` documents that also match this filter. The value can be
2671
- a single query or a list of queries. If `filter` isn't provided, all documents
2672
- are allowed to match.
2673
- :param routing: A comma-separated list of specific routing values
2674
- :param source: Indicates which source fields are returned for matching documents.
2675
- These fields are returned in the hits._source property of the search response.
2676
- :param stored_fields: List of stored fields to return as part of a hit. If no
2677
- fields are specified, no stored fields are included in the response. If this
2678
- field is specified, the _source parameter defaults to false. You can pass
2679
- _source: true to return both source fields and stored fields in the search
2680
- response.
2971
+ .. raw:: html
2972
+
2973
+ <p>Get cluster info.
2974
+ Get basic build, version, and cluster information.</p>
2975
+
2976
+
2977
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/group/endpoint-info>`_
2681
2978
  """
2682
- if index in SKIP_IN_PATH:
2683
- raise ValueError("Empty value passed for parameter 'index'")
2684
- if knn is None and body is None:
2685
- raise ValueError("Empty value passed for parameter 'knn'")
2686
- __path_parts: t.Dict[str, str] = {"index": _quote(index)}
2687
- __path = f'/{__path_parts["index"]}/_knn_search'
2979
+ __path_parts: t.Dict[str, str] = {}
2980
+ __path = "/"
2688
2981
  __query: t.Dict[str, t.Any] = {}
2689
- __body: t.Dict[str, t.Any] = body if body is not None else {}
2690
2982
  if error_trace is not None:
2691
2983
  __query["error_trace"] = error_trace
2692
2984
  if filter_path is not None:
@@ -2695,33 +2987,13 @@ class Elasticsearch(BaseClient):
2695
2987
  __query["human"] = human
2696
2988
  if pretty is not None:
2697
2989
  __query["pretty"] = pretty
2698
- if routing is not None:
2699
- __query["routing"] = routing
2700
- if not __body:
2701
- if knn is not None:
2702
- __body["knn"] = knn
2703
- if docvalue_fields is not None:
2704
- __body["docvalue_fields"] = docvalue_fields
2705
- if fields is not None:
2706
- __body["fields"] = fields
2707
- if filter is not None:
2708
- __body["filter"] = filter
2709
- if source is not None:
2710
- __body["_source"] = source
2711
- if stored_fields is not None:
2712
- __body["stored_fields"] = stored_fields
2713
- if not __body:
2714
- __body = None # type: ignore[assignment]
2715
2990
  __headers = {"accept": "application/json"}
2716
- if __body is not None:
2717
- __headers["content-type"] = "application/json"
2718
2991
  return self.perform_request( # type: ignore[return-value]
2719
- "POST",
2992
+ "GET",
2720
2993
  __path,
2721
2994
  params=__query,
2722
2995
  headers=__headers,
2723
- body=__body,
2724
- endpoint_id="knn_search",
2996
+ endpoint_id="info",
2725
2997
  path_parts=__path_parts,
2726
2998
  )
2727
2999
 
@@ -2755,12 +3027,23 @@ class Elasticsearch(BaseClient):
2755
3027
  body: t.Optional[t.Dict[str, t.Any]] = None,
2756
3028
  ) -> ObjectApiResponse[t.Any]:
2757
3029
  """
2758
- Get multiple documents. Get multiple JSON documents by ID from one or more indices.
2759
- If you specify an index in the request URI, you only need to specify the document
2760
- IDs in the request body. To ensure fast responses, this multi get (mget) API
2761
- responds with partial results if one or more shards fail.
3030
+ .. raw:: html
3031
+
3032
+ <p>Get multiple documents.</p>
3033
+ <p>Get multiple JSON documents by ID from one or more indices.
3034
+ If you specify an index in the request URI, you only need to specify the document IDs in the request body.
3035
+ To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail.</p>
3036
+ <p><strong>Filter source fields</strong></p>
3037
+ <p>By default, the <code>_source</code> field is returned for every document (if stored).
3038
+ Use the <code>_source</code> and <code>_source_include</code> or <code>source_exclude</code> attributes to filter what fields are returned for a particular document.
3039
+ You can include the <code>_source</code>, <code>_source_includes</code>, and <code>_source_excludes</code> query parameters in the request URI to specify the defaults to use when there are no per-document instructions.</p>
3040
+ <p><strong>Get stored fields</strong></p>
3041
+ <p>Use the <code>stored_fields</code> attribute to specify the set of stored fields you want to retrieve.
3042
+ Any requested fields that are not stored are ignored.
3043
+ You can include the <code>stored_fields</code> query parameter in the request URI to specify the defaults to use when there are no per-document instructions.</p>
2762
3044
 
2763
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-get.html>`_
3045
+
3046
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-mget>`_
2764
3047
 
2765
3048
  :param index: Name of the index to retrieve documents from when `ids` are specified,
2766
3049
  or when a document in the `docs` array does not specify an index.
@@ -2879,15 +3162,23 @@ class Elasticsearch(BaseClient):
2879
3162
  typed_keys: t.Optional[bool] = None,
2880
3163
  ) -> ObjectApiResponse[t.Any]:
2881
3164
  """
2882
- Run multiple searches. The format of the request is similar to the bulk API format
2883
- and makes use of the newline delimited JSON (NDJSON) format. The structure is
2884
- as follows: ``` header\\n body\\n header\\n body\\n ``` This structure is specifically
2885
- optimized to reduce parsing if a specific search ends up redirected to another
2886
- node. IMPORTANT: The final line of data must end with a newline character `\\n`.
2887
- Each newline character may be preceded by a carriage return `\\r`. When sending
2888
- requests to this endpoint the `Content-Type` header should be set to `application/x-ndjson`.
3165
+ .. raw:: html
3166
+
3167
+ <p>Run multiple searches.</p>
3168
+ <p>The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format.
3169
+ The structure is as follows:</p>
3170
+ <pre><code>header\\n
3171
+ body\\n
3172
+ header\\n
3173
+ body\\n
3174
+ </code></pre>
3175
+ <p>This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node.</p>
3176
+ <p>IMPORTANT: The final line of data must end with a newline character <code>\\n</code>.
3177
+ Each newline character may be preceded by a carriage return <code>\\r</code>.
3178
+ When sending requests to this endpoint the <code>Content-Type</code> header should be set to <code>application/x-ndjson</code>.</p>
2889
3179
 
2890
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
3180
+
3181
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-msearch>`_
2891
3182
 
2892
3183
  :param searches:
2893
3184
  :param index: Comma-separated list of data streams, indices, and index aliases
@@ -2914,7 +3205,8 @@ class Elasticsearch(BaseClient):
2914
3205
  computationally expensive named queries on a large number of hits may add
2915
3206
  significant overhead.
2916
3207
  :param max_concurrent_searches: Maximum number of concurrent searches the multi
2917
- search API can execute.
3208
+ search API can execute. Defaults to `max(1, (# of data nodes * min(search
3209
+ thread pool size, 10)))`.
2918
3210
  :param max_concurrent_shard_requests: Maximum number of concurrent shard requests
2919
3211
  that each sub-search request executes per node.
2920
3212
  :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
@@ -3017,22 +3309,35 @@ class Elasticsearch(BaseClient):
3017
3309
  typed_keys: t.Optional[bool] = None,
3018
3310
  ) -> ObjectApiResponse[t.Any]:
3019
3311
  """
3020
- Run multiple templated searches.
3312
+ .. raw:: html
3313
+
3314
+ <p>Run multiple templated searches.</p>
3315
+ <p>Run multiple templated searches with a single request.
3316
+ If you are providing a text file or text input to <code>curl</code>, use the <code>--data-binary</code> flag instead of <code>-d</code> to preserve newlines.
3317
+ For example:</p>
3318
+ <pre><code>$ cat requests
3319
+ { &quot;index&quot;: &quot;my-index&quot; }
3320
+ { &quot;id&quot;: &quot;my-search-template&quot;, &quot;params&quot;: { &quot;query_string&quot;: &quot;hello world&quot;, &quot;from&quot;: 0, &quot;size&quot;: 10 }}
3321
+ { &quot;index&quot;: &quot;my-other-index&quot; }
3322
+ { &quot;id&quot;: &quot;my-other-search-template&quot;, &quot;params&quot;: { &quot;query_type&quot;: &quot;match_all&quot; }}
3323
+
3324
+ $ curl -H &quot;Content-Type: application/x-ndjson&quot; -XGET localhost:9200/_msearch/template --data-binary &quot;@requests&quot;; echo
3325
+ </code></pre>
3326
+
3021
3327
 
3022
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
3328
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-msearch-template>`_
3023
3329
 
3024
3330
  :param search_templates:
3025
- :param index: Comma-separated list of data streams, indices, and aliases to search.
3026
- Supports wildcards (`*`). To search all data streams and indices, omit this
3027
- parameter or use `*`.
3331
+ :param index: A comma-separated list of data streams, indices, and aliases to
3332
+ search. It supports wildcards (`*`). To search all data streams and indices,
3333
+ omit this parameter or use `*`.
3028
3334
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
3029
3335
  for cross-cluster search requests.
3030
- :param max_concurrent_searches: Maximum number of concurrent searches the API
3031
- can run.
3336
+ :param max_concurrent_searches: The maximum number of concurrent searches the
3337
+ API can run.
3032
3338
  :param rest_total_hits_as_int: If `true`, the response returns `hits.total` as
3033
3339
  an integer. If `false`, it returns `hits.total` as an object.
3034
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
3035
- `dfs_query_then_fetch`.
3340
+ :param search_type: The type of the search operation.
3036
3341
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
3037
3342
  names with their respective types.
3038
3343
  """
@@ -3112,34 +3417,41 @@ class Elasticsearch(BaseClient):
3112
3417
  body: t.Optional[t.Dict[str, t.Any]] = None,
3113
3418
  ) -> ObjectApiResponse[t.Any]:
3114
3419
  """
3115
- Get multiple term vectors. You can specify existing documents by index and ID
3116
- or provide artificial documents in the body of the request. You can specify the
3117
- index in the request body or request URI. The response contains a `docs` array
3118
- with all the fetched termvectors. Each element has the structure provided by
3119
- the termvectors API.
3420
+ .. raw:: html
3421
+
3422
+ <p>Get multiple term vectors.</p>
3423
+ <p>Get multiple term vectors with a single request.
3424
+ You can specify existing documents by index and ID or provide artificial documents in the body of the request.
3425
+ You can specify the index in the request body or request URI.
3426
+ The response contains a <code>docs</code> array with all the fetched termvectors.
3427
+ Each element has the structure provided by the termvectors API.</p>
3428
+ <p><strong>Artificial documents</strong></p>
3429
+ <p>You can also use <code>mtermvectors</code> to generate term vectors for artificial documents provided in the body of the request.
3430
+ The mapping used is determined by the specified <code>_index</code>.</p>
3120
3431
 
3121
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-termvectors.html>`_
3122
3432
 
3123
- :param index: Name of the index that contains the documents.
3124
- :param docs: Array of existing or artificial documents.
3433
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-mtermvectors>`_
3434
+
3435
+ :param index: The name of the index that contains the documents.
3436
+ :param docs: An array of existing or artificial documents.
3125
3437
  :param field_statistics: If `true`, the response includes the document count,
3126
3438
  sum of document frequencies, and sum of total term frequencies.
3127
- :param fields: Comma-separated list or wildcard expressions of fields to include
3128
- in the statistics. Used as the default list unless a specific field list
3129
- is provided in the `completion_fields` or `fielddata_fields` parameters.
3130
- :param ids: Simplified syntax to specify documents by their ID if they're in
3439
+ :param fields: A comma-separated list or wildcard expressions of fields to include
3440
+ in the statistics. It is used as the default list unless a specific field
3441
+ list is provided in the `completion_fields` or `fielddata_fields` parameters.
3442
+ :param ids: A simplified syntax to specify documents by their ID if they're in
3131
3443
  the same index.
3132
3444
  :param offsets: If `true`, the response includes term offsets.
3133
3445
  :param payloads: If `true`, the response includes term payloads.
3134
3446
  :param positions: If `true`, the response includes term positions.
3135
- :param preference: Specifies the node or shard the operation should be performed
3136
- on. Random by default.
3447
+ :param preference: The node or shard the operation should be performed on. It
3448
+ is random by default.
3137
3449
  :param realtime: If true, the request is real-time as opposed to near-real-time.
3138
- :param routing: Custom value used to route operations to a specific shard.
3450
+ :param routing: A custom value used to route operations to a specific shard.
3139
3451
  :param term_statistics: If true, the response includes term frequency and document
3140
3452
  frequency.
3141
3453
  :param version: If `true`, returns the document version as part of a hit.
3142
- :param version_type: Specific version type.
3454
+ :param version_type: The version type.
3143
3455
  """
3144
3456
  __path_parts: t.Dict[str, str]
3145
3457
  if index not in SKIP_IN_PATH:
@@ -3222,42 +3534,68 @@ class Elasticsearch(BaseClient):
3222
3534
  human: t.Optional[bool] = None,
3223
3535
  ignore_unavailable: t.Optional[bool] = None,
3224
3536
  index_filter: t.Optional[t.Mapping[str, t.Any]] = None,
3537
+ max_concurrent_shard_requests: t.Optional[int] = None,
3225
3538
  preference: t.Optional[str] = None,
3226
3539
  pretty: t.Optional[bool] = None,
3227
3540
  routing: t.Optional[str] = None,
3228
3541
  body: t.Optional[t.Dict[str, t.Any]] = None,
3229
3542
  ) -> ObjectApiResponse[t.Any]:
3230
3543
  """
3231
- Open a point in time. A search request by default runs against the most recent
3232
- visible data of the target indices, which is called point in time. Elasticsearch
3233
- pit (point in time) is a lightweight view into the state of the data as it existed
3234
- when initiated. In some cases, it’s preferred to perform multiple search requests
3235
- using the same point in time. For example, if refreshes happen between `search_after`
3236
- requests, then the results of those requests might not be consistent as changes
3237
- happening between searches are only visible to the more recent point in time.
3238
- A point in time must be opened explicitly before being used in search requests.
3239
- The `keep_alive` parameter tells Elasticsearch how long it should persist.
3240
-
3241
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
3544
+ .. raw:: html
3545
+
3546
+ <p>Open a point in time.</p>
3547
+ <p>A search request by default runs against the most recent visible data of the target indices,
3548
+ which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the
3549
+ state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple
3550
+ search requests using the same point in time. For example, if refreshes happen between
3551
+ <code>search_after</code> requests, then the results of those requests might not be consistent as changes happening
3552
+ between searches are only visible to the more recent point in time.</p>
3553
+ <p>A point in time must be opened explicitly before being used in search requests.</p>
3554
+ <p>A subsequent search request with the <code>pit</code> parameter must not specify <code>index</code>, <code>routing</code>, or <code>preference</code> values as these parameters are copied from the point in time.</p>
3555
+ <p>Just like regular searches, you can use <code>from</code> and <code>size</code> to page through point in time search results, up to the first 10,000 hits.
3556
+ If you want to retrieve more hits, use PIT with <code>search_after</code>.</p>
3557
+ <p>IMPORTANT: The open point in time request and each subsequent search request can return different identifiers; always use the most recently received ID for the next search request.</p>
3558
+ <p>When a PIT that contains shard failures is used in a search request, the missing are always reported in the search response as a <code>NoShardAvailableActionException</code> exception.
3559
+ To get rid of these exceptions, a new PIT needs to be created so that shards missing from the previous PIT can be handled, assuming they become available in the meantime.</p>
3560
+ <p><strong>Keeping point in time alive</strong></p>
3561
+ <p>The <code>keep_alive</code> parameter, which is passed to a open point in time request and search request, extends the time to live of the corresponding point in time.
3562
+ The value does not need to be long enough to process all data — it just needs to be long enough for the next request.</p>
3563
+ <p>Normally, the background merge process optimizes the index by merging together smaller segments to create new, bigger segments.
3564
+ Once the smaller segments are no longer needed they are deleted.
3565
+ However, open point-in-times prevent the old segments from being deleted since they are still in use.</p>
3566
+ <p>TIP: Keeping older segments alive means that more disk space and file handles are needed.
3567
+ Ensure that you have configured your nodes to have ample free file handles.</p>
3568
+ <p>Additionally, if a segment contains deleted or updated documents then the point in time must keep track of whether each document in the segment was live at the time of the initial search request.
3569
+ Ensure that your nodes have sufficient heap space if you have many open point-in-times on an index that is subject to ongoing deletes or updates.
3570
+ Note that a point-in-time doesn't prevent its associated indices from being deleted.
3571
+ You can check how many point-in-times (that is, search contexts) are open with the nodes stats API.</p>
3572
+
3573
+
3574
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-open-point-in-time>`_
3242
3575
 
3243
3576
  :param index: A comma-separated list of index names to open point in time; use
3244
3577
  `_all` or empty string to perform the operation on all indices
3245
- :param keep_alive: Extends the time to live of the corresponding point in time.
3246
- :param allow_partial_search_results: If `false`, creating a point in time request
3247
- when a shard is missing or unavailable will throw an exception. If `true`,
3248
- the point in time will contain all the shards that are available at the time
3249
- of the request.
3250
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
3251
- request can target data streams, this argument determines whether wildcard
3252
- expressions match hidden data streams. Supports comma-separated values, such
3253
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
3578
+ :param keep_alive: Extend the length of time that the point in time persists.
3579
+ :param allow_partial_search_results: Indicates whether the point in time tolerates
3580
+ unavailable shards or shard failures when initially creating the PIT. If
3581
+ `false`, creating a point in time request when a shard is missing or unavailable
3582
+ will throw an exception. If `true`, the point in time will contain all the
3583
+ shards that are available at the time of the request.
3584
+ :param expand_wildcards: The type of index that wildcard patterns can match.
3585
+ If the request can target data streams, this argument determines whether
3586
+ wildcard expressions match hidden data streams. It supports comma-separated
3587
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
3588
+ `hidden`, `none`.
3254
3589
  :param ignore_unavailable: If `false`, the request returns an error if it targets
3255
3590
  a missing or closed index.
3256
- :param index_filter: Allows to filter indices if the provided query rewrites
3257
- to `match_none` on every shard.
3258
- :param preference: Specifies the node or shard the operation should be performed
3259
- on. Random by default.
3260
- :param routing: Custom value used to route operations to a specific shard.
3591
+ :param index_filter: Filter indices if the provided query rewrites to `match_none`
3592
+ on every shard.
3593
+ :param max_concurrent_shard_requests: Maximum number of concurrent shard requests
3594
+ that each sub-search request executes per node.
3595
+ :param preference: The node or shard the operation should be performed on. By
3596
+ default, it is random.
3597
+ :param routing: A custom value that is used to route operations to a specific
3598
+ shard.
3261
3599
  """
3262
3600
  if index in SKIP_IN_PATH:
3263
3601
  raise ValueError("Empty value passed for parameter 'index'")
@@ -3281,6 +3619,8 @@ class Elasticsearch(BaseClient):
3281
3619
  __query["human"] = human
3282
3620
  if ignore_unavailable is not None:
3283
3621
  __query["ignore_unavailable"] = ignore_unavailable
3622
+ if max_concurrent_shard_requests is not None:
3623
+ __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
3284
3624
  if preference is not None:
3285
3625
  __query["preference"] = preference
3286
3626
  if pretty is not None:
@@ -3323,23 +3663,27 @@ class Elasticsearch(BaseClient):
3323
3663
  body: t.Optional[t.Dict[str, t.Any]] = None,
3324
3664
  ) -> ObjectApiResponse[t.Any]:
3325
3665
  """
3326
- Create or update a script or search template. Creates or updates a stored script
3327
- or search template.
3328
-
3329
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
3330
-
3331
- :param id: Identifier for the stored script or search template. Must be unique
3332
- within the cluster.
3333
- :param script: Contains the script or search template, its parameters, and its
3334
- language.
3335
- :param context: Context in which the script or search template should run. To
3336
- prevent errors, the API immediately compiles the script or template in this
3337
- context.
3338
- :param master_timeout: Period to wait for a connection to the master node. If
3339
- no response is received before the timeout expires, the request fails and
3340
- returns an error.
3341
- :param timeout: Period to wait for a response. If no response is received before
3342
- the timeout expires, the request fails and returns an error.
3666
+ .. raw:: html
3667
+
3668
+ <p>Create or update a script or search template.
3669
+ Creates or updates a stored script or search template.</p>
3670
+
3671
+
3672
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-put-script>`_
3673
+
3674
+ :param id: The identifier for the stored script or search template. It must be
3675
+ unique within the cluster.
3676
+ :param script: The script or search template, its parameters, and its language.
3677
+ :param context: The context in which the script or search template should run.
3678
+ To prevent errors, the API immediately compiles the script or template in
3679
+ this context.
3680
+ :param master_timeout: The period to wait for a connection to the master node.
3681
+ If no response is received before the timeout expires, the request fails
3682
+ and returns an error. It can also be set to `-1` to indicate that the request
3683
+ should never timeout.
3684
+ :param timeout: The period to wait for a response. If no response is received
3685
+ before the timeout expires, the request fails and returns an error. It can
3686
+ also be set to `-1` to indicate that the request should never timeout.
3343
3687
  """
3344
3688
  if id in SKIP_IN_PATH:
3345
3689
  raise ValueError("Empty value passed for parameter 'id'")
@@ -3409,14 +3753,17 @@ class Elasticsearch(BaseClient):
3409
3753
  body: t.Optional[t.Dict[str, t.Any]] = None,
3410
3754
  ) -> ObjectApiResponse[t.Any]:
3411
3755
  """
3412
- Evaluate ranked search results. Evaluate the quality of ranked search results
3413
- over a set of typical search queries.
3756
+ .. raw:: html
3757
+
3758
+ <p>Evaluate ranked search results.</p>
3759
+ <p>Evaluate the quality of ranked search results over a set of typical search queries.</p>
3414
3760
 
3415
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-rank-eval.html>`_
3761
+
3762
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rank-eval>`_
3416
3763
 
3417
3764
  :param requests: A set of typical search requests, together with their provided
3418
3765
  ratings.
3419
- :param index: Comma-separated list of data streams, indices, and index aliases
3766
+ :param index: A comma-separated list of data streams, indices, and index aliases
3420
3767
  used to limit the request. Wildcard (`*`) expressions are supported. To target
3421
3768
  all data streams and indices in a cluster, omit this parameter or use `_all`
3422
3769
  or `*`.
@@ -3504,33 +3851,187 @@ class Elasticsearch(BaseClient):
3504
3851
  body: t.Optional[t.Dict[str, t.Any]] = None,
3505
3852
  ) -> ObjectApiResponse[t.Any]:
3506
3853
  """
3507
- Reindex documents. Copies documents from a source to a destination. The source
3508
- can be any existing index, alias, or data stream. The destination must differ
3509
- from the source. For example, you cannot reindex a data stream into itself.
3510
-
3511
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3854
+ .. raw:: html
3855
+
3856
+ <p>Reindex documents.</p>
3857
+ <p>Copy documents from a source to a destination.
3858
+ You can copy all documents to the destination index or reindex a subset of the documents.
3859
+ The source can be any existing index, alias, or data stream.
3860
+ The destination must differ from the source.
3861
+ For example, you cannot reindex a data stream into itself.</p>
3862
+ <p>IMPORTANT: Reindex requires <code>_source</code> to be enabled for all documents in the source.
3863
+ The destination should be configured as wanted before calling the reindex API.
3864
+ Reindex does not copy the settings from the source or its associated template.
3865
+ Mappings, shard counts, and replicas, for example, must be configured ahead of time.</p>
3866
+ <p>If the Elasticsearch security features are enabled, you must have the following security privileges:</p>
3867
+ <ul>
3868
+ <li>The <code>read</code> index privilege for the source data stream, index, or alias.</li>
3869
+ <li>The <code>write</code> index privilege for the destination data stream, index, or index alias.</li>
3870
+ <li>To automatically create a data stream or index with a reindex API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege for the destination data stream, index, or alias.</li>
3871
+ <li>If reindexing from a remote cluster, the <code>source.remote.user</code> must have the <code>monitor</code> cluster privilege and the <code>read</code> index privilege for the source data stream, index, or alias.</li>
3872
+ </ul>
3873
+ <p>If reindexing from a remote cluster, you must explicitly allow the remote host in the <code>reindex.remote.whitelist</code> setting.
3874
+ Automatic data stream creation requires a matching index template with data stream enabled.</p>
3875
+ <p>The <code>dest</code> element can be configured like the index API to control optimistic concurrency control.
3876
+ Omitting <code>version_type</code> or setting it to <code>internal</code> causes Elasticsearch to blindly dump documents into the destination, overwriting any that happen to have the same ID.</p>
3877
+ <p>Setting <code>version_type</code> to <code>external</code> causes Elasticsearch to preserve the <code>version</code> from the source, create any documents that are missing, and update any documents that have an older version in the destination than they do in the source.</p>
3878
+ <p>Setting <code>op_type</code> to <code>create</code> causes the reindex API to create only missing documents in the destination.
3879
+ All existing documents will cause a version conflict.</p>
3880
+ <p>IMPORTANT: Because data streams are append-only, any reindex request to a destination data stream must have an <code>op_type</code> of <code>create</code>.
3881
+ A reindex can only add new documents to a destination data stream.
3882
+ It cannot update existing documents in a destination data stream.</p>
3883
+ <p>By default, version conflicts abort the reindex process.
3884
+ To continue reindexing if there are conflicts, set the <code>conflicts</code> request body property to <code>proceed</code>.
3885
+ In this case, the response includes a count of the version conflicts that were encountered.
3886
+ Note that the handling of other error types is unaffected by the <code>conflicts</code> property.
3887
+ Additionally, if you opt to count version conflicts, the operation could attempt to reindex more documents from the source than <code>max_docs</code> until it has successfully indexed <code>max_docs</code> documents into the target or it has gone through every document in the source query.</p>
3888
+ <p>NOTE: The reindex API makes no effort to handle ID collisions.
3889
+ The last document written will &quot;win&quot; but the order isn't usually predictable so it is not a good idea to rely on this behavior.
3890
+ Instead, make sure that IDs are unique by using a script.</p>
3891
+ <p><strong>Running reindex asynchronously</strong></p>
3892
+ <p>If the request contains <code>wait_for_completion=false</code>, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task.
3893
+ Elasticsearch creates a record of this task as a document at <code>_tasks/&lt;task_id&gt;</code>.</p>
3894
+ <p><strong>Reindex from multiple sources</strong></p>
3895
+ <p>If you have many sources to reindex it is generally better to reindex them one at a time rather than using a glob pattern to pick up multiple sources.
3896
+ That way you can resume the process if there are any errors by removing the partially completed source and starting over.
3897
+ It also makes parallelizing the process fairly simple: split the list of sources to reindex and run each list in parallel.</p>
3898
+ <p>For example, you can use a bash script like this:</p>
3899
+ <pre><code>for index in i1 i2 i3 i4 i5; do
3900
+ curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{
3901
+ &quot;source&quot;: {
3902
+ &quot;index&quot;: &quot;'$index'&quot;
3903
+ },
3904
+ &quot;dest&quot;: {
3905
+ &quot;index&quot;: &quot;'$index'-reindexed&quot;
3906
+ }
3907
+ }'
3908
+ done
3909
+ </code></pre>
3910
+ <p><strong>Throttling</strong></p>
3911
+ <p>Set <code>requests_per_second</code> to any positive decimal number (<code>1.4</code>, <code>6</code>, <code>1000</code>, for example) to throttle the rate at which reindex issues batches of index operations.
3912
+ Requests are throttled by padding each batch with a wait time.
3913
+ To turn off throttling, set <code>requests_per_second</code> to <code>-1</code>.</p>
3914
+ <p>The throttling is done by waiting between batches so that the scroll that reindex uses internally can be given a timeout that takes into account the padding.
3915
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
3916
+ By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
3917
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
3918
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
3919
+ </code></pre>
3920
+ <p>Since the batch is issued as a single bulk request, large batch sizes cause Elasticsearch to create many requests and then wait for a while before starting the next set.
3921
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
3922
+ <p><strong>Slicing</strong></p>
3923
+ <p>Reindex supports sliced scroll to parallelize the reindexing process.
3924
+ This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
3925
+ <p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
3926
+ <p>You can slice a reindex request manually by providing a slice ID and total number of slices to each request.
3927
+ You can also let reindex automatically parallelize by using sliced scroll to slice on <code>_id</code>.
3928
+ The <code>slices</code> parameter specifies the number of slices to use.</p>
3929
+ <p>Adding <code>slices</code> to the reindex request just automates the manual process, creating sub-requests which means it has some quirks:</p>
3930
+ <ul>
3931
+ <li>You can see these requests in the tasks API. These sub-requests are &quot;child&quot; tasks of the task for the request with slices.</li>
3932
+ <li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
3933
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
3934
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
3935
+ <li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
3936
+ <li>Due to the nature of <code>slices</code>, each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
3937
+ <li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with <code>slices</code> are distributed proportionally to each sub-request. Combine that with the previous point about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being reindexed.</li>
3938
+ <li>Each sub-request gets a slightly different snapshot of the source, though these are all taken at approximately the same time.</li>
3939
+ </ul>
3940
+ <p>If slicing automatically, setting <code>slices</code> to <code>auto</code> will choose a reasonable number for most indices.
3941
+ If slicing manually or otherwise tuning automatic slicing, use the following guidelines.</p>
3942
+ <p>Query performance is most efficient when the number of slices is equal to the number of shards in the index.
3943
+ If that number is large (for example, <code>500</code>), choose a lower number as too many slices will hurt performance.
3944
+ Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</p>
3945
+ <p>Indexing performance scales linearly across available resources with the number of slices.</p>
3946
+ <p>Whether query or indexing performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
3947
+ <p><strong>Modify documents during reindexing</strong></p>
3948
+ <p>Like <code>_update_by_query</code>, reindex operations support a script that modifies the document.
3949
+ Unlike <code>_update_by_query</code>, the script is allowed to modify the document's metadata.</p>
3950
+ <p>Just as in <code>_update_by_query</code>, you can set <code>ctx.op</code> to change the operation that is run on the destination.
3951
+ For example, set <code>ctx.op</code> to <code>noop</code> if your script decides that the document doesn’t have to be indexed in the destination. This &quot;no operation&quot; will be reported in the <code>noop</code> counter in the response body.
3952
+ Set <code>ctx.op</code> to <code>delete</code> if your script decides that the document must be deleted from the destination.
3953
+ The deletion will be reported in the <code>deleted</code> counter in the response body.
3954
+ Setting <code>ctx.op</code> to anything else will return an error, as will setting any other field in <code>ctx</code>.</p>
3955
+ <p>Think of the possibilities! Just be careful; you are able to change:</p>
3956
+ <ul>
3957
+ <li><code>_id</code></li>
3958
+ <li><code>_index</code></li>
3959
+ <li><code>_version</code></li>
3960
+ <li><code>_routing</code></li>
3961
+ </ul>
3962
+ <p>Setting <code>_version</code> to <code>null</code> or clearing it from the <code>ctx</code> map is just like not sending the version in an indexing request.
3963
+ It will cause the document to be overwritten in the destination regardless of the version on the target or the version type you use in the reindex API.</p>
3964
+ <p><strong>Reindex from remote</strong></p>
3965
+ <p>Reindex supports reindexing from a remote Elasticsearch cluster.
3966
+ The <code>host</code> parameter must contain a scheme, host, port, and optional path.
3967
+ The <code>username</code> and <code>password</code> parameters are optional and when they are present the reindex operation will connect to the remote Elasticsearch node using basic authentication.
3968
+ Be sure to use HTTPS when using basic authentication or the password will be sent in plain text.
3969
+ There are a range of settings available to configure the behavior of the HTTPS connection.</p>
3970
+ <p>When using Elastic Cloud, it is also possible to authenticate against the remote cluster through the use of a valid API key.
3971
+ Remote hosts must be explicitly allowed with the <code>reindex.remote.whitelist</code> setting.
3972
+ It can be set to a comma delimited list of allowed remote host and port combinations.
3973
+ Scheme is ignored; only the host and port are used.
3974
+ For example:</p>
3975
+ <pre><code>reindex.remote.whitelist: [otherhost:9200, another:9200, 127.0.10.*:9200, localhost:*&quot;]
3976
+ </code></pre>
3977
+ <p>The list of allowed hosts must be configured on any nodes that will coordinate the reindex.
3978
+ This feature should work with remote clusters of any version of Elasticsearch.
3979
+ This should enable you to upgrade from any version of Elasticsearch to the current version by reindexing from a cluster of the old version.</p>
3980
+ <p>WARNING: Elasticsearch does not support forward compatibility across major versions.
3981
+ For example, you cannot reindex from a 7.x cluster into a 6.x cluster.</p>
3982
+ <p>To enable queries sent to older versions of Elasticsearch, the <code>query</code> parameter is sent directly to the remote host without validation or modification.</p>
3983
+ <p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
3984
+ <p>Reindexing from a remote server uses an on-heap buffer that defaults to a maximum size of 100mb.
3985
+ If the remote index includes very large documents you'll need to use a smaller batch size.
3986
+ It is also possible to set the socket read timeout on the remote connection with the <code>socket_timeout</code> field and the connection timeout with the <code>connect_timeout</code> field.
3987
+ Both default to 30 seconds.</p>
3988
+ <p><strong>Configuring SSL parameters</strong></p>
3989
+ <p>Reindex from remote supports configurable SSL settings.
3990
+ These must be specified in the <code>elasticsearch.yml</code> file, with the exception of the secure settings, which you add in the Elasticsearch keystore.
3991
+ It is not possible to configure SSL in the body of the reindex request.</p>
3992
+
3993
+
3994
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-reindex>`_
3512
3995
 
3513
3996
  :param dest: The destination you are copying to.
3514
3997
  :param source: The source you are copying from.
3515
- :param conflicts: Set to proceed to continue reindexing even if there are conflicts.
3516
- :param max_docs: The maximum number of documents to reindex.
3998
+ :param conflicts: Indicates whether to continue reindexing even when there are
3999
+ conflicts.
4000
+ :param max_docs: The maximum number of documents to reindex. By default, all
4001
+ documents are reindexed. If it is a value less then or equal to `scroll_size`,
4002
+ a scroll will not be used to retrieve the results for the operation. If `conflicts`
4003
+ is set to `proceed`, the reindex operation could attempt to reindex more
4004
+ documents from the source than `max_docs` until it has successfully indexed
4005
+ `max_docs` documents into the target or it has gone through every document
4006
+ in the source query.
3517
4007
  :param refresh: If `true`, the request refreshes affected shards to make this
3518
4008
  operation visible to search.
3519
4009
  :param requests_per_second: The throttle for this request in sub-requests per
3520
- second. Defaults to no throttle.
4010
+ second. By default, there is no throttle.
3521
4011
  :param require_alias: If `true`, the destination must be an index alias.
3522
4012
  :param script: The script to run to update the document source or metadata when
3523
4013
  reindexing.
3524
- :param scroll: Specifies how long a consistent view of the index should be maintained
3525
- for scrolled search.
4014
+ :param scroll: The period of time that a consistent view of the index should
4015
+ be maintained for scrolled search.
3526
4016
  :param size:
3527
- :param slices: The number of slices this task should be divided into. Defaults
3528
- to 1 slice, meaning the task isnt sliced into subtasks.
3529
- :param timeout: Period each indexing waits for automatic index creation, dynamic
3530
- mapping updates, and waiting for active shards.
4017
+ :param slices: The number of slices this task should be divided into. It defaults
4018
+ to one slice, which means the task isn't sliced into subtasks. Reindex supports
4019
+ sliced scroll to parallelize the reindexing process. This parallelization
4020
+ can improve efficiency and provide a convenient way to break the request
4021
+ down into smaller parts. NOTE: Reindexing from remote clusters does not support
4022
+ manual or automatic slicing. If set to `auto`, Elasticsearch chooses the
4023
+ number of slices to use. This setting will use one slice per shard, up to
4024
+ a certain limit. If there are multiple sources, it will choose the number
4025
+ of slices based on the index or backing index with the smallest number of
4026
+ shards.
4027
+ :param timeout: The period each indexing waits for automatic index creation,
4028
+ dynamic mapping updates, and waiting for active shards. By default, Elasticsearch
4029
+ waits for at least one minute before failing. The actual wait time could
4030
+ be longer, particularly when multiple waits occur.
3531
4031
  :param wait_for_active_shards: The number of shard copies that must be active
3532
- before proceeding with the operation. Set to `all` or any positive integer
3533
- up to the total number of shards in the index (`number_of_replicas+1`).
4032
+ before proceeding with the operation. Set it to `all` or any positive integer
4033
+ up to the total number of shards in the index (`number_of_replicas+1`). The
4034
+ default value is one, which means it waits for each primary shard to be active.
3534
4035
  :param wait_for_completion: If `true`, the request blocks until the operation
3535
4036
  is complete.
3536
4037
  """
@@ -3602,14 +4103,24 @@ class Elasticsearch(BaseClient):
3602
4103
  requests_per_second: t.Optional[float] = None,
3603
4104
  ) -> ObjectApiResponse[t.Any]:
3604
4105
  """
3605
- Throttle a reindex operation. Change the number of requests per second for a
3606
- particular reindex operation.
4106
+ .. raw:: html
4107
+
4108
+ <p>Throttle a reindex operation.</p>
4109
+ <p>Change the number of requests per second for a particular reindex operation.
4110
+ For example:</p>
4111
+ <pre><code>POST _reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
4112
+ </code></pre>
4113
+ <p>Rethrottling that speeds up the query takes effect immediately.
4114
+ Rethrottling that slows down the query will take effect after completing the current batch.
4115
+ This behavior prevents scroll timeouts.</p>
3607
4116
 
3608
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3609
4117
 
3610
- :param task_id: Identifier for the task.
4118
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-reindex>`_
4119
+
4120
+ :param task_id: The task identifier, which can be found by using the tasks API.
3611
4121
  :param requests_per_second: The throttle for this request in sub-requests per
3612
- second.
4122
+ second. It can be either `-1` to turn off throttling or any decimal number
4123
+ like `1.7` or `12` to throttle to that level.
3613
4124
  """
3614
4125
  if task_id in SKIP_IN_PATH:
3615
4126
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -3650,21 +4161,25 @@ class Elasticsearch(BaseClient):
3650
4161
  human: t.Optional[bool] = None,
3651
4162
  params: t.Optional[t.Mapping[str, t.Any]] = None,
3652
4163
  pretty: t.Optional[bool] = None,
3653
- source: t.Optional[str] = None,
4164
+ source: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,
3654
4165
  body: t.Optional[t.Dict[str, t.Any]] = None,
3655
4166
  ) -> ObjectApiResponse[t.Any]:
3656
4167
  """
3657
- Render a search template. Render a search template as a search request body.
4168
+ .. raw:: html
3658
4169
 
3659
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/render-search-template-api.html>`_
4170
+ <p>Render a search template.</p>
4171
+ <p>Render a search template as a search request body.</p>
3660
4172
 
3661
- :param id: ID of the search template to render. If no `source` is specified,
4173
+
4174
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-render-search-template>`_
4175
+
4176
+ :param id: The ID of the search template to render. If no `source` is specified,
3662
4177
  this or the `id` request body parameter is required.
3663
4178
  :param file:
3664
4179
  :param params: Key-value pairs used to replace Mustache variables in the template.
3665
4180
  The key is the variable name. The value is the variable value.
3666
- :param source: An inline search template. Supports the same parameters as the
3667
- search API's request body. These parameters also support Mustache variables.
4181
+ :param source: An inline search template. It supports the same parameters as
4182
+ the search API's request body. These parameters also support Mustache variables.
3668
4183
  If no `id` or `<templated-id>` is specified, this parameter is required.
3669
4184
  """
3670
4185
  __path_parts: t.Dict[str, str]
@@ -3713,7 +4228,24 @@ class Elasticsearch(BaseClient):
3713
4228
  def scripts_painless_execute(
3714
4229
  self,
3715
4230
  *,
3716
- context: t.Optional[str] = None,
4231
+ context: t.Optional[
4232
+ t.Union[
4233
+ str,
4234
+ t.Literal[
4235
+ "boolean_field",
4236
+ "composite_field",
4237
+ "date_field",
4238
+ "double_field",
4239
+ "filter",
4240
+ "geo_point_field",
4241
+ "ip_field",
4242
+ "keyword_field",
4243
+ "long_field",
4244
+ "painless_test",
4245
+ "score",
4246
+ ],
4247
+ ]
4248
+ ] = None,
3717
4249
  context_setup: t.Optional[t.Mapping[str, t.Any]] = None,
3718
4250
  error_trace: t.Optional[bool] = None,
3719
4251
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -3723,13 +4255,24 @@ class Elasticsearch(BaseClient):
3723
4255
  body: t.Optional[t.Dict[str, t.Any]] = None,
3724
4256
  ) -> ObjectApiResponse[t.Any]:
3725
4257
  """
3726
- Run a script. Runs a script and returns a result.
4258
+ .. raw:: html
3727
4259
 
3728
- `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-execute-api.html>`_
4260
+ <p>Run a script.</p>
4261
+ <p>Runs a script and returns a result.
4262
+ Use this API to build and test scripts, such as when defining a script for a runtime field.
4263
+ This API requires very few dependencies and is especially useful if you don't have permissions to write documents on a cluster.</p>
4264
+ <p>The API uses several <em>contexts</em>, which control how scripts are run, what variables are available at runtime, and what the return type is.</p>
4265
+ <p>Each context requires a script, but additional parameters depend on the context you're using for that script.</p>
3729
4266
 
3730
- :param context: The context that the script should run in.
3731
- :param context_setup: Additional parameters for the `context`.
3732
- :param script: The Painless script to execute.
4267
+
4268
+ `<https://www.elastic.co/docs/reference/scripting-languages/painless/painless-api-examples>`_
4269
+
4270
+ :param context: The context that the script should run in. NOTE: Result ordering
4271
+ in the field contexts is not guaranteed.
4272
+ :param context_setup: Additional parameters for the `context`. NOTE: This parameter
4273
+ is required for all contexts except `painless_test`, which is the default
4274
+ if no value is provided for `context`.
4275
+ :param script: The Painless script to run.
3733
4276
  """
3734
4277
  __path_parts: t.Dict[str, str] = {}
3735
4278
  __path = "/_scripts/painless/_execute"
@@ -3781,30 +4324,27 @@ class Elasticsearch(BaseClient):
3781
4324
  body: t.Optional[t.Dict[str, t.Any]] = None,
3782
4325
  ) -> ObjectApiResponse[t.Any]:
3783
4326
  """
3784
- Run a scrolling search. IMPORTANT: The scroll API is no longer recommend for
3785
- deep pagination. If you need to preserve the index state while paging through
3786
- more than 10,000 hits, use the `search_after` parameter with a point in time
3787
- (PIT). The scroll API gets large sets of results from a single scrolling search
3788
- request. To get the necessary scroll ID, submit a search API request that includes
3789
- an argument for the `scroll` query parameter. The `scroll` parameter indicates
3790
- how long Elasticsearch should retain the search context for the request. The
3791
- search response returns a scroll ID in the `_scroll_id` response body parameter.
3792
- You can then use the scroll ID with the scroll API to retrieve the next batch
3793
- of results for the request. If the Elasticsearch security features are enabled,
3794
- the access to the results of a specific scroll ID is restricted to the user or
3795
- API key that submitted the search. You can also use the scroll API to specify
3796
- a new scroll parameter that extends or shortens the retention period for the
3797
- search context. IMPORTANT: Results from a scrolling search reflect the state
3798
- of the index at the time of the initial search request. Subsequent indexing or
3799
- document changes only affect later search and scroll requests.
3800
-
3801
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-request-body.html#request-body-search-scroll>`_
3802
-
3803
- :param scroll_id: Scroll ID of the search.
4327
+ .. raw:: html
4328
+
4329
+ <p>Run a scrolling search.</p>
4330
+ <p>IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the <code>search_after</code> parameter with a point in time (PIT).</p>
4331
+ <p>The scroll API gets large sets of results from a single scrolling search request.
4332
+ To get the necessary scroll ID, submit a search API request that includes an argument for the <code>scroll</code> query parameter.
4333
+ The <code>scroll</code> parameter indicates how long Elasticsearch should retain the search context for the request.
4334
+ The search response returns a scroll ID in the <code>_scroll_id</code> response body parameter.
4335
+ You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request.
4336
+ If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.</p>
4337
+ <p>You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.</p>
4338
+ <p>IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.</p>
4339
+
4340
+
4341
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-scroll>`_
4342
+
4343
+ :param scroll_id: The scroll ID of the search.
3804
4344
  :param rest_total_hits_as_int: If true, the API response’s hit.total property
3805
4345
  is returned as an integer. If false, the API response’s hit.total property
3806
4346
  is returned as an object.
3807
- :param scroll: Period to retain the search context for scrolling.
4347
+ :param scroll: The period to retain the search context for scrolling.
3808
4348
  """
3809
4349
  if scroll_id is None and body is None:
3810
4350
  raise ValueError("Empty value passed for parameter 'scroll_id'")
@@ -3929,7 +4469,6 @@ class Elasticsearch(BaseClient):
3929
4469
  ] = None,
3930
4470
  lenient: t.Optional[bool] = None,
3931
4471
  max_concurrent_shard_requests: t.Optional[int] = None,
3932
- min_compatible_shard_node: t.Optional[str] = None,
3933
4472
  min_score: t.Optional[float] = None,
3934
4473
  pit: t.Optional[t.Mapping[str, t.Any]] = None,
3935
4474
  post_filter: t.Optional[t.Mapping[str, t.Any]] = None,
@@ -3951,7 +4490,7 @@ class Elasticsearch(BaseClient):
3951
4490
  script_fields: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
3952
4491
  scroll: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
3953
4492
  search_after: t.Optional[
3954
- t.Sequence[t.Union[None, bool, float, int, str, t.Any]]
4493
+ t.Sequence[t.Union[None, bool, float, int, str]]
3955
4494
  ] = None,
3956
4495
  search_type: t.Optional[
3957
4496
  t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
@@ -3986,15 +4525,29 @@ class Elasticsearch(BaseClient):
3986
4525
  body: t.Optional[t.Dict[str, t.Any]] = None,
3987
4526
  ) -> ObjectApiResponse[t.Any]:
3988
4527
  """
3989
- Run a search. Get search hits that match the query defined in the request. You
3990
- can provide search queries using the `q` query string parameter or the request
3991
- body. If both are specified, only the query parameter is used.
4528
+ .. raw:: html
4529
+
4530
+ <p>Run a search.</p>
4531
+ <p>Get search hits that match the query defined in the request.
4532
+ You can provide search queries using the <code>q</code> query string parameter or the request body.
4533
+ If both are specified, only the query parameter is used.</p>
4534
+ <p>If the Elasticsearch security features are enabled, you must have the read index privilege for the target data stream, index, or alias. For cross-cluster search, refer to the documentation about configuring CCS privileges.
4535
+ To search a point in time (PIT) for an alias, you must have the <code>read</code> index privilege for the alias's data streams or indices.</p>
4536
+ <p><strong>Search slicing</strong></p>
4537
+ <p>When paging through a large number of documents, it can be helpful to split the search into multiple slices to consume them independently with the <code>slice</code> and <code>pit</code> properties.
4538
+ By default the splitting is done first on the shards, then locally on each shard.
4539
+ The local splitting partitions the shard into contiguous ranges based on Lucene document IDs.</p>
4540
+ <p>For instance if the number of shards is equal to 2 and you request 4 slices, the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.</p>
4541
+ <p>IMPORTANT: The same point-in-time ID should be used for all slices.
4542
+ If different PIT IDs are used, slices can overlap and miss documents.
4543
+ This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index.</p>
4544
+
4545
+
4546
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search>`_
3992
4547
 
3993
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
3994
-
3995
- :param index: Comma-separated list of data streams, indices, and aliases to search.
3996
- Supports wildcards (`*`). To search all data streams and indices, omit this
3997
- parameter or use `*` or `_all`.
4548
+ :param index: A comma-separated list of data streams, indices, and aliases to
4549
+ search. It supports wildcards (`*`). To search all data streams and indices,
4550
+ omit this parameter or use `*` or `_all`.
3998
4551
  :param aggregations: Defines the aggregations that are run as part of the search
3999
4552
  request.
4000
4553
  :param aggs: Defines the aggregations that are run as part of the search request.
@@ -4003,45 +4556,46 @@ class Elasticsearch(BaseClient):
4003
4556
  This behavior applies even if the request targets other open indices. For
4004
4557
  example, a request targeting `foo*,bar*` returns an error if an index starts
4005
4558
  with `foo` but no index starts with `bar`.
4006
- :param allow_partial_search_results: If true, returns partial results if there
4007
- are shard request timeouts or shard failures. If false, returns an error
4008
- with no partial results.
4009
- :param analyze_wildcard: If true, wildcard and prefix queries are analyzed. This
4010
- parameter can only be used when the q query string parameter is specified.
4011
- :param analyzer: Analyzer to use for the query string. This parameter can only
4012
- be used when the q query string parameter is specified.
4559
+ :param allow_partial_search_results: If `true` and there are shard request timeouts
4560
+ or shard failures, the request returns partial results. If `false`, it returns
4561
+ an error with no partial results. To override the default behavior, you can
4562
+ set the `search.default_allow_partial_results` cluster setting to `false`.
4563
+ :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
4564
+ This parameter can be used only when the `q` query string parameter is specified.
4565
+ :param analyzer: The analyzer to use for the query string. This parameter can
4566
+ be used only when the `q` query string parameter is specified.
4013
4567
  :param batched_reduce_size: The number of shard results that should be reduced
4014
- at once on the coordinating node. This value should be used as a protection
4015
- mechanism to reduce the memory overhead per search request if the potential
4016
- number of shards in the request can be large.
4017
- :param ccs_minimize_roundtrips: If true, network round-trips between the coordinating
4018
- node and the remote clusters are minimized when executing cross-cluster search
4568
+ at once on the coordinating node. If the potential number of shards in the
4569
+ request can be large, this value should be used as a protection mechanism
4570
+ to reduce the memory overhead per search request.
4571
+ :param ccs_minimize_roundtrips: If `true`, network round-trips between the coordinating
4572
+ node and the remote clusters are minimized when running cross-cluster search
4019
4573
  (CCS) requests.
4020
4574
  :param collapse: Collapses search results the values of the specified field.
4021
- :param default_operator: The default operator for query string query: AND or
4022
- OR. This parameter can only be used when the `q` query string parameter is
4023
- specified.
4024
- :param df: Field to use as default where no field prefix is given in the query
4025
- string. This parameter can only be used when the q query string parameter
4575
+ :param default_operator: The default operator for the query string query: `AND`
4576
+ or `OR`. This parameter can be used only when the `q` query string parameter
4026
4577
  is specified.
4027
- :param docvalue_fields: Array of wildcard (`*`) patterns. The request returns
4028
- doc values for field names matching these patterns in the `hits.fields` property
4029
- of the response.
4030
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
4031
- request can target data streams, this argument determines whether wildcard
4032
- expressions match hidden data streams. Supports comma-separated values, such
4033
- as `open,hidden`.
4034
- :param explain: If true, returns detailed information about score computation
4035
- as part of a hit.
4578
+ :param df: The field to use as a default when no field prefix is given in the
4579
+ query string. This parameter can be used only when the `q` query string parameter
4580
+ is specified.
4581
+ :param docvalue_fields: An array of wildcard (`*`) field patterns. The request
4582
+ returns doc values for field names matching these patterns in the `hits.fields`
4583
+ property of the response.
4584
+ :param expand_wildcards: The type of index that wildcard patterns can match.
4585
+ If the request can target data streams, this argument determines whether
4586
+ wildcard expressions match hidden data streams. It supports comma-separated
4587
+ values such as `open,hidden`.
4588
+ :param explain: If `true`, the request returns detailed information about score
4589
+ computation as part of a hit.
4036
4590
  :param ext: Configuration of search extensions defined by Elasticsearch plugins.
4037
- :param fields: Array of wildcard (`*`) patterns. The request returns values for
4038
- field names matching these patterns in the `hits.fields` property of the
4039
- response.
4591
+ :param fields: An array of wildcard (`*`) field patterns. The request returns
4592
+ values for field names matching these patterns in the `hits.fields` property
4593
+ of the response.
4040
4594
  :param force_synthetic_source: Should this request force synthetic _source? Use
4041
4595
  this to test if the mapping supports synthetic _source and to get a sense
4042
4596
  of the worst case performance. Fetches with this enabled will be slower the
4043
4597
  enabling synthetic source natively in the index.
4044
- :param from_: Starting document offset. Needs to be non-negative. By default,
4598
+ :param from_: The starting document offset, which must be non-negative. By default,
4045
4599
  you cannot page through more than 10,000 hits using the `from` and `size`
4046
4600
  parameters. To page through more hits, use the `search_after` parameter.
4047
4601
  :param highlight: Specifies the highlighter to use for retrieving highlighted
@@ -4050,95 +4604,101 @@ class Elasticsearch(BaseClient):
4050
4604
  be ignored when frozen.
4051
4605
  :param ignore_unavailable: If `false`, the request returns an error if it targets
4052
4606
  a missing or closed index.
4053
- :param include_named_queries_score: Indicates whether hit.matched_queries should
4054
- be rendered as a map that includes the name of the matched query associated
4055
- with its score (true) or as an array containing the name of the matched queries
4056
- (false) This functionality reruns each named query on every hit in a search
4057
- response. Typically, this adds a small overhead to a request. However, using
4058
- computationally expensive named queries on a large number of hits may add
4059
- significant overhead.
4060
- :param indices_boost: Boosts the _score of documents from specified indices.
4061
- :param knn: Defines the approximate kNN search to run.
4607
+ :param include_named_queries_score: If `true`, the response includes the score
4608
+ contribution from any named queries. This functionality reruns each named
4609
+ query on every hit in a search response. Typically, this adds a small overhead
4610
+ to a request. However, using computationally expensive named queries on a
4611
+ large number of hits may add significant overhead.
4612
+ :param indices_boost: Boost the `_score` of documents from specified indices.
4613
+ The boost value is the factor by which scores are multiplied. A boost value
4614
+ greater than `1.0` increases the score. A boost value between `0` and `1.0`
4615
+ decreases the score.
4616
+ :param knn: The approximate kNN search to run.
4062
4617
  :param lenient: If `true`, format-based query failures (such as providing text
4063
4618
  to a numeric field) in the query string will be ignored. This parameter can
4064
- only be used when the `q` query string parameter is specified.
4065
- :param max_concurrent_shard_requests: Defines the number of concurrent shard
4066
- requests per node this search executes concurrently. This value should be
4067
- used to limit the impact of the search on the cluster in order to limit the
4068
- number of concurrent shard requests.
4069
- :param min_compatible_shard_node: The minimum version of the node that can handle
4070
- the request Any handling node with a lower version will fail the request.
4071
- :param min_score: Minimum `_score` for matching documents. Documents with a lower
4072
- `_score` are not included in the search results.
4073
- :param pit: Limits the search to a point in time (PIT). If you provide a PIT,
4619
+ be used only when the `q` query string parameter is specified.
4620
+ :param max_concurrent_shard_requests: The number of concurrent shard requests
4621
+ per node that the search runs concurrently. This value should be used to
4622
+ limit the impact of the search on the cluster in order to limit the number
4623
+ of concurrent shard requests.
4624
+ :param min_score: The minimum `_score` for matching documents. Documents with
4625
+ a lower `_score` are not included in search results and results collected
4626
+ by aggregations.
4627
+ :param pit: Limit the search to a point in time (PIT). If you provide a PIT,
4074
4628
  you cannot specify an `<index>` in the request path.
4075
4629
  :param post_filter: Use the `post_filter` parameter to filter search results.
4076
4630
  The search hits are filtered after the aggregations are calculated. A post
4077
4631
  filter has no impact on the aggregation results.
4078
- :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
4079
- roundtrip to prefilter search shards based on query rewriting if the number
4080
- of shards the search request expands to exceeds the threshold. This filter
4081
- roundtrip can limit the number of shards significantly if for instance a
4082
- shard can not match any documents based on its rewrite method (if date filters
4083
- are mandatory to match but the shard bounds and the query are disjoint).
4084
- When unspecified, the pre-filter phase is executed if any of these conditions
4085
- is met: the request targets more than 128 shards; the request targets one
4086
- or more read-only index; the primary sort of the query targets an indexed
4632
+ :param pre_filter_shard_size: A threshold that enforces a pre-filter roundtrip
4633
+ to prefilter search shards based on query rewriting if the number of shards
4634
+ the search request expands to exceeds the threshold. This filter roundtrip
4635
+ can limit the number of shards significantly if for instance a shard can
4636
+ not match any documents based on its rewrite method (if date filters are
4637
+ mandatory to match but the shard bounds and the query are disjoint). When
4638
+ unspecified, the pre-filter phase is executed if any of these conditions
4639
+ is met: * The request targets more than 128 shards. * The request targets
4640
+ one or more read-only index. * The primary sort of the query targets an indexed
4087
4641
  field.
4088
- :param preference: Nodes and shards used for the search. By default, Elasticsearch
4642
+ :param preference: The nodes and shards used for the search. By default, Elasticsearch
4089
4643
  selects from eligible nodes and shards using adaptive replica selection,
4090
- accounting for allocation awareness. Valid values are: `_only_local` to run
4091
- the search only on shards on the local node; `_local` to, if possible, run
4092
- the search on shards on the local node, or if not, select shards using the
4093
- default method; `_only_nodes:<node-id>,<node-id>` to run the search on only
4094
- the specified nodes IDs, where, if suitable shards exist on more than one
4095
- selected node, use shards on those nodes using the default method, or if
4096
- none of the specified nodes are available, select shards from any available
4097
- node using the default method; `_prefer_nodes:<node-id>,<node-id>` to if
4098
- possible, run the search on the specified nodes IDs, or if not, select shards
4099
- using the default method; `_shards:<shard>,<shard>` to run the search only
4100
- on the specified shards; `<custom-string>` (any string that does not start
4101
- with `_`) to route searches with the same `<custom-string>` to the same shards
4102
- in the same order.
4644
+ accounting for allocation awareness. Valid values are: * `_only_local` to
4645
+ run the search only on shards on the local node. * `_local` to, if possible,
4646
+ run the search on shards on the local node, or if not, select shards using
4647
+ the default method. * `_only_nodes:<node-id>,<node-id>` to run the search
4648
+ on only the specified nodes IDs. If suitable shards exist on more than one
4649
+ selected node, use shards on those nodes using the default method. If none
4650
+ of the specified nodes are available, select shards from any available node
4651
+ using the default method. * `_prefer_nodes:<node-id>,<node-id>` to if possible,
4652
+ run the search on the specified nodes IDs. If not, select shards using the
4653
+ default method. `_shards:<shard>,<shard>` to run the search only on the specified
4654
+ shards. You can combine this value with other `preference` values. However,
4655
+ the `_shards` value must come first. For example: `_shards:2,3|_local`. `<custom-string>`
4656
+ (any string that does not start with `_`) to route searches with the same
4657
+ `<custom-string>` to the same shards in the same order.
4103
4658
  :param profile: Set to `true` to return detailed timing information about the
4104
4659
  execution of individual components in a search request. NOTE: This is a debugging
4105
4660
  tool and adds significant overhead to search execution.
4106
- :param q: Query in the Lucene query string syntax using query parameter search.
4107
- Query parameter searches do not support the full Elasticsearch Query DSL
4108
- but are handy for testing.
4109
- :param query: Defines the search definition using the Query DSL.
4110
- :param rank: Defines the Reciprocal Rank Fusion (RRF) to use.
4661
+ :param q: A query in the Lucene query string syntax. Query parameter searches
4662
+ do not support the full Elasticsearch Query DSL but are handy for testing.
4663
+ IMPORTANT: This parameter overrides the query parameter in the request body.
4664
+ If both parameters are specified, documents matching the query request body
4665
+ parameter are not returned.
4666
+ :param query: The search definition using the Query DSL.
4667
+ :param rank: The Reciprocal Rank Fusion (RRF) to use.
4111
4668
  :param request_cache: If `true`, the caching of search results is enabled for
4112
- requests where `size` is `0`. Defaults to index level settings.
4669
+ requests where `size` is `0`. It defaults to index level settings.
4113
4670
  :param rescore: Can be used to improve precision by reordering just the top (for
4114
4671
  example 100 - 500) documents returned by the `query` and `post_filter` phases.
4115
4672
  :param rest_total_hits_as_int: Indicates whether `hits.total` should be rendered
4116
4673
  as an integer or an object in the rest search response.
4117
4674
  :param retriever: A retriever is a specification to describe top documents returned
4118
4675
  from a search. A retriever replaces other elements of the search API that
4119
- also return top documents such as query and knn.
4120
- :param routing: Custom value used to route operations to a specific shard.
4121
- :param runtime_mappings: Defines one or more runtime fields in the search request.
4122
- These fields take precedence over mapped fields with the same name.
4676
+ also return top documents such as `query` and `knn`.
4677
+ :param routing: A custom value that is used to route operations to a specific
4678
+ shard.
4679
+ :param runtime_mappings: One or more runtime fields in the search request. These
4680
+ fields take precedence over mapped fields with the same name.
4123
4681
  :param script_fields: Retrieve a script evaluation (based on different fields)
4124
4682
  for each hit.
4125
- :param scroll: Period to retain the search context for scrolling. See Scroll
4126
- search results. By default, this value cannot exceed `1d` (24 hours). You
4127
- can change this limit using the `search.max_keep_alive` cluster-level setting.
4683
+ :param scroll: The period to retain the search context for scrolling. By default,
4684
+ this value cannot exceed `1d` (24 hours). You can change this limit by using
4685
+ the `search.max_keep_alive` cluster-level setting.
4128
4686
  :param search_after: Used to retrieve the next page of hits using a set of sort
4129
4687
  values from the previous page.
4130
- :param search_type: How distributed term frequencies are calculated for relevance
4131
- scoring.
4132
- :param seq_no_primary_term: If `true`, returns sequence number and primary term
4133
- of the last modification of each hit.
4134
- :param size: The number of hits to return. By default, you cannot page through
4135
- more than 10,000 hits using the `from` and `size` parameters. To page through
4136
- more hits, use the `search_after` parameter.
4137
- :param slice: Can be used to split a scrolled search into multiple slices that
4138
- can be consumed independently.
4688
+ :param search_type: Indicates how distributed term frequencies are calculated
4689
+ for relevance scoring.
4690
+ :param seq_no_primary_term: If `true`, the request returns sequence number and
4691
+ primary term of the last modification of each hit.
4692
+ :param size: The number of hits to return, which must not be negative. By default,
4693
+ you cannot page through more than 10,000 hits using the `from` and `size`
4694
+ parameters. To page through more hits, use the `search_after` property.
4695
+ :param slice: Split a scrolled search into multiple slices that can be consumed
4696
+ independently.
4139
4697
  :param sort: A comma-separated list of <field>:<direction> pairs.
4140
- :param source: Indicates which source fields are returned for matching documents.
4141
- These fields are returned in the hits._source property of the search response.
4698
+ :param source: The source fields that are returned for matching documents. These
4699
+ fields are returned in the `hits._source` property of the search response.
4700
+ If the `stored_fields` property is specified, the `_source` property defaults
4701
+ to `false`. Otherwise, it defaults to `true`.
4142
4702
  :param source_excludes: A comma-separated list of source fields to exclude from
4143
4703
  the response. You can also use this parameter to exclude fields from the
4144
4704
  subset specified in `_source_includes` query parameter. If the `_source`
@@ -4148,45 +4708,46 @@ class Elasticsearch(BaseClient):
4148
4708
  returned. You can exclude fields from this subset using the `_source_excludes`
4149
4709
  query parameter. If the `_source` parameter is `false`, this parameter is
4150
4710
  ignored.
4151
- :param stats: Stats groups to associate with the search. Each group maintains
4711
+ :param stats: The stats groups to associate with the search. Each group maintains
4152
4712
  a statistics aggregation for its associated searches. You can retrieve these
4153
4713
  stats using the indices stats API.
4154
- :param stored_fields: List of stored fields to return as part of a hit. If no
4155
- fields are specified, no stored fields are included in the response. If this
4156
- field is specified, the `_source` parameter defaults to `false`. You can
4157
- pass `_source: true` to return both source fields and stored fields in the
4158
- search response.
4714
+ :param stored_fields: A comma-separated list of stored fields to return as part
4715
+ of a hit. If no fields are specified, no stored fields are included in the
4716
+ response. If this field is specified, the `_source` property defaults to
4717
+ `false`. You can pass `_source: true` to return both source fields and stored
4718
+ fields in the search response.
4159
4719
  :param suggest: Defines a suggester that provides similar looking terms based
4160
4720
  on a provided text.
4161
- :param suggest_field: Specifies which field to use for suggestions.
4162
- :param suggest_mode: Specifies the suggest mode. This parameter can only be used
4163
- when the `suggest_field` and `suggest_text` query string parameters are specified.
4164
- :param suggest_size: Number of suggestions to return. This parameter can only
4165
- be used when the `suggest_field` and `suggest_text` query string parameters
4721
+ :param suggest_field: The field to use for suggestions.
4722
+ :param suggest_mode: The suggest mode. This parameter can be used only when the
4723
+ `suggest_field` and `suggest_text` query string parameters are specified.
4724
+ :param suggest_size: The number of suggestions to return. This parameter can
4725
+ be used only when the `suggest_field` and `suggest_text` query string parameters
4166
4726
  are specified.
4167
4727
  :param suggest_text: The source text for which the suggestions should be returned.
4168
- This parameter can only be used when the `suggest_field` and `suggest_text`
4728
+ This parameter can be used only when the `suggest_field` and `suggest_text`
4169
4729
  query string parameters are specified.
4170
- :param terminate_after: Maximum number of documents to collect for each shard.
4730
+ :param terminate_after: The maximum number of documents to collect for each shard.
4171
4731
  If a query reaches this limit, Elasticsearch terminates the query early.
4172
- Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
4173
- applies this parameter to each shard handling the request. When possible,
4174
- let Elasticsearch perform early termination automatically. Avoid specifying
4175
- this parameter for requests that target data streams with backing indices
4176
- across multiple data tiers. If set to `0` (default), the query does not terminate
4177
- early.
4178
- :param timeout: Specifies the period of time to wait for a response from each
4179
- shard. If no response is received before the timeout expires, the request
4180
- fails and returns an error. Defaults to no timeout.
4181
- :param track_scores: If true, calculate and return document scores, even if the
4182
- scores are not used for sorting.
4732
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
4733
+ Elasticsearch applies this property to each shard handling the request. When
4734
+ possible, let Elasticsearch perform early termination automatically. Avoid
4735
+ specifying this property for requests that target data streams with backing
4736
+ indices across multiple data tiers. If set to `0` (default), the query does
4737
+ not terminate early.
4738
+ :param timeout: The period of time to wait for a response from each shard. If
4739
+ no response is received before the timeout expires, the request fails and
4740
+ returns an error. Defaults to no timeout.
4741
+ :param track_scores: If `true`, calculate and return document scores, even if
4742
+ the scores are not used for sorting.
4183
4743
  :param track_total_hits: Number of hits matching the query to count accurately.
4184
4744
  If `true`, the exact number of hits is returned at the cost of some performance.
4185
4745
  If `false`, the response does not include the total number of hits matching
4186
4746
  the query.
4187
4747
  :param typed_keys: If `true`, aggregation and suggester names are be prefixed
4188
4748
  by their respective types in the response.
4189
- :param version: If true, returns document version as part of a hit.
4749
+ :param version: If `true`, the request returns the document version as part of
4750
+ a hit.
4190
4751
  """
4191
4752
  __path_parts: t.Dict[str, str]
4192
4753
  if index not in SKIP_IN_PATH:
@@ -4244,8 +4805,6 @@ class Elasticsearch(BaseClient):
4244
4805
  __query["lenient"] = lenient
4245
4806
  if max_concurrent_shard_requests is not None:
4246
4807
  __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
4247
- if min_compatible_shard_node is not None:
4248
- __query["min_compatible_shard_node"] = min_compatible_shard_node
4249
4808
  if pre_filter_shard_size is not None:
4250
4809
  __query["pre_filter_shard_size"] = pre_filter_shard_size
4251
4810
  if preference is not None:
@@ -4418,52 +4977,376 @@ class Elasticsearch(BaseClient):
4418
4977
  body: t.Optional[t.Dict[str, t.Any]] = None,
4419
4978
  ) -> BinaryApiResponse:
4420
4979
  """
4421
- Search a vector tile. Search a vector tile for geospatial values.
4422
-
4423
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-vector-tile-api.html>`_
4980
+ .. raw:: html
4981
+
4982
+ <p>Search a vector tile.</p>
4983
+ <p>Search a vector tile for geospatial values.
4984
+ Before using this API, you should be familiar with the Mapbox vector tile specification.
4985
+ The API returns results as a binary mapbox vector tile.</p>
4986
+ <p>Internally, Elasticsearch translates a vector tile search API request into a search containing:</p>
4987
+ <ul>
4988
+ <li>A <code>geo_bounding_box</code> query on the <code>&lt;field&gt;</code>. The query uses the <code>&lt;zoom&gt;/&lt;x&gt;/&lt;y&gt;</code> tile as a bounding box.</li>
4989
+ <li>A <code>geotile_grid</code> or <code>geohex_grid</code> aggregation on the <code>&lt;field&gt;</code>. The <code>grid_agg</code> parameter determines the aggregation type. The aggregation uses the <code>&lt;zoom&gt;/&lt;x&gt;/&lt;y&gt;</code> tile as a bounding box.</li>
4990
+ <li>Optionally, a <code>geo_bounds</code> aggregation on the <code>&lt;field&gt;</code>. The search only includes this aggregation if the <code>exact_bounds</code> parameter is <code>true</code>.</li>
4991
+ <li>If the optional parameter <code>with_labels</code> is <code>true</code>, the internal search will include a dynamic runtime field that calls the <code>getLabelPosition</code> function of the geometry doc value. This enables the generation of new point features containing suggested geometry labels, so that, for example, multi-polygons will have only one label.</li>
4992
+ </ul>
4993
+ <p>For example, Elasticsearch may translate a vector tile search API request with a <code>grid_agg</code> argument of <code>geotile</code> and an <code>exact_bounds</code> argument of <code>true</code> into the following search</p>
4994
+ <pre><code>GET my-index/_search
4995
+ {
4996
+ &quot;size&quot;: 10000,
4997
+ &quot;query&quot;: {
4998
+ &quot;geo_bounding_box&quot;: {
4999
+ &quot;my-geo-field&quot;: {
5000
+ &quot;top_left&quot;: {
5001
+ &quot;lat&quot;: -40.979898069620134,
5002
+ &quot;lon&quot;: -45
5003
+ },
5004
+ &quot;bottom_right&quot;: {
5005
+ &quot;lat&quot;: -66.51326044311186,
5006
+ &quot;lon&quot;: 0
5007
+ }
5008
+ }
5009
+ }
5010
+ },
5011
+ &quot;aggregations&quot;: {
5012
+ &quot;grid&quot;: {
5013
+ &quot;geotile_grid&quot;: {
5014
+ &quot;field&quot;: &quot;my-geo-field&quot;,
5015
+ &quot;precision&quot;: 11,
5016
+ &quot;size&quot;: 65536,
5017
+ &quot;bounds&quot;: {
5018
+ &quot;top_left&quot;: {
5019
+ &quot;lat&quot;: -40.979898069620134,
5020
+ &quot;lon&quot;: -45
5021
+ },
5022
+ &quot;bottom_right&quot;: {
5023
+ &quot;lat&quot;: -66.51326044311186,
5024
+ &quot;lon&quot;: 0
5025
+ }
5026
+ }
5027
+ }
5028
+ },
5029
+ &quot;bounds&quot;: {
5030
+ &quot;geo_bounds&quot;: {
5031
+ &quot;field&quot;: &quot;my-geo-field&quot;,
5032
+ &quot;wrap_longitude&quot;: false
5033
+ }
5034
+ }
5035
+ }
5036
+ }
5037
+ </code></pre>
5038
+ <p>The API returns results as a binary Mapbox vector tile.
5039
+ Mapbox vector tiles are encoded as Google Protobufs (PBF). By default, the tile contains three layers:</p>
5040
+ <ul>
5041
+ <li>A <code>hits</code> layer containing a feature for each <code>&lt;field&gt;</code> value matching the <code>geo_bounding_box</code> query.</li>
5042
+ <li>An <code>aggs</code> layer containing a feature for each cell of the <code>geotile_grid</code> or <code>geohex_grid</code>. The layer only contains features for cells with matching data.</li>
5043
+ <li>A meta layer containing:
5044
+ <ul>
5045
+ <li>A feature containing a bounding box. By default, this is the bounding box of the tile.</li>
5046
+ <li>Value ranges for any sub-aggregations on the <code>geotile_grid</code> or <code>geohex_grid</code>.</li>
5047
+ <li>Metadata for the search.</li>
5048
+ </ul>
5049
+ </li>
5050
+ </ul>
5051
+ <p>The API only returns features that can display at its zoom level.
5052
+ For example, if a polygon feature has no area at its zoom level, the API omits it.
5053
+ The API returns errors as UTF-8 encoded JSON.</p>
5054
+ <p>IMPORTANT: You can specify several options for this API as either a query parameter or request body parameter.
5055
+ If you specify both parameters, the query parameter takes precedence.</p>
5056
+ <p><strong>Grid precision for geotile</strong></p>
5057
+ <p>For a <code>grid_agg</code> of <code>geotile</code>, you can use cells in the <code>aggs</code> layer as tiles for lower zoom levels.
5058
+ <code>grid_precision</code> represents the additional zoom levels available through these cells. The final precision is computed by as follows: <code>&lt;zoom&gt; + grid_precision</code>.
5059
+ For example, if <code>&lt;zoom&gt;</code> is 7 and <code>grid_precision</code> is 8, then the <code>geotile_grid</code> aggregation will use a precision of 15.
5060
+ The maximum final precision is 29.
5061
+ The <code>grid_precision</code> also determines the number of cells for the grid as follows: <code>(2^grid_precision) x (2^grid_precision)</code>.
5062
+ For example, a value of 8 divides the tile into a grid of 256 x 256 cells.
5063
+ The <code>aggs</code> layer only contains features for cells with matching data.</p>
5064
+ <p><strong>Grid precision for geohex</strong></p>
5065
+ <p>For a <code>grid_agg</code> of <code>geohex</code>, Elasticsearch uses <code>&lt;zoom&gt;</code> and <code>grid_precision</code> to calculate a final precision as follows: <code>&lt;zoom&gt; + grid_precision</code>.</p>
5066
+ <p>This precision determines the H3 resolution of the hexagonal cells produced by the <code>geohex</code> aggregation.
5067
+ The following table maps the H3 resolution for each precision.
5068
+ For example, if <code>&lt;zoom&gt;</code> is 3 and <code>grid_precision</code> is 3, the precision is 6.
5069
+ At a precision of 6, hexagonal cells have an H3 resolution of 2.
5070
+ If <code>&lt;zoom&gt;</code> is 3 and <code>grid_precision</code> is 4, the precision is 7.
5071
+ At a precision of 7, hexagonal cells have an H3 resolution of 3.</p>
5072
+ <table>
5073
+ <thead>
5074
+ <tr>
5075
+ <th>Precision</th>
5076
+ <th>Unique tile bins</th>
5077
+ <th>H3 resolution</th>
5078
+ <th>Unique hex bins</th>
5079
+ <th>Ratio</th>
5080
+ </tr>
5081
+ </thead>
5082
+ <tbody>
5083
+ <tr>
5084
+ <td>1</td>
5085
+ <td>4</td>
5086
+ <td>0</td>
5087
+ <td>122</td>
5088
+ <td>30.5</td>
5089
+ </tr>
5090
+ <tr>
5091
+ <td>2</td>
5092
+ <td>16</td>
5093
+ <td>0</td>
5094
+ <td>122</td>
5095
+ <td>7.625</td>
5096
+ </tr>
5097
+ <tr>
5098
+ <td>3</td>
5099
+ <td>64</td>
5100
+ <td>1</td>
5101
+ <td>842</td>
5102
+ <td>13.15625</td>
5103
+ </tr>
5104
+ <tr>
5105
+ <td>4</td>
5106
+ <td>256</td>
5107
+ <td>1</td>
5108
+ <td>842</td>
5109
+ <td>3.2890625</td>
5110
+ </tr>
5111
+ <tr>
5112
+ <td>5</td>
5113
+ <td>1024</td>
5114
+ <td>2</td>
5115
+ <td>5882</td>
5116
+ <td>5.744140625</td>
5117
+ </tr>
5118
+ <tr>
5119
+ <td>6</td>
5120
+ <td>4096</td>
5121
+ <td>2</td>
5122
+ <td>5882</td>
5123
+ <td>1.436035156</td>
5124
+ </tr>
5125
+ <tr>
5126
+ <td>7</td>
5127
+ <td>16384</td>
5128
+ <td>3</td>
5129
+ <td>41162</td>
5130
+ <td>2.512329102</td>
5131
+ </tr>
5132
+ <tr>
5133
+ <td>8</td>
5134
+ <td>65536</td>
5135
+ <td>3</td>
5136
+ <td>41162</td>
5137
+ <td>0.6280822754</td>
5138
+ </tr>
5139
+ <tr>
5140
+ <td>9</td>
5141
+ <td>262144</td>
5142
+ <td>4</td>
5143
+ <td>288122</td>
5144
+ <td>1.099098206</td>
5145
+ </tr>
5146
+ <tr>
5147
+ <td>10</td>
5148
+ <td>1048576</td>
5149
+ <td>4</td>
5150
+ <td>288122</td>
5151
+ <td>0.2747745514</td>
5152
+ </tr>
5153
+ <tr>
5154
+ <td>11</td>
5155
+ <td>4194304</td>
5156
+ <td>5</td>
5157
+ <td>2016842</td>
5158
+ <td>0.4808526039</td>
5159
+ </tr>
5160
+ <tr>
5161
+ <td>12</td>
5162
+ <td>16777216</td>
5163
+ <td>6</td>
5164
+ <td>14117882</td>
5165
+ <td>0.8414913416</td>
5166
+ </tr>
5167
+ <tr>
5168
+ <td>13</td>
5169
+ <td>67108864</td>
5170
+ <td>6</td>
5171
+ <td>14117882</td>
5172
+ <td>0.2103728354</td>
5173
+ </tr>
5174
+ <tr>
5175
+ <td>14</td>
5176
+ <td>268435456</td>
5177
+ <td>7</td>
5178
+ <td>98825162</td>
5179
+ <td>0.3681524172</td>
5180
+ </tr>
5181
+ <tr>
5182
+ <td>15</td>
5183
+ <td>1073741824</td>
5184
+ <td>8</td>
5185
+ <td>691776122</td>
5186
+ <td>0.644266719</td>
5187
+ </tr>
5188
+ <tr>
5189
+ <td>16</td>
5190
+ <td>4294967296</td>
5191
+ <td>8</td>
5192
+ <td>691776122</td>
5193
+ <td>0.1610666797</td>
5194
+ </tr>
5195
+ <tr>
5196
+ <td>17</td>
5197
+ <td>17179869184</td>
5198
+ <td>9</td>
5199
+ <td>4842432842</td>
5200
+ <td>0.2818666889</td>
5201
+ </tr>
5202
+ <tr>
5203
+ <td>18</td>
5204
+ <td>68719476736</td>
5205
+ <td>10</td>
5206
+ <td>33897029882</td>
5207
+ <td>0.4932667053</td>
5208
+ </tr>
5209
+ <tr>
5210
+ <td>19</td>
5211
+ <td>274877906944</td>
5212
+ <td>11</td>
5213
+ <td>237279209162</td>
5214
+ <td>0.8632167343</td>
5215
+ </tr>
5216
+ <tr>
5217
+ <td>20</td>
5218
+ <td>1099511627776</td>
5219
+ <td>11</td>
5220
+ <td>237279209162</td>
5221
+ <td>0.2158041836</td>
5222
+ </tr>
5223
+ <tr>
5224
+ <td>21</td>
5225
+ <td>4398046511104</td>
5226
+ <td>12</td>
5227
+ <td>1660954464122</td>
5228
+ <td>0.3776573213</td>
5229
+ </tr>
5230
+ <tr>
5231
+ <td>22</td>
5232
+ <td>17592186044416</td>
5233
+ <td>13</td>
5234
+ <td>11626681248842</td>
5235
+ <td>0.6609003122</td>
5236
+ </tr>
5237
+ <tr>
5238
+ <td>23</td>
5239
+ <td>70368744177664</td>
5240
+ <td>13</td>
5241
+ <td>11626681248842</td>
5242
+ <td>0.165225078</td>
5243
+ </tr>
5244
+ <tr>
5245
+ <td>24</td>
5246
+ <td>281474976710656</td>
5247
+ <td>14</td>
5248
+ <td>81386768741882</td>
5249
+ <td>0.2891438866</td>
5250
+ </tr>
5251
+ <tr>
5252
+ <td>25</td>
5253
+ <td>1125899906842620</td>
5254
+ <td>15</td>
5255
+ <td>569707381193162</td>
5256
+ <td>0.5060018015</td>
5257
+ </tr>
5258
+ <tr>
5259
+ <td>26</td>
5260
+ <td>4503599627370500</td>
5261
+ <td>15</td>
5262
+ <td>569707381193162</td>
5263
+ <td>0.1265004504</td>
5264
+ </tr>
5265
+ <tr>
5266
+ <td>27</td>
5267
+ <td>18014398509482000</td>
5268
+ <td>15</td>
5269
+ <td>569707381193162</td>
5270
+ <td>0.03162511259</td>
5271
+ </tr>
5272
+ <tr>
5273
+ <td>28</td>
5274
+ <td>72057594037927900</td>
5275
+ <td>15</td>
5276
+ <td>569707381193162</td>
5277
+ <td>0.007906278149</td>
5278
+ </tr>
5279
+ <tr>
5280
+ <td>29</td>
5281
+ <td>288230376151712000</td>
5282
+ <td>15</td>
5283
+ <td>569707381193162</td>
5284
+ <td>0.001976569537</td>
5285
+ </tr>
5286
+ </tbody>
5287
+ </table>
5288
+ <p>Hexagonal cells don't align perfectly on a vector tile.
5289
+ Some cells may intersect more than one vector tile.
5290
+ To compute the H3 resolution for each precision, Elasticsearch compares the average density of hexagonal bins at each resolution with the average density of tile bins at each zoom level.
5291
+ Elasticsearch uses the H3 resolution that is closest to the corresponding geotile density.</p>
5292
+
5293
+
5294
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search-mvt>`_
4424
5295
 
4425
5296
  :param index: Comma-separated list of data streams, indices, or aliases to search
4426
5297
  :param field: Field containing geospatial data to return
4427
5298
  :param zoom: Zoom level for the vector tile to search
4428
5299
  :param x: X coordinate for the vector tile to search
4429
5300
  :param y: Y coordinate for the vector tile to search
4430
- :param aggs: Sub-aggregations for the geotile_grid. Supports the following aggregation
4431
- types: - avg - cardinality - max - min - sum
4432
- :param buffer: Size, in pixels, of a clipping buffer outside the tile. This allows
4433
- renderers to avoid outline artifacts from geometries that extend past the
4434
- extent of the tile.
4435
- :param exact_bounds: If false, the meta layer’s feature is the bounding box of
4436
- the tile. If true, the meta layer’s feature is a bounding box resulting from
4437
- a geo_bounds aggregation. The aggregation runs on <field> values that intersect
4438
- the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting bounding
4439
- box may be larger than the vector tile.
4440
- :param extent: Size, in pixels, of a side of the tile. Vector tiles are square
5301
+ :param aggs: Sub-aggregations for the geotile_grid. It supports the following
5302
+ aggregation types: - `avg` - `boxplot` - `cardinality` - `extended stats`
5303
+ - `max` - `median absolute deviation` - `min` - `percentile` - `percentile-rank`
5304
+ - `stats` - `sum` - `value count` The aggregation names can't start with
5305
+ `_mvt_`. The `_mvt_` prefix is reserved for internal aggregations.
5306
+ :param buffer: The size, in pixels, of a clipping buffer outside the tile. This
5307
+ allows renderers to avoid outline artifacts from geometries that extend past
5308
+ the extent of the tile.
5309
+ :param exact_bounds: If `false`, the meta layer's feature is the bounding box
5310
+ of the tile. If `true`, the meta layer's feature is a bounding box resulting
5311
+ from a `geo_bounds` aggregation. The aggregation runs on <field> values that
5312
+ intersect the `<zoom>/<x>/<y>` tile with `wrap_longitude` set to `false`.
5313
+ The resulting bounding box may be larger than the vector tile.
5314
+ :param extent: The size, in pixels, of a side of the tile. Vector tiles are square
4441
5315
  with equal sides.
4442
- :param fields: Fields to return in the `hits` layer. Supports wildcards (`*`).
4443
- This parameter does not support fields with array values. Fields with array
4444
- values may return inconsistent results.
4445
- :param grid_agg: Aggregation used to create a grid for the `field`.
5316
+ :param fields: The fields to return in the `hits` layer. It supports wildcards
5317
+ (`*`). This parameter does not support fields with array values. Fields with
5318
+ array values may return inconsistent results.
5319
+ :param grid_agg: The aggregation used to create a grid for the `field`.
4446
5320
  :param grid_precision: Additional zoom levels available through the aggs layer.
4447
- For example, if <zoom> is 7 and grid_precision is 8, you can zoom in up to
4448
- level 15. Accepts 0-8. If 0, results dont include the aggs layer.
5321
+ For example, if `<zoom>` is `7` and `grid_precision` is `8`, you can zoom
5322
+ in up to level 15. Accepts 0-8. If 0, results don't include the aggs layer.
4449
5323
  :param grid_type: Determines the geometry type for features in the aggs layer.
4450
- In the aggs layer, each feature represents a geotile_grid cell. If 'grid'
4451
- each feature is a Polygon of the cells bounding box. If 'point' each feature
5324
+ In the aggs layer, each feature represents a `geotile_grid` cell. If `grid,
5325
+ each feature is a polygon of the cells bounding box. If `point`, each feature
4452
5326
  is a Point that is the centroid of the cell.
4453
- :param query: Query DSL used to filter documents for the search.
5327
+ :param query: The query DSL used to filter documents for the search.
4454
5328
  :param runtime_mappings: Defines one or more runtime fields in the search request.
4455
5329
  These fields take precedence over mapped fields with the same name.
4456
- :param size: Maximum number of features to return in the hits layer. Accepts
4457
- 0-10000. If 0, results dont include the hits layer.
4458
- :param sort: Sorts features in the hits layer. By default, the API calculates
4459
- a bounding box for each feature. It sorts features based on this boxs diagonal
5330
+ :param size: The maximum number of features to return in the hits layer. Accepts
5331
+ 0-10000. If 0, results don't include the hits layer.
5332
+ :param sort: Sort the features in the hits layer. By default, the API calculates
5333
+ a bounding box for each feature. It sorts features based on this box's diagonal
4460
5334
  length, from longest to shortest.
4461
- :param track_total_hits: Number of hits matching the query to count accurately.
5335
+ :param track_total_hits: The number of hits matching the query to count accurately.
4462
5336
  If `true`, the exact number of hits is returned at the cost of some performance.
4463
5337
  If `false`, the response does not include the total number of hits matching
4464
5338
  the query.
4465
5339
  :param with_labels: If `true`, the hits and aggs layers will contain additional
4466
5340
  point features representing suggested label positions for the original features.
5341
+ * `Point` and `MultiPoint` features will have one of the points selected.
5342
+ * `Polygon` and `MultiPolygon` features will have a single point generated,
5343
+ either the centroid, if it is within the polygon, or another point within
5344
+ the polygon selected from the sorted triangle-tree. * `LineString` features
5345
+ will likewise provide a roughly central point selected from the triangle-tree.
5346
+ * The aggregation results will provide one central point for each aggregation
5347
+ bucket. All attributes from the original features will also be copied to
5348
+ the new label features. In addition, the new features will be distinguishable
5349
+ using the tag `_mvt_label_position`.
4467
5350
  """
4468
5351
  if index in SKIP_IN_PATH:
4469
5352
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4567,20 +5450,26 @@ class Elasticsearch(BaseClient):
4567
5450
  human: t.Optional[bool] = None,
4568
5451
  ignore_unavailable: t.Optional[bool] = None,
4569
5452
  local: t.Optional[bool] = None,
5453
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
4570
5454
  preference: t.Optional[str] = None,
4571
5455
  pretty: t.Optional[bool] = None,
4572
5456
  routing: t.Optional[str] = None,
4573
5457
  ) -> ObjectApiResponse[t.Any]:
4574
5458
  """
4575
- Get the search shards. Get the indices and shards that a search request would
4576
- be run against. This information can be useful for working out issues or planning
4577
- optimizations with routing and shard preferences. When filtered aliases are used,
4578
- the filter is returned as part of the indices section.
5459
+ .. raw:: html
5460
+
5461
+ <p>Get the search shards.</p>
5462
+ <p>Get the indices and shards that a search request would be run against.
5463
+ This information can be useful for working out issues or planning optimizations with routing and shard preferences.
5464
+ When filtered aliases are used, the filter is returned as part of the <code>indices</code> section.</p>
5465
+ <p>If the Elasticsearch security features are enabled, you must have the <code>view_index_metadata</code> or <code>manage</code> index privilege for the target data stream, index, or alias.</p>
4579
5466
 
4580
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-shards.html>`_
4581
5467
 
4582
- :param index: Returns the indices and shards that a search request would be executed
4583
- against.
5468
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search-shards>`_
5469
+
5470
+ :param index: A comma-separated list of data streams, indices, and aliases to
5471
+ search. It supports wildcards (`*`). To search all data streams and indices,
5472
+ omit this parameter or use `*` or `_all`.
4584
5473
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4585
5474
  expression, index alias, or `_all` value targets only missing or closed indices.
4586
5475
  This behavior applies even if the request targets other open indices. For
@@ -4594,9 +5483,13 @@ class Elasticsearch(BaseClient):
4594
5483
  a missing or closed index.
4595
5484
  :param local: If `true`, the request retrieves information from the local node
4596
5485
  only.
4597
- :param preference: Specifies the node or shard the operation should be performed
4598
- on. Random by default.
4599
- :param routing: Custom value used to route operations to a specific shard.
5486
+ :param master_timeout: The period to wait for a connection to the master node.
5487
+ If the master node is not available before the timeout expires, the request
5488
+ fails and returns an error. IT can also be set to `-1` to indicate that the
5489
+ request should never timeout.
5490
+ :param preference: The node or shard the operation should be performed on. It
5491
+ is random by default.
5492
+ :param routing: A custom value used to route operations to a specific shard.
4600
5493
  """
4601
5494
  __path_parts: t.Dict[str, str]
4602
5495
  if index not in SKIP_IN_PATH:
@@ -4620,6 +5513,8 @@ class Elasticsearch(BaseClient):
4620
5513
  __query["ignore_unavailable"] = ignore_unavailable
4621
5514
  if local is not None:
4622
5515
  __query["local"] = local
5516
+ if master_timeout is not None:
5517
+ __query["master_timeout"] = master_timeout
4623
5518
  if preference is not None:
4624
5519
  __query["preference"] = preference
4625
5520
  if pretty is not None:
@@ -4671,17 +5566,20 @@ class Elasticsearch(BaseClient):
4671
5566
  search_type: t.Optional[
4672
5567
  t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
4673
5568
  ] = None,
4674
- source: t.Optional[str] = None,
5569
+ source: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,
4675
5570
  typed_keys: t.Optional[bool] = None,
4676
5571
  body: t.Optional[t.Dict[str, t.Any]] = None,
4677
5572
  ) -> ObjectApiResponse[t.Any]:
4678
5573
  """
4679
- Run a search with a search template.
5574
+ .. raw:: html
5575
+
5576
+ <p>Run a search with a search template.</p>
5577
+
4680
5578
 
4681
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-template.html>`_
5579
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search-template>`_
4682
5580
 
4683
- :param index: Comma-separated list of data streams, indices, and aliases to search.
4684
- Supports wildcards (*).
5581
+ :param index: A comma-separated list of data streams, indices, and aliases to
5582
+ search. It supports wildcards (`*`).
4685
5583
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4686
5584
  expression, index alias, or `_all` value targets only missing or closed indices.
4687
5585
  This behavior applies even if the request targets other open indices. For
@@ -4689,32 +5587,34 @@ class Elasticsearch(BaseClient):
4689
5587
  with `foo` but no index starts with `bar`.
4690
5588
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
4691
5589
  for cross-cluster search requests.
4692
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
4693
- request can target data streams, this argument determines whether wildcard
4694
- expressions match hidden data streams. Supports comma-separated values, such
4695
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
5590
+ :param expand_wildcards: The type of index that wildcard patterns can match.
5591
+ If the request can target data streams, this argument determines whether
5592
+ wildcard expressions match hidden data streams. Supports comma-separated
5593
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
5594
+ `hidden`, `none`.
4696
5595
  :param explain: If `true`, returns detailed information about score calculation
4697
- as part of each hit.
4698
- :param id: ID of the search template to use. If no source is specified, this
4699
- parameter is required.
5596
+ as part of each hit. If you specify both this and the `explain` query parameter,
5597
+ the API uses only the query parameter.
5598
+ :param id: The ID of the search template to use. If no `source` is specified,
5599
+ this parameter is required.
4700
5600
  :param ignore_throttled: If `true`, specified concrete, expanded, or aliased
4701
5601
  indices are not included in the response when throttled.
4702
5602
  :param ignore_unavailable: If `false`, the request returns an error if it targets
4703
5603
  a missing or closed index.
4704
5604
  :param params: Key-value pairs used to replace Mustache variables in the template.
4705
5605
  The key is the variable name. The value is the variable value.
4706
- :param preference: Specifies the node or shard the operation should be performed
4707
- on. Random by default.
5606
+ :param preference: The node or shard the operation should be performed on. It
5607
+ is random by default.
4708
5608
  :param profile: If `true`, the query execution is profiled.
4709
- :param rest_total_hits_as_int: If true, hits.total are rendered as an integer
4710
- in the response.
4711
- :param routing: Custom value used to route operations to a specific shard.
5609
+ :param rest_total_hits_as_int: If `true`, `hits.total` is rendered as an integer
5610
+ in the response. If `false`, it is rendered as an object.
5611
+ :param routing: A custom value used to route operations to a specific shard.
4712
5612
  :param scroll: Specifies how long a consistent view of the index should be maintained
4713
5613
  for scrolled search.
4714
5614
  :param search_type: The type of the search operation.
4715
5615
  :param source: An inline search template. Supports the same parameters as the
4716
- search API's request body. Also supports Mustache variables. If no id is
4717
- specified, this parameter is required.
5616
+ search API's request body. It also supports Mustache variables. If no `id`
5617
+ is specified, this parameter is required.
4718
5618
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
4719
5619
  names with their respective types.
4720
5620
  """
@@ -4808,34 +5708,39 @@ class Elasticsearch(BaseClient):
4808
5708
  body: t.Optional[t.Dict[str, t.Any]] = None,
4809
5709
  ) -> ObjectApiResponse[t.Any]:
4810
5710
  """
4811
- Get terms in an index. Discover terms that match a partial string in an index.
4812
- This "terms enum" API is designed for low-latency look-ups used in auto-complete
4813
- scenarios. If the `complete` property in the response is false, the returned
4814
- terms set may be incomplete and should be treated as approximate. This can occur
4815
- due to a few reasons, such as a request timeout or a node error. NOTE: The terms
4816
- enum API may return terms from deleted documents. Deleted documents are initially
4817
- only marked as deleted. It is not until their segments are merged that documents
4818
- are actually deleted. Until that happens, the terms enum API will return terms
4819
- from these documents.
4820
-
4821
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-terms-enum.html>`_
5711
+ .. raw:: html
4822
5712
 
4823
- :param index: Comma-separated list of data streams, indices, and index aliases
4824
- to search. Wildcard (*) expressions are supported.
5713
+ <p>Get terms in an index.</p>
5714
+ <p>Discover terms that match a partial string in an index.
5715
+ This API is designed for low-latency look-ups used in auto-complete scenarios.</p>
5716
+ <blockquote>
5717
+ <p>info
5718
+ The terms enum API may return terms from deleted documents. Deleted documents are initially only marked as deleted. It is not until their segments are merged that documents are actually deleted. Until that happens, the terms enum API will return terms from these documents.</p>
5719
+ </blockquote>
5720
+
5721
+
5722
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-terms-enum>`_
5723
+
5724
+ :param index: A comma-separated list of data streams, indices, and index aliases
5725
+ to search. Wildcard (`*`) expressions are supported. To search all data streams
5726
+ or indices, omit this parameter or use `*` or `_all`.
4825
5727
  :param field: The string to match at the start of indexed terms. If not provided,
4826
5728
  all terms in the field are considered.
4827
- :param case_insensitive: When true the provided search string is matched against
5729
+ :param case_insensitive: When `true`, the provided search string is matched against
4828
5730
  index terms without case sensitivity.
4829
- :param index_filter: Allows to filter an index shard if the provided query rewrites
4830
- to match_none.
4831
- :param search_after:
4832
- :param size: How many matching terms to return.
4833
- :param string: The string after which terms in the index should be returned.
4834
- Allows for a form of pagination if the last result from one request is passed
4835
- as the search_after parameter for a subsequent request.
4836
- :param timeout: The maximum length of time to spend collecting results. Defaults
4837
- to "1s" (one second). If the timeout is exceeded the complete flag set to
4838
- false in the response and the results may be partial or empty.
5731
+ :param index_filter: Filter an index shard if the provided query rewrites to
5732
+ `match_none`.
5733
+ :param search_after: The string after which terms in the index should be returned.
5734
+ It allows for a form of pagination if the last result from one request is
5735
+ passed as the `search_after` parameter for a subsequent request.
5736
+ :param size: The number of matching terms to return.
5737
+ :param string: The string to match at the start of indexed terms. If it is not
5738
+ provided, all terms in the field are considered. > info > The prefix string
5739
+ cannot be larger than the largest possible keyword value, which is Lucene's
5740
+ term byte-length limit of 32766.
5741
+ :param timeout: The maximum length of time to spend collecting results. If the
5742
+ timeout is exceeded the `complete` flag set to `false` in the response and
5743
+ the results may be partial or empty.
4839
5744
  """
4840
5745
  if index in SKIP_IN_PATH:
4841
5746
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4884,7 +5789,20 @@ class Elasticsearch(BaseClient):
4884
5789
  )
4885
5790
 
4886
5791
  @_rewrite_parameters(
4887
- body_fields=("doc", "filter", "per_field_analyzer"),
5792
+ body_fields=(
5793
+ "doc",
5794
+ "field_statistics",
5795
+ "fields",
5796
+ "filter",
5797
+ "offsets",
5798
+ "payloads",
5799
+ "per_field_analyzer",
5800
+ "positions",
5801
+ "routing",
5802
+ "term_statistics",
5803
+ "version",
5804
+ "version_type",
5805
+ ),
4888
5806
  )
4889
5807
  def termvectors(
4890
5808
  self,
@@ -4914,33 +5832,77 @@ class Elasticsearch(BaseClient):
4914
5832
  body: t.Optional[t.Dict[str, t.Any]] = None,
4915
5833
  ) -> ObjectApiResponse[t.Any]:
4916
5834
  """
4917
- Get term vector information. Get information and statistics about terms in the
4918
- fields of a particular document.
4919
-
4920
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-termvectors.html>`_
4921
-
4922
- :param index: Name of the index that contains the document.
4923
- :param id: Unique identifier of the document.
5835
+ .. raw:: html
5836
+
5837
+ <p>Get term vector information.</p>
5838
+ <p>Get information and statistics about terms in the fields of a particular document.</p>
5839
+ <p>You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request.
5840
+ You can specify the fields you are interested in through the <code>fields</code> parameter or by adding the fields to the request body.
5841
+ For example:</p>
5842
+ <pre><code>GET /my-index-000001/_termvectors/1?fields=message
5843
+ </code></pre>
5844
+ <p>Fields can be specified using wildcards, similar to the multi match query.</p>
5845
+ <p>Term vectors are real-time by default, not near real-time.
5846
+ This can be changed by setting <code>realtime</code> parameter to <code>false</code>.</p>
5847
+ <p>You can request three types of values: <em>term information</em>, <em>term statistics</em>, and <em>field statistics</em>.
5848
+ By default, all term information and field statistics are returned for all fields but term statistics are excluded.</p>
5849
+ <p><strong>Term information</strong></p>
5850
+ <ul>
5851
+ <li>term frequency in the field (always returned)</li>
5852
+ <li>term positions (<code>positions: true</code>)</li>
5853
+ <li>start and end offsets (<code>offsets: true</code>)</li>
5854
+ <li>term payloads (<code>payloads: true</code>), as base64 encoded bytes</li>
5855
+ </ul>
5856
+ <p>If the requested information wasn't stored in the index, it will be computed on the fly if possible.
5857
+ Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.</p>
5858
+ <blockquote>
5859
+ <p>warn
5860
+ Start and end offsets assume UTF-16 encoding is being used. If you want to use these offsets in order to get the original text that produced this token, you should make sure that the string you are taking a sub-string of is also encoded using UTF-16.</p>
5861
+ </blockquote>
5862
+ <p><strong>Behaviour</strong></p>
5863
+ <p>The term and field statistics are not accurate.
5864
+ Deleted documents are not taken into account.
5865
+ The information is only retrieved for the shard the requested document resides in.
5866
+ The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
5867
+ By default, when requesting term vectors of artificial documents, a shard to get the statistics from is randomly selected.
5868
+ Use <code>routing</code> only to hit a particular shard.</p>
5869
+
5870
+
5871
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-termvectors>`_
5872
+
5873
+ :param index: The name of the index that contains the document.
5874
+ :param id: A unique identifier for the document.
4924
5875
  :param doc: An artificial document (a document not present in the index) for
4925
5876
  which you want to retrieve term vectors.
4926
- :param field_statistics: If `true`, the response includes the document count,
4927
- sum of document frequencies, and sum of total term frequencies.
4928
- :param fields: Comma-separated list or wildcard expressions of fields to include
4929
- in the statistics. Used as the default list unless a specific field list
4930
- is provided in the `completion_fields` or `fielddata_fields` parameters.
4931
- :param filter: Filter terms based on their tf-idf scores.
5877
+ :param field_statistics: If `true`, the response includes: * The document count
5878
+ (how many documents contain this field). * The sum of document frequencies
5879
+ (the sum of document frequencies for all terms in this field). * The sum
5880
+ of total term frequencies (the sum of total term frequencies of each term
5881
+ in this field).
5882
+ :param fields: A list of fields to include in the statistics. It is used as the
5883
+ default list unless a specific field list is provided in the `completion_fields`
5884
+ or `fielddata_fields` parameters.
5885
+ :param filter: Filter terms based on their tf-idf scores. This could be useful
5886
+ in order find out a good characteristic vector of a document. This feature
5887
+ works in a similar manner to the second phase of the More Like This Query.
4932
5888
  :param offsets: If `true`, the response includes term offsets.
4933
5889
  :param payloads: If `true`, the response includes term payloads.
4934
- :param per_field_analyzer: Overrides the default per-field analyzer.
5890
+ :param per_field_analyzer: Override the default per-field analyzer. This is useful
5891
+ in order to generate term vectors in any fashion, especially when using artificial
5892
+ documents. When providing an analyzer for a field that already stores term
5893
+ vectors, the term vectors will be regenerated.
4935
5894
  :param positions: If `true`, the response includes term positions.
4936
- :param preference: Specifies the node or shard the operation should be performed
4937
- on. Random by default.
5895
+ :param preference: The node or shard the operation should be performed on. It
5896
+ is random by default.
4938
5897
  :param realtime: If true, the request is real-time as opposed to near-real-time.
4939
- :param routing: Custom value used to route operations to a specific shard.
4940
- :param term_statistics: If `true`, the response includes term frequency and document
4941
- frequency.
5898
+ :param routing: A custom value that is used to route operations to a specific
5899
+ shard.
5900
+ :param term_statistics: If `true`, the response includes: * The total term frequency
5901
+ (how often a term occurs in all documents). * The document frequency (the
5902
+ number of documents containing the current term). By default these values
5903
+ are not returned since term statistics can have a serious performance impact.
4942
5904
  :param version: If `true`, returns the document version as part of a hit.
4943
- :param version_type: Specific version type.
5905
+ :param version_type: The version type.
4944
5906
  """
4945
5907
  if index in SKIP_IN_PATH:
4946
5908
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4957,41 +5919,41 @@ class Elasticsearch(BaseClient):
4957
5919
  __body: t.Dict[str, t.Any] = body if body is not None else {}
4958
5920
  if error_trace is not None:
4959
5921
  __query["error_trace"] = error_trace
4960
- if field_statistics is not None:
4961
- __query["field_statistics"] = field_statistics
4962
- if fields is not None:
4963
- __query["fields"] = fields
4964
5922
  if filter_path is not None:
4965
5923
  __query["filter_path"] = filter_path
4966
5924
  if human is not None:
4967
5925
  __query["human"] = human
4968
- if offsets is not None:
4969
- __query["offsets"] = offsets
4970
- if payloads is not None:
4971
- __query["payloads"] = payloads
4972
- if positions is not None:
4973
- __query["positions"] = positions
4974
5926
  if preference is not None:
4975
5927
  __query["preference"] = preference
4976
5928
  if pretty is not None:
4977
5929
  __query["pretty"] = pretty
4978
5930
  if realtime is not None:
4979
5931
  __query["realtime"] = realtime
4980
- if routing is not None:
4981
- __query["routing"] = routing
4982
- if term_statistics is not None:
4983
- __query["term_statistics"] = term_statistics
4984
- if version is not None:
4985
- __query["version"] = version
4986
- if version_type is not None:
4987
- __query["version_type"] = version_type
4988
5932
  if not __body:
4989
5933
  if doc is not None:
4990
5934
  __body["doc"] = doc
5935
+ if field_statistics is not None:
5936
+ __body["field_statistics"] = field_statistics
5937
+ if fields is not None:
5938
+ __body["fields"] = fields
4991
5939
  if filter is not None:
4992
5940
  __body["filter"] = filter
5941
+ if offsets is not None:
5942
+ __body["offsets"] = offsets
5943
+ if payloads is not None:
5944
+ __body["payloads"] = payloads
4993
5945
  if per_field_analyzer is not None:
4994
5946
  __body["per_field_analyzer"] = per_field_analyzer
5947
+ if positions is not None:
5948
+ __body["positions"] = positions
5949
+ if routing is not None:
5950
+ __body["routing"] = routing
5951
+ if term_statistics is not None:
5952
+ __body["term_statistics"] = term_statistics
5953
+ if version is not None:
5954
+ __body["version"] = version
5955
+ if version_type is not None:
5956
+ __body["version_type"] = version_type
4995
5957
  if not __body:
4996
5958
  __body = None # type: ignore[assignment]
4997
5959
  __headers = {"accept": "application/json"}
@@ -5036,6 +5998,7 @@ class Elasticsearch(BaseClient):
5036
5998
  human: t.Optional[bool] = None,
5037
5999
  if_primary_term: t.Optional[int] = None,
5038
6000
  if_seq_no: t.Optional[int] = None,
6001
+ include_source_on_error: t.Optional[bool] = None,
5039
6002
  lang: t.Optional[str] = None,
5040
6003
  pretty: t.Optional[bool] = None,
5041
6004
  refresh: t.Optional[
@@ -5057,46 +6020,67 @@ class Elasticsearch(BaseClient):
5057
6020
  body: t.Optional[t.Dict[str, t.Any]] = None,
5058
6021
  ) -> ObjectApiResponse[t.Any]:
5059
6022
  """
5060
- Update a document. Updates a document by running a script or passing a partial
5061
- document.
5062
-
5063
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update.html>`_
5064
-
5065
- :param index: The name of the index
5066
- :param id: Document ID
5067
- :param detect_noop: Set to false to disable setting 'result' in the response
5068
- to 'noop' if no change to the document occurred.
5069
- :param doc: A partial update to an existing document.
5070
- :param doc_as_upsert: Set to true to use the contents of 'doc' as the value of
5071
- 'upsert'
6023
+ .. raw:: html
6024
+
6025
+ <p>Update a document.</p>
6026
+ <p>Update a document by running a script or passing a partial document.</p>
6027
+ <p>If the Elasticsearch security features are enabled, you must have the <code>index</code> or <code>write</code> index privilege for the target index or index alias.</p>
6028
+ <p>The script can update, delete, or skip modifying the document.
6029
+ The API also supports passing a partial document, which is merged into the existing document.
6030
+ To fully replace an existing document, use the index API.
6031
+ This operation:</p>
6032
+ <ul>
6033
+ <li>Gets the document (collocated with the shard) from the index.</li>
6034
+ <li>Runs the specified script.</li>
6035
+ <li>Indexes the result.</li>
6036
+ </ul>
6037
+ <p>The document must still be reindexed, but using this API removes some network roundtrips and reduces chances of version conflicts between the GET and the index operation.</p>
6038
+ <p>The <code>_source</code> field must be enabled to use this API.
6039
+ In addition to <code>_source</code>, you can access the following variables through the <code>ctx</code> map: <code>_index</code>, <code>_type</code>, <code>_id</code>, <code>_version</code>, <code>_routing</code>, and <code>_now</code> (the current timestamp).</p>
6040
+
6041
+
6042
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-update>`_
6043
+
6044
+ :param index: The name of the target index. By default, the index is created
6045
+ automatically if it doesn't exist.
6046
+ :param id: A unique identifier for the document to be updated.
6047
+ :param detect_noop: If `true`, the `result` in the response is set to `noop`
6048
+ (no operation) when there are no changes to the document.
6049
+ :param doc: A partial update to an existing document. If both `doc` and `script`
6050
+ are specified, `doc` is ignored.
6051
+ :param doc_as_upsert: If `true`, use the contents of 'doc' as the value of 'upsert'.
6052
+ NOTE: Using ingest pipelines with `doc_as_upsert` is not supported.
5072
6053
  :param if_primary_term: Only perform the operation if the document has this primary
5073
6054
  term.
5074
6055
  :param if_seq_no: Only perform the operation if the document has this sequence
5075
6056
  number.
6057
+ :param include_source_on_error: True or false if to include the document source
6058
+ in the error message in case of parsing errors.
5076
6059
  :param lang: The script language.
5077
6060
  :param refresh: If 'true', Elasticsearch refreshes the affected shards to make
5078
- this operation visible to search, if 'wait_for' then wait for a refresh to
5079
- make this operation visible to search, if 'false' do nothing with refreshes.
5080
- :param require_alias: If true, the destination must be an index alias.
5081
- :param retry_on_conflict: Specify how many times should the operation be retried
6061
+ this operation visible to search. If 'wait_for', it waits for a refresh to
6062
+ make this operation visible to search. If 'false', it does nothing with refreshes.
6063
+ :param require_alias: If `true`, the destination must be an index alias.
6064
+ :param retry_on_conflict: The number of times the operation should be retried
5082
6065
  when a conflict occurs.
5083
- :param routing: Custom value used to route operations to a specific shard.
5084
- :param script: Script to execute to update the document.
5085
- :param scripted_upsert: Set to true to execute the script whether or not the
5086
- document exists.
5087
- :param source: Set to false to disable source retrieval. You can also specify
5088
- a comma-separated list of the fields you want to retrieve.
5089
- :param source_excludes: Specify the source fields you want to exclude.
5090
- :param source_includes: Specify the source fields you want to retrieve.
5091
- :param timeout: Period to wait for dynamic mapping updates and active shards.
5092
- This guarantees Elasticsearch waits for at least the timeout before failing.
5093
- The actual wait time could be longer, particularly when multiple waits occur.
6066
+ :param routing: A custom value used to route operations to a specific shard.
6067
+ :param script: The script to run to update the document.
6068
+ :param scripted_upsert: If `true`, run the script whether or not the document
6069
+ exists.
6070
+ :param source: If `false`, turn off source retrieval. You can also specify a
6071
+ comma-separated list of the fields you want to retrieve.
6072
+ :param source_excludes: The source fields you want to exclude.
6073
+ :param source_includes: The source fields you want to retrieve.
6074
+ :param timeout: The period to wait for the following operations: dynamic mapping
6075
+ updates and waiting for active shards. Elasticsearch waits for at least the
6076
+ timeout period before failing. The actual wait time could be longer, particularly
6077
+ when multiple waits occur.
5094
6078
  :param upsert: If the document does not already exist, the contents of 'upsert'
5095
- are inserted as a new document. If the document exists, the 'script' is executed.
5096
- :param wait_for_active_shards: The number of shard copies that must be active
5097
- before proceeding with the operations. Set to 'all' or any positive integer
5098
- up to the total number of shards in the index (number_of_replicas+1). Defaults
5099
- to 1 meaning the primary shard.
6079
+ are inserted as a new document. If the document exists, the 'script' is run.
6080
+ :param wait_for_active_shards: The number of copies of each shard that must be
6081
+ active before proceeding with the operation. Set to 'all' or any positive
6082
+ integer up to the total number of shards in the index (`number_of_replicas`+1).
6083
+ The default value of `1` means it waits for each primary shard to be active.
5100
6084
  """
5101
6085
  if index in SKIP_IN_PATH:
5102
6086
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5116,6 +6100,8 @@ class Elasticsearch(BaseClient):
5116
6100
  __query["if_primary_term"] = if_primary_term
5117
6101
  if if_seq_no is not None:
5118
6102
  __query["if_seq_no"] = if_seq_no
6103
+ if include_source_on_error is not None:
6104
+ __query["include_source_on_error"] = include_source_on_error
5119
6105
  if lang is not None:
5120
6106
  __query["lang"] = lang
5121
6107
  if pretty is not None:
@@ -5222,82 +6208,166 @@ class Elasticsearch(BaseClient):
5222
6208
  body: t.Optional[t.Dict[str, t.Any]] = None,
5223
6209
  ) -> ObjectApiResponse[t.Any]:
5224
6210
  """
5225
- Update documents. Updates documents that match the specified query. If no query
5226
- is specified, performs an update on every document in the data stream or index
5227
- without modifying the source, which is useful for picking up mapping changes.
5228
-
5229
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
6211
+ .. raw:: html
6212
+
6213
+ <p>Update documents.
6214
+ Updates documents that match the specified query.
6215
+ If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.</p>
6216
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
6217
+ <ul>
6218
+ <li><code>read</code></li>
6219
+ <li><code>index</code> or <code>write</code></li>
6220
+ </ul>
6221
+ <p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.</p>
6222
+ <p>When you submit an update by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and updates matching documents using internal versioning.
6223
+ When the versions match, the document is updated and the version number is incremented.
6224
+ If a document changes between the time that the snapshot is taken and the update operation is processed, it results in a version conflict and the operation fails.
6225
+ You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
6226
+ Note that if you opt to count version conflicts, the operation could attempt to update more documents from the source than <code>max_docs</code> until it has successfully updated <code>max_docs</code> documents or it has gone through every document in the source query.</p>
6227
+ <p>NOTE: Documents with a version equal to 0 cannot be updated using update by query because internal versioning does not support 0 as a valid version number.</p>
6228
+ <p>While processing an update by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents.
6229
+ A bulk update request is performed for each batch of matching documents.
6230
+ Any query or update failures cause the update by query request to fail and the failures are shown in the response.
6231
+ Any update requests that completed successfully still stick, they are not rolled back.</p>
6232
+ <p><strong>Throttling update requests</strong></p>
6233
+ <p>To control the rate at which update by query issues batches of update operations, you can set <code>requests_per_second</code> to any positive decimal number.
6234
+ This pads each batch with a wait time to throttle the rate.
6235
+ Set <code>requests_per_second</code> to <code>-1</code> to turn off throttling.</p>
6236
+ <p>Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
6237
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
6238
+ By default the batch size is 1000, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
6239
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
6240
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
6241
+ </code></pre>
6242
+ <p>Since the batch is issued as a single _bulk request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
6243
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
6244
+ <p><strong>Slicing</strong></p>
6245
+ <p>Update by query supports sliced scroll to parallelize the update process.
6246
+ This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
6247
+ <p>Setting <code>slices</code> to <code>auto</code> chooses a reasonable number for most data streams and indices.
6248
+ This setting will use one slice per shard, up to a certain limit.
6249
+ If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.</p>
6250
+ <p>Adding <code>slices</code> to <code>_update_by_query</code> just automates the manual process of creating sub-requests, which means it has some quirks:</p>
6251
+ <ul>
6252
+ <li>You can see these requests in the tasks APIs. These sub-requests are &quot;child&quot; tasks of the task for the request with slices.</li>
6253
+ <li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
6254
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
6255
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
6256
+ <li>Canceling the request with slices will cancel each sub-request.</li>
6257
+ <li>Due to the nature of slices each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
6258
+ <li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with slices are distributed proportionally to each sub-request. Combine that with the point above about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being updated.</li>
6259
+ <li>Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.</li>
6260
+ </ul>
6261
+ <p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
6262
+ <ul>
6263
+ <li>Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many slices hurts performance. Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</li>
6264
+ <li>Update performance scales linearly across available resources with the number of slices.</li>
6265
+ </ul>
6266
+ <p>Whether query or update performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
6267
+ <p><strong>Update the document source</strong></p>
6268
+ <p>Update by query supports scripts to update the document source.
6269
+ As with the update API, you can set <code>ctx.op</code> to change the operation that is performed.</p>
6270
+ <p>Set <code>ctx.op = &quot;noop&quot;</code> if your script decides that it doesn't have to make any changes.
6271
+ The update by query operation skips updating the document and increments the <code>noop</code> counter.</p>
6272
+ <p>Set <code>ctx.op = &quot;delete&quot;</code> if your script decides that the document should be deleted.
6273
+ The update by query operation deletes the document and increments the <code>deleted</code> counter.</p>
6274
+ <p>Update by query supports only <code>index</code>, <code>noop</code>, and <code>delete</code>.
6275
+ Setting <code>ctx.op</code> to anything else is an error.
6276
+ Setting any other field in <code>ctx</code> is an error.
6277
+ This API enables you to only modify the source of matching documents; you cannot move them.</p>
6278
+
6279
+
6280
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-update-by-query>`_
5230
6281
 
5231
- :param index: Comma-separated list of data streams, indices, and aliases to search.
5232
- Supports wildcards (`*`). To search all data streams or indices, omit this
5233
- parameter or use `*` or `_all`.
6282
+ :param index: A comma-separated list of data streams, indices, and aliases to
6283
+ search. It supports wildcards (`*`). To search all data streams or indices,
6284
+ omit this parameter or use `*` or `_all`.
5234
6285
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
5235
6286
  expression, index alias, or `_all` value targets only missing or closed indices.
5236
6287
  This behavior applies even if the request targets other open indices. For
5237
6288
  example, a request targeting `foo*,bar*` returns an error if an index starts
5238
6289
  with `foo` but no index starts with `bar`.
5239
6290
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
5240
- :param analyzer: Analyzer to use for the query string.
5241
- :param conflicts: What to do if update by query hits version conflicts: `abort`
5242
- or `proceed`.
6291
+ This parameter can be used only when the `q` query string parameter is specified.
6292
+ :param analyzer: The analyzer to use for the query string. This parameter can
6293
+ be used only when the `q` query string parameter is specified.
6294
+ :param conflicts: The preferred behavior when update by query hits version conflicts:
6295
+ `abort` or `proceed`.
5243
6296
  :param default_operator: The default operator for query string query: `AND` or
5244
- `OR`.
5245
- :param df: Field to use as default where no field prefix is given in the query
5246
- string.
5247
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
5248
- request can target data streams, this argument determines whether wildcard
5249
- expressions match hidden data streams. Supports comma-separated values, such
5250
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
5251
- :param from_: Starting offset (default: 0)
6297
+ `OR`. This parameter can be used only when the `q` query string parameter
6298
+ is specified.
6299
+ :param df: The field to use as default where no field prefix is given in the
6300
+ query string. This parameter can be used only when the `q` query string parameter
6301
+ is specified.
6302
+ :param expand_wildcards: The type of index that wildcard patterns can match.
6303
+ If the request can target data streams, this argument determines whether
6304
+ wildcard expressions match hidden data streams. It supports comma-separated
6305
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
6306
+ `hidden`, `none`.
6307
+ :param from_: Skips the specified number of documents.
5252
6308
  :param ignore_unavailable: If `false`, the request returns an error if it targets
5253
6309
  a missing or closed index.
5254
6310
  :param lenient: If `true`, format-based query failures (such as providing text
5255
- to a numeric field) in the query string will be ignored.
6311
+ to a numeric field) in the query string will be ignored. This parameter can
6312
+ be used only when the `q` query string parameter is specified.
5256
6313
  :param max_docs: The maximum number of documents to update.
5257
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
6314
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
5258
6315
  If the index has a default ingest pipeline specified, then setting the value
5259
6316
  to `_none` disables the default ingest pipeline for this request. If a final
5260
6317
  pipeline is configured it will always run, regardless of the value of this
5261
6318
  parameter.
5262
- :param preference: Specifies the node or shard the operation should be performed
5263
- on. Random by default.
5264
- :param q: Query in the Lucene query string syntax.
5265
- :param query: Specifies the documents to update using the Query DSL.
6319
+ :param preference: The node or shard the operation should be performed on. It
6320
+ is random by default.
6321
+ :param q: A query in the Lucene query string syntax.
6322
+ :param query: The documents to update using the Query DSL.
5266
6323
  :param refresh: If `true`, Elasticsearch refreshes affected shards to make the
5267
- operation visible to search.
6324
+ operation visible to search after the request completes. This is different
6325
+ than the update API's `refresh` parameter, which causes just the shard that
6326
+ received the request to be refreshed.
5268
6327
  :param request_cache: If `true`, the request cache is used for this request.
6328
+ It defaults to the index-level setting.
5269
6329
  :param requests_per_second: The throttle for this request in sub-requests per
5270
6330
  second.
5271
- :param routing: Custom value used to route operations to a specific shard.
6331
+ :param routing: A custom value used to route operations to a specific shard.
5272
6332
  :param script: The script to run to update the document source or metadata when
5273
6333
  updating.
5274
- :param scroll: Period to retain the search context for scrolling.
5275
- :param scroll_size: Size of the scroll request that powers the operation.
5276
- :param search_timeout: Explicit timeout for each search request.
5277
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
5278
- `dfs_query_then_fetch`.
6334
+ :param scroll: The period to retain the search context for scrolling.
6335
+ :param scroll_size: The size of the scroll request that powers the operation.
6336
+ :param search_timeout: An explicit timeout for each search request. By default,
6337
+ there is no timeout.
6338
+ :param search_type: The type of the search operation. Available options include
6339
+ `query_then_fetch` and `dfs_query_then_fetch`.
5279
6340
  :param slice: Slice the request manually using the provided slice ID and total
5280
6341
  number of slices.
5281
6342
  :param slices: The number of slices this task should be divided into.
5282
6343
  :param sort: A comma-separated list of <field>:<direction> pairs.
5283
- :param stats: Specific `tag` of the request for logging and statistical purposes.
5284
- :param terminate_after: Maximum number of documents to collect for each shard.
6344
+ :param stats: The specific `tag` of the request for logging and statistical purposes.
6345
+ :param terminate_after: The maximum number of documents to collect for each shard.
5285
6346
  If a query reaches this limit, Elasticsearch terminates the query early.
5286
- Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
5287
- applies this parameter to each shard handling the request. When possible,
5288
- let Elasticsearch perform early termination automatically. Avoid specifying
5289
- this parameter for requests that target data streams with backing indices
5290
- across multiple data tiers.
5291
- :param timeout: Period each update request waits for the following operations:
5292
- dynamic mapping updates, waiting for active shards.
6347
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
6348
+ Elasticsearch applies this parameter to each shard handling the request.
6349
+ When possible, let Elasticsearch perform early termination automatically.
6350
+ Avoid specifying this parameter for requests that target data streams with
6351
+ backing indices across multiple data tiers.
6352
+ :param timeout: The period each update request waits for the following operations:
6353
+ dynamic mapping updates, waiting for active shards. By default, it is one
6354
+ minute. This guarantees Elasticsearch waits for at least the timeout before
6355
+ failing. The actual wait time could be longer, particularly when multiple
6356
+ waits occur.
5293
6357
  :param version: If `true`, returns the document version as part of a hit.
5294
6358
  :param version_type: Should the document increment the version number (internal)
5295
6359
  on hit or not (reindex)
5296
6360
  :param wait_for_active_shards: The number of shard copies that must be active
5297
6361
  before proceeding with the operation. Set to `all` or any positive integer
5298
- up to the total number of shards in the index (`number_of_replicas+1`).
6362
+ up to the total number of shards in the index (`number_of_replicas+1`). The
6363
+ `timeout` parameter controls how long each write request waits for unavailable
6364
+ shards to become available. Both work exactly the way they work in the bulk
6365
+ API.
5299
6366
  :param wait_for_completion: If `true`, the request blocks until the operation
5300
- is complete.
6367
+ is complete. If `false`, Elasticsearch performs some preflight checks, launches
6368
+ the request, and returns a task ID that you can use to cancel or get the
6369
+ status of the task. Elasticsearch creates a record of this task as a document
6370
+ at `.tasks/task/${taskId}`.
5301
6371
  """
5302
6372
  if index in SKIP_IN_PATH:
5303
6373
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5420,16 +6490,18 @@ class Elasticsearch(BaseClient):
5420
6490
  requests_per_second: t.Optional[float] = None,
5421
6491
  ) -> ObjectApiResponse[t.Any]:
5422
6492
  """
5423
- Throttle an update by query operation. Change the number of requests per second
5424
- for a particular update by query operation. Rethrottling that speeds up the query
5425
- takes effect immediately but rethrotting that slows down the query takes effect
5426
- after completing the current batch to prevent scroll timeouts.
6493
+ .. raw:: html
6494
+
6495
+ <p>Throttle an update by query operation.</p>
6496
+ <p>Change the number of requests per second for a particular update by query operation.
6497
+ Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.</p>
5427
6498
 
5428
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
6499
+
6500
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-update-by-query-rethrottle>`_
5429
6501
 
5430
6502
  :param task_id: The ID for the task.
5431
6503
  :param requests_per_second: The throttle for this request in sub-requests per
5432
- second.
6504
+ second. To turn off throttling, set it to `-1`.
5433
6505
  """
5434
6506
  if task_id in SKIP_IN_PATH:
5435
6507
  raise ValueError("Empty value passed for parameter 'task_id'")