elasticsearch 8.17.1__py3-none-any.whl → 8.17.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. elasticsearch/__init__.py +2 -2
  2. elasticsearch/_async/client/__init__.py +1971 -779
  3. elasticsearch/_async/client/async_search.py +33 -22
  4. elasticsearch/_async/client/autoscaling.py +27 -21
  5. elasticsearch/_async/client/cat.py +216 -141
  6. elasticsearch/_async/client/ccr.py +96 -70
  7. elasticsearch/_async/client/cluster.py +150 -142
  8. elasticsearch/_async/client/connector.py +182 -86
  9. elasticsearch/_async/client/dangling_indices.py +19 -13
  10. elasticsearch/_async/client/enrich.py +25 -6
  11. elasticsearch/_async/client/eql.py +22 -9
  12. elasticsearch/_async/client/esql.py +295 -3
  13. elasticsearch/_async/client/features.py +25 -25
  14. elasticsearch/_async/client/fleet.py +15 -9
  15. elasticsearch/_async/client/graph.py +9 -8
  16. elasticsearch/_async/client/ilm.py +85 -55
  17. elasticsearch/_async/client/indices.py +692 -549
  18. elasticsearch/_async/client/inference.py +32 -28
  19. elasticsearch/_async/client/ingest.py +61 -22
  20. elasticsearch/_async/client/license.py +48 -31
  21. elasticsearch/_async/client/logstash.py +17 -6
  22. elasticsearch/_async/client/migration.py +23 -14
  23. elasticsearch/_async/client/ml.py +532 -284
  24. elasticsearch/_async/client/monitoring.py +5 -2
  25. elasticsearch/_async/client/nodes.py +43 -27
  26. elasticsearch/_async/client/query_rules.py +51 -25
  27. elasticsearch/_async/client/rollup.py +111 -73
  28. elasticsearch/_async/client/search_application.py +49 -21
  29. elasticsearch/_async/client/searchable_snapshots.py +21 -8
  30. elasticsearch/_async/client/security.py +810 -472
  31. elasticsearch/_async/client/shutdown.py +31 -26
  32. elasticsearch/_async/client/simulate.py +16 -22
  33. elasticsearch/_async/client/slm.py +55 -30
  34. elasticsearch/_async/client/snapshot.py +173 -192
  35. elasticsearch/_async/client/sql.py +37 -16
  36. elasticsearch/_async/client/ssl.py +16 -17
  37. elasticsearch/_async/client/synonyms.py +50 -29
  38. elasticsearch/_async/client/tasks.py +74 -39
  39. elasticsearch/_async/client/text_structure.py +61 -52
  40. elasticsearch/_async/client/transform.py +108 -79
  41. elasticsearch/_async/client/watcher.py +93 -57
  42. elasticsearch/_async/client/xpack.py +16 -7
  43. elasticsearch/_async/helpers.py +1 -1
  44. elasticsearch/_sync/client/__init__.py +1971 -779
  45. elasticsearch/_sync/client/async_search.py +33 -22
  46. elasticsearch/_sync/client/autoscaling.py +27 -21
  47. elasticsearch/_sync/client/cat.py +216 -141
  48. elasticsearch/_sync/client/ccr.py +96 -70
  49. elasticsearch/_sync/client/cluster.py +150 -142
  50. elasticsearch/_sync/client/connector.py +182 -86
  51. elasticsearch/_sync/client/dangling_indices.py +19 -13
  52. elasticsearch/_sync/client/enrich.py +25 -6
  53. elasticsearch/_sync/client/eql.py +22 -9
  54. elasticsearch/_sync/client/esql.py +295 -3
  55. elasticsearch/_sync/client/features.py +25 -25
  56. elasticsearch/_sync/client/fleet.py +15 -9
  57. elasticsearch/_sync/client/graph.py +9 -8
  58. elasticsearch/_sync/client/ilm.py +85 -55
  59. elasticsearch/_sync/client/indices.py +692 -549
  60. elasticsearch/_sync/client/inference.py +32 -28
  61. elasticsearch/_sync/client/ingest.py +61 -22
  62. elasticsearch/_sync/client/license.py +48 -31
  63. elasticsearch/_sync/client/logstash.py +17 -6
  64. elasticsearch/_sync/client/migration.py +23 -14
  65. elasticsearch/_sync/client/ml.py +532 -284
  66. elasticsearch/_sync/client/monitoring.py +5 -2
  67. elasticsearch/_sync/client/nodes.py +43 -27
  68. elasticsearch/_sync/client/query_rules.py +51 -25
  69. elasticsearch/_sync/client/rollup.py +111 -73
  70. elasticsearch/_sync/client/search_application.py +49 -21
  71. elasticsearch/_sync/client/searchable_snapshots.py +21 -8
  72. elasticsearch/_sync/client/security.py +810 -472
  73. elasticsearch/_sync/client/shutdown.py +31 -26
  74. elasticsearch/_sync/client/simulate.py +16 -22
  75. elasticsearch/_sync/client/slm.py +55 -30
  76. elasticsearch/_sync/client/snapshot.py +173 -192
  77. elasticsearch/_sync/client/sql.py +37 -16
  78. elasticsearch/_sync/client/ssl.py +16 -17
  79. elasticsearch/_sync/client/synonyms.py +50 -29
  80. elasticsearch/_sync/client/tasks.py +74 -39
  81. elasticsearch/_sync/client/text_structure.py +61 -52
  82. elasticsearch/_sync/client/transform.py +108 -79
  83. elasticsearch/_sync/client/utils.py +1 -1
  84. elasticsearch/_sync/client/watcher.py +93 -57
  85. elasticsearch/_sync/client/xpack.py +16 -7
  86. elasticsearch/_version.py +1 -1
  87. elasticsearch/client.py +2 -0
  88. elasticsearch/helpers/actions.py +1 -1
  89. elasticsearch/helpers/vectorstore/_sync/vectorstore.py +4 -1
  90. {elasticsearch-8.17.1.dist-info → elasticsearch-8.17.2.dist-info}/METADATA +1 -1
  91. elasticsearch-8.17.2.dist-info/RECORD +119 -0
  92. elasticsearch-8.17.1.dist-info/RECORD +0 -119
  93. {elasticsearch-8.17.1.dist-info → elasticsearch-8.17.2.dist-info}/WHEEL +0 -0
  94. {elasticsearch-8.17.1.dist-info → elasticsearch-8.17.2.dist-info}/licenses/LICENSE +0 -0
  95. {elasticsearch-8.17.1.dist-info → elasticsearch-8.17.2.dist-info}/licenses/NOTICE +0 -0
@@ -644,83 +644,89 @@ class Elasticsearch(BaseClient):
644
644
  ] = None,
645
645
  ) -> ObjectApiResponse[t.Any]:
646
646
  """
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.
647
+ .. raw:: html
648
+
649
+ <p>Bulk index or delete documents.
650
+ Perform multiple <code>index</code>, <code>create</code>, <code>delete</code>, and <code>update</code> actions in a single request.
651
+ This reduces overhead and can greatly increase indexing speed.</p>
652
+ <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>
653
+ <ul>
654
+ <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>
655
+ <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>
656
+ <li>To use the <code>delete</code> action, you must have the <code>delete</code> or <code>write</code> index privilege.</li>
657
+ <li>To use the <code>update</code> action, you must have the <code>index</code> or <code>write</code> index privilege.</li>
658
+ <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>
659
+ <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>
660
+ </ul>
661
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
662
+ <p>The actions are specified in the request body using a newline delimited JSON (NDJSON) structure:</p>
663
+ <pre><code>action_and_meta_data\\n
664
+ optional_source\\n
665
+ action_and_meta_data\\n
666
+ optional_source\\n
667
+ ....
668
+ action_and_meta_data\\n
669
+ optional_source\\n
670
+ </code></pre>
671
+ <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.
672
+ A <code>create</code> action fails if a document with the same ID already exists in the target
673
+ An <code>index</code> action adds or replaces a document as necessary.</p>
674
+ <p>NOTE: Data streams support only the <code>create</code> action.
675
+ To update or delete a document in a data stream, you must target the backing index containing the document.</p>
676
+ <p>An <code>update</code> action expects that the partial doc, upsert, and script and its options are specified on the next line.</p>
677
+ <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>
678
+ <p>NOTE: The final line of data must end with a newline character (<code>\\n</code>).
679
+ Each newline character may be preceded by a carriage return (<code>\\r</code>).
680
+ 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>.
681
+ 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>
682
+ <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>
683
+ <p>A note on the format: the idea here is to make processing as fast as possible.
684
+ 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>
685
+ <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>
686
+ <p>There is no &quot;correct&quot; number of actions to perform in a single bulk request.
687
+ Experiment with different settings to find the optimal size for your particular workload.
688
+ 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.
689
+ 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.
690
+ 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>
691
+ <p><strong>Client suppport for bulk requests</strong></p>
692
+ <p>Some of the officially supported clients provide helpers to assist with bulk requests and reindexing:</p>
693
+ <ul>
694
+ <li>Go: Check out <code>esutil.BulkIndexer</code></li>
695
+ <li>Perl: Check out <code>Search::Elasticsearch::Client::5_0::Bulk</code> and <code>Search::Elasticsearch::Client::5_0::Scroll</code></li>
696
+ <li>Python: Check out <code>elasticsearch.helpers.*</code></li>
697
+ <li>JavaScript: Check out <code>client.helpers.*</code></li>
698
+ <li>.NET: Check out <code>BulkAllObservable</code></li>
699
+ <li>PHP: Check out bulk indexing.</li>
700
+ </ul>
701
+ <p><strong>Submitting bulk requests with cURL</strong></p>
702
+ <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>.
703
+ The latter doesn't preserve newlines. For example:</p>
704
+ <pre><code>$ cat requests
705
+ { &quot;index&quot; : { &quot;_index&quot; : &quot;test&quot;, &quot;_id&quot; : &quot;1&quot; } }
706
+ { &quot;field1&quot; : &quot;value1&quot; }
707
+ $ curl -s -H &quot;Content-Type: application/x-ndjson&quot; -XPOST localhost:9200/_bulk --data-binary &quot;@requests&quot;; echo
708
+ {&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}}]}
709
+ </code></pre>
710
+ <p><strong>Optimistic concurrency control</strong></p>
711
+ <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.
712
+ 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>
713
+ <p><strong>Versioning</strong></p>
714
+ <p>Each bulk item can include the version value using the <code>version</code> field.
715
+ It automatically follows the behavior of the index or delete operation based on the <code>_version</code> mapping.
716
+ It also support the <code>version_type</code>.</p>
717
+ <p><strong>Routing</strong></p>
718
+ <p>Each bulk item can include the routing value using the <code>routing</code> field.
719
+ It automatically follows the behavior of the index or delete operation based on the <code>_routing</code> mapping.</p>
720
+ <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>
721
+ <p><strong>Wait for active shards</strong></p>
722
+ <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>
723
+ <p><strong>Refresh</strong></p>
724
+ <p>Control when the changes made by this request are visible to search.</p>
725
+ <p>NOTE: Only the shards that receive the bulk request will be affected by refresh.
726
+ 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.
727
+ The request will only wait for those three shards to refresh.
728
+ The other two shards that make up the index do not participate in the <code>_bulk</code> request at all.</p>
729
+
724
730
 
725
731
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-bulk.html>`_
726
732
 
@@ -837,8 +843,11 @@ class Elasticsearch(BaseClient):
837
843
  body: t.Optional[t.Dict[str, t.Any]] = None,
838
844
  ) -> ObjectApiResponse[t.Any]:
839
845
  """
840
- Clear a scrolling search. Clear the search context and results for a scrolling
841
- search.
846
+ .. raw:: html
847
+
848
+ <p>Clear a scrolling search.
849
+ Clear the search context and results for a scrolling search.</p>
850
+
842
851
 
843
852
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/clear-scroll-api.html>`_
844
853
 
@@ -888,11 +897,14 @@ class Elasticsearch(BaseClient):
888
897
  body: t.Optional[t.Dict[str, t.Any]] = None,
889
898
  ) -> ObjectApiResponse[t.Any]:
890
899
  """
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.
900
+ .. raw:: html
901
+
902
+ <p>Close a point in time.
903
+ A point in time must be opened explicitly before being used in search requests.
904
+ The <code>keep_alive</code> parameter tells Elasticsearch how long it should persist.
905
+ A point in time is automatically closed when the <code>keep_alive</code> period has elapsed.
906
+ However, keeping points in time has a cost; close them as soon as they are no longer required for search requests.</p>
907
+
896
908
 
897
909
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
898
910
 
@@ -966,14 +978,17 @@ class Elasticsearch(BaseClient):
966
978
  body: t.Optional[t.Dict[str, t.Any]] = None,
967
979
  ) -> ObjectApiResponse[t.Any]:
968
980
  """
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.
981
+ .. raw:: html
982
+
983
+ <p>Count search results.
984
+ Get the number of documents matching a query.</p>
985
+ <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.
986
+ The query is optional. When no query is provided, the API uses <code>match_all</code> to count all the documents.</p>
987
+ <p>The count API supports multi-target syntax. You can run a single count API search across multiple data streams and indices.</p>
988
+ <p>The operation is broadcast across all shards.
989
+ For each shard ID group, a replica is chosen and the search is run against it.
990
+ This means that replicas increase the scalability of the count.</p>
991
+
977
992
 
978
993
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-count.html>`_
979
994
 
@@ -1010,10 +1025,10 @@ class Elasticsearch(BaseClient):
1010
1025
  in the result.
1011
1026
  :param preference: The node or shard the operation should be performed on. By
1012
1027
  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.
1028
+ :param q: The query in Lucene query string syntax. This parameter cannot be used
1029
+ with a request body.
1030
+ :param query: Defines the search query using Query DSL. A request body query
1031
+ cannot be used with the `q` query string parameter.
1017
1032
  :param routing: A custom value used to route operations to a specific shard.
1018
1033
  :param terminate_after: The maximum number of documents to collect for each shard.
1019
1034
  If a query reaches this limit, Elasticsearch terminates the query early.
@@ -1115,38 +1130,100 @@ class Elasticsearch(BaseClient):
1115
1130
  ] = None,
1116
1131
  ) -> ObjectApiResponse[t.Any]:
1117
1132
  """
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.
1133
+ .. raw:: html
1134
+
1135
+ <p>Create a new document in the index.</p>
1136
+ <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
1137
+ Using <code>_create</code> guarantees that the document is indexed only if it does not already exist.
1138
+ It returns a 409 response when a document with a same ID already exists in the index.
1139
+ To update an existing document, you must use the <code>/&lt;target&gt;/_doc/</code> API.</p>
1140
+ <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>
1141
+ <ul>
1142
+ <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>
1143
+ <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>
1144
+ </ul>
1145
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
1146
+ <p><strong>Automatically create data streams and indices</strong></p>
1147
+ <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>
1148
+ <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>
1149
+ <p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
1150
+ <p>If no mapping exists, the index operation creates a dynamic mapping.
1151
+ By default, new fields and objects are automatically added to the mapping if needed.</p>
1152
+ <p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
1153
+ If it is <code>true</code>, any index can be created automatically.
1154
+ 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.
1155
+ 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.
1156
+ When a list is specified, the default behaviour is to disallow.</p>
1157
+ <p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
1158
+ It does not affect the creation of data streams.</p>
1159
+ <p><strong>Routing</strong></p>
1160
+ <p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
1161
+ 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>
1162
+ <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.
1163
+ This does come at the (very minimal) cost of an additional document parsing pass.
1164
+ 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>
1165
+ <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>
1166
+ <p>** Distributed**</p>
1167
+ <p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
1168
+ After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
1169
+ <p><strong>Active shards</strong></p>
1170
+ <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.
1171
+ 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.
1172
+ 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>).
1173
+ This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
1174
+ To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
1175
+ <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).
1176
+ Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
1177
+ <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).
1178
+ If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
1179
+ 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.
1180
+ 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.
1181
+ This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
1182
+ 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.
1183
+ The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
1184
+ <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.
1185
+ 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.
1186
+ The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
1187
+
1121
1188
 
1122
1189
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
1123
1190
 
1124
- :param index: Name of the data stream or index to target. If the target doesnt
1191
+ :param index: The name of the data stream or index to target. If the target doesn't
1125
1192
  exist and matches the name or wildcard (`*`) pattern of an index template
1126
1193
  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
1194
+ the target doesn't exist and doesn’t match a data stream template, this request
1128
1195
  creates the index.
1129
- :param id: Unique identifier for the document.
1196
+ :param id: A unique identifier for the document. To automatically generate a
1197
+ document ID, use the `POST /<target>/_doc/` request format.
1130
1198
  :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
1199
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
1200
+ If the index has a default ingest pipeline specified, setting the value to
1201
+ `_none` turns off the default ingest pipeline for this request. If a final
1202
+ pipeline is configured, it will always run regardless of the value of this
1135
1203
  parameter.
1136
1204
  :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`.
1205
+ this operation visible to search. If `wait_for`, it waits for a refresh to
1206
+ make this operation visible to search. If `false`, it does nothing with refreshes.
1207
+ :param routing: A custom value that is used to route operations to a specific
1208
+ shard.
1209
+ :param timeout: The period the request waits for the following operations: automatic
1210
+ index creation, dynamic mapping updates, waiting for active shards. Elasticsearch
1211
+ waits for at least the specified timeout period before failing. The actual
1212
+ wait time could be longer, particularly when multiple waits occur. This parameter
1213
+ is useful for situations where the primary shard assigned to perform the
1214
+ operation might not be available when the operation runs. Some reasons for
1215
+ this might be that the primary shard is currently recovering from a gateway
1216
+ or undergoing relocation. By default, the operation will wait on the primary
1217
+ shard to become available for at least 1 minute before failing and responding
1218
+ with an error. The actual wait time could be longer, particularly when multiple
1219
+ waits occur.
1220
+ :param version: The explicit version number for concurrency control. It must
1221
+ be a non-negative long number.
1222
+ :param version_type: The version type.
1147
1223
  :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`).
1224
+ before proceeding with the operation. You can set it to `all` or any positive
1225
+ integer up to the total number of shards in the index (`number_of_replicas+1`).
1226
+ The default value of `1` means it waits for each primary shard to be active.
1150
1227
  """
1151
1228
  if index in SKIP_IN_PATH:
1152
1229
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1221,29 +1298,60 @@ class Elasticsearch(BaseClient):
1221
1298
  ] = None,
1222
1299
  ) -> ObjectApiResponse[t.Any]:
1223
1300
  """
1224
- Delete a document. Removes a JSON document from the specified index.
1301
+ .. raw:: html
1302
+
1303
+ <p>Delete a document.</p>
1304
+ <p>Remove a JSON document from the specified index.</p>
1305
+ <p>NOTE: You cannot send deletion requests directly to a data stream.
1306
+ To delete a document in a data stream, you must target the backing index containing the document.</p>
1307
+ <p><strong>Optimistic concurrency control</strong></p>
1308
+ <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.
1309
+ If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
1310
+ <p><strong>Versioning</strong></p>
1311
+ <p>Each document indexed is versioned.
1312
+ 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.
1313
+ Every write operation run on a document, deletes included, causes its version to be incremented.
1314
+ The version number of a deleted document remains available for a short time after deletion to allow for control of concurrent operations.
1315
+ 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>
1316
+ <p><strong>Routing</strong></p>
1317
+ <p>If routing is used during indexing, the routing value also needs to be specified to delete a document.</p>
1318
+ <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>
1319
+ <p>For example:</p>
1320
+ <pre><code>DELETE /my-index-000001/_doc/1?routing=shard-1
1321
+ </code></pre>
1322
+ <p>This request deletes the document with ID 1, but it is routed based on the user.
1323
+ The document is not deleted if the correct routing is not specified.</p>
1324
+ <p><strong>Distributed</strong></p>
1325
+ <p>The delete operation gets hashed into a specific shard ID.
1326
+ It then gets redirected into the primary shard within that ID group and replicated (if needed) to shard replicas within that ID group.</p>
1327
+
1225
1328
 
1226
1329
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete.html>`_
1227
1330
 
1228
- :param index: Name of the target index.
1229
- :param id: Unique identifier for the document.
1331
+ :param index: The name of the target index.
1332
+ :param id: A unique identifier for the document.
1230
1333
  :param if_primary_term: Only perform the operation if the document has this primary
1231
1334
  term.
1232
1335
  :param if_seq_no: Only perform the operation if the document has this sequence
1233
1336
  number.
1234
1337
  :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`).
1338
+ this operation visible to search. If `wait_for`, it waits for a refresh to
1339
+ make this operation visible to search. If `false`, it does nothing with refreshes.
1340
+ :param routing: A custom value used to route operations to a specific shard.
1341
+ :param timeout: The period to wait for active shards. This parameter is useful
1342
+ for situations where the primary shard assigned to perform the delete operation
1343
+ might not be available when the delete operation runs. Some reasons for this
1344
+ might be that the primary shard is currently recovering from a store or undergoing
1345
+ relocation. By default, the delete operation will wait on the primary shard
1346
+ to become available for up to 1 minute before failing and responding with
1347
+ an error.
1348
+ :param version: An explicit version number for concurrency control. It must match
1349
+ the current version of the document for the request to succeed.
1350
+ :param version_type: The version type.
1351
+ :param wait_for_active_shards: The minimum number of shard copies that must be
1352
+ active before proceeding with the operation. You can set it to `all` or any
1353
+ positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1354
+ The default value of `1` means it waits for each primary shard to be active.
1247
1355
  """
1248
1356
  if index in SKIP_IN_PATH:
1249
1357
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1343,72 +1451,148 @@ class Elasticsearch(BaseClient):
1343
1451
  body: t.Optional[t.Dict[str, t.Any]] = None,
1344
1452
  ) -> ObjectApiResponse[t.Any]:
1345
1453
  """
1346
- Delete documents. Deletes documents that match the specified query.
1454
+ .. raw:: html
1455
+
1456
+ <p>Delete documents.</p>
1457
+ <p>Deletes documents that match the specified query.</p>
1458
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
1459
+ <ul>
1460
+ <li><code>read</code></li>
1461
+ <li><code>delete</code> or <code>write</code></li>
1462
+ </ul>
1463
+ <p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.
1464
+ 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.
1465
+ 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>
1466
+ <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>
1467
+ <p>While processing a delete by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents to delete.
1468
+ A bulk delete request is performed for each batch of matching documents.
1469
+ If a search or bulk request is rejected, the requests are retried up to 10 times, with exponential back off.
1470
+ If the maximum retry limit is reached, processing halts and all failed requests are returned in the response.
1471
+ Any delete requests that completed successfully still stick, they are not rolled back.</p>
1472
+ <p>You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
1473
+ 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>
1474
+ <p><strong>Throttling delete requests</strong></p>
1475
+ <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.
1476
+ This pads each batch with a wait time to throttle the rate.
1477
+ Set <code>requests_per_second</code> to <code>-1</code> to disable throttling.</p>
1478
+ <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.
1479
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
1480
+ By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
1481
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
1482
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
1483
+ </code></pre>
1484
+ <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.
1485
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
1486
+ <p><strong>Slicing</strong></p>
1487
+ <p>Delete by query supports sliced scroll to parallelize the delete process.
1488
+ This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
1489
+ <p>Setting <code>slices</code> to <code>auto</code> lets Elasticsearch choose the number of slices to use.
1490
+ This setting will use one slice per shard, up to a certain limit.
1491
+ 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.
1492
+ Adding slices to the delete by query operation creates sub-requests which means it has some quirks:</p>
1493
+ <ul>
1494
+ <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>
1495
+ <li>Fetching the status of the task for the request with slices only contains the status of completed slices.</li>
1496
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
1497
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
1498
+ <li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
1499
+ <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>
1500
+ <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>
1501
+ <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>
1502
+ </ul>
1503
+ <p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
1504
+ <ul>
1505
+ <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>
1506
+ <li>Delete performance scales linearly across available resources with the number of slices.</li>
1507
+ </ul>
1508
+ <p>Whether query or delete performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
1509
+ <p><strong>Cancel a delete by query operation</strong></p>
1510
+ <p>Any delete by query can be canceled using the task cancel API. For example:</p>
1511
+ <pre><code>POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
1512
+ </code></pre>
1513
+ <p>The task ID can be found by using the get tasks API.</p>
1514
+ <p>Cancellation should happen quickly but might take a few seconds.
1515
+ 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>
1516
+
1347
1517
 
1348
1518
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1349
1519
 
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`.
1520
+ :param index: A comma-separated list of data streams, indices, and aliases to
1521
+ search. It supports wildcards (`*`). To search all data streams or indices,
1522
+ omit this parameter or use `*` or `_all`.
1353
1523
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
1354
1524
  expression, index alias, or `_all` value targets only missing or closed indices.
1355
1525
  This behavior applies even if the request targets other open indices. For
1356
1526
  example, a request targeting `foo*,bar*` returns an error if an index starts
1357
1527
  with `foo` but no index starts with `bar`.
1358
1528
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1359
- :param analyzer: Analyzer to use for the query string.
1529
+ This parameter can be used only when the `q` query string parameter is specified.
1530
+ :param analyzer: Analyzer to use for the query string. This parameter can be
1531
+ used only when the `q` query string parameter is specified.
1360
1532
  :param conflicts: What to do if delete by query hits version conflicts: `abort`
1361
1533
  or `proceed`.
1362
1534
  :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`.
1535
+ `OR`. This parameter can be used only when the `q` query string parameter
1536
+ is specified.
1537
+ :param df: The field to use as default where no field prefix is given in the
1538
+ query string. This parameter can be used only when the `q` query string parameter
1539
+ is specified.
1540
+ :param expand_wildcards: The type of index that wildcard patterns can match.
1541
+ If the request can target data streams, this argument determines whether
1542
+ wildcard expressions match hidden data streams. It supports comma-separated
1543
+ values, such as `open,hidden`.
1370
1544
  :param from_: Starting offset (default: 0)
1371
1545
  :param ignore_unavailable: If `false`, the request returns an error if it targets
1372
1546
  a missing or closed index.
1373
1547
  :param lenient: If `true`, format-based query failures (such as providing text
1374
- to a numeric field) in the query string will be ignored.
1548
+ to a numeric field) in the query string will be ignored. This parameter can
1549
+ be used only when the `q` query string parameter is specified.
1375
1550
  :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.
1551
+ :param preference: The node or shard the operation should be performed on. It
1552
+ is random by default.
1553
+ :param q: A query in the Lucene query string syntax.
1554
+ :param query: The documents to delete specified with Query DSL.
1380
1555
  :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1381
- delete by query after the request completes.
1556
+ delete by query after the request completes. This is different than the delete
1557
+ API's `refresh` parameter, which causes just the shard that received the
1558
+ delete request to be refreshed. Unlike the delete API, it does not support
1559
+ `wait_for`.
1382
1560
  :param request_cache: If `true`, the request cache is used for this request.
1383
1561
  Defaults to the index-level setting.
1384
1562
  :param requests_per_second: The throttle for this request in sub-requests per
1385
1563
  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`.
1564
+ :param routing: A custom value used to route operations to a specific shard.
1565
+ :param scroll: The period to retain the search context for scrolling.
1566
+ :param scroll_size: The size of the scroll request that powers the operation.
1567
+ :param search_timeout: The explicit timeout for each search request. It defaults
1568
+ to no timeout.
1569
+ :param search_type: The type of the search operation. Available options include
1570
+ `query_then_fetch` and `dfs_query_then_fetch`.
1393
1571
  :param slice: Slice the request manually using the provided slice ID and total
1394
1572
  number of slices.
1395
1573
  :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.
1574
+ :param sort: A comma-separated list of `<field>:<direction>` pairs.
1575
+ :param stats: The specific `tag` of the request for logging and statistical purposes.
1576
+ :param terminate_after: The maximum number of documents to collect for each shard.
1399
1577
  If a query reaches this limit, Elasticsearch terminates the query early.
1400
1578
  Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
1401
1579
  applies this parameter to each shard handling the request. When possible,
1402
1580
  let Elasticsearch perform early termination automatically. Avoid specifying
1403
1581
  this parameter for requests that target data streams with backing indices
1404
1582
  across multiple data tiers.
1405
- :param timeout: Period each deletion request waits for active shards.
1583
+ :param timeout: The period each deletion request waits for active shards.
1406
1584
  :param version: If `true`, returns the document version as part of a hit.
1407
1585
  :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`).
1586
+ before proceeding with the operation. Set to `all` or any positive integer
1587
+ up to the total number of shards in the index (`number_of_replicas+1`). The
1588
+ `timeout` value controls how long each write request waits for unavailable
1589
+ shards to become available.
1410
1590
  :param wait_for_completion: If `true`, the request blocks until the operation
1411
- is complete.
1591
+ is complete. If `false`, Elasticsearch performs some preflight checks, launches
1592
+ the request, and returns a task you can use to cancel or get the status of
1593
+ the task. Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`.
1594
+ When you are done with a task, you should delete the task document so Elasticsearch
1595
+ can reclaim the space.
1412
1596
  """
1413
1597
  if index in SKIP_IN_PATH:
1414
1598
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1521,16 +1705,18 @@ class Elasticsearch(BaseClient):
1521
1705
  requests_per_second: t.Optional[float] = None,
1522
1706
  ) -> ObjectApiResponse[t.Any]:
1523
1707
  """
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.
1708
+ .. raw:: html
1709
+
1710
+ <p>Throttle a delete by query operation.</p>
1711
+ <p>Change the number of requests per second for a particular delete by query operation.
1712
+ 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
1713
 
1529
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1714
+
1715
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html#docs-delete-by-query-rethrottle>`_
1530
1716
 
1531
1717
  :param task_id: The ID for the task.
1532
1718
  :param requests_per_second: The throttle for this request in sub-requests per
1533
- second.
1719
+ second. To disable throttling, set it to `-1`.
1534
1720
  """
1535
1721
  if task_id in SKIP_IN_PATH:
1536
1722
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -1570,16 +1756,22 @@ class Elasticsearch(BaseClient):
1570
1756
  timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1571
1757
  ) -> ObjectApiResponse[t.Any]:
1572
1758
  """
1573
- Delete a script or search template. Deletes a stored script or search template.
1759
+ .. raw:: html
1574
1760
 
1575
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
1761
+ <p>Delete a script or search template.
1762
+ Deletes a stored script or search template.</p>
1576
1763
 
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.
1764
+
1765
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/delete-stored-script-api.html>`_
1766
+
1767
+ :param id: The identifier for the stored script or search template.
1768
+ :param master_timeout: The period to wait for a connection to the master node.
1769
+ If no response is received before the timeout expires, the request fails
1770
+ and returns an error. It can also be set to `-1` to indicate that the request
1771
+ should never timeout.
1772
+ :param timeout: The period to wait for a response. If no response is received
1773
+ before the timeout expires, the request fails and returns an error. It can
1774
+ also be set to `-1` to indicate that the request should never timeout.
1583
1775
  """
1584
1776
  if id in SKIP_IN_PATH:
1585
1777
  raise ValueError("Empty value passed for parameter 'id'")
@@ -1638,32 +1830,60 @@ class Elasticsearch(BaseClient):
1638
1830
  ] = None,
1639
1831
  ) -> HeadApiResponse:
1640
1832
  """
1641
- Check a document. Checks if a specified document exists.
1833
+ .. raw:: html
1834
+
1835
+ <p>Check a document.</p>
1836
+ <p>Verify that a document exists.
1837
+ For example, check to see if a document with the <code>_id</code> 0 exists:</p>
1838
+ <pre><code>HEAD my-index-000001/_doc/0
1839
+ </code></pre>
1840
+ <p>If the document exists, the API returns a status code of <code>200 - OK</code>.
1841
+ If the document doesn’t exist, the API returns <code>404 - Not Found</code>.</p>
1842
+ <p><strong>Versioning support</strong></p>
1843
+ <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>
1844
+ <p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
1845
+ The old version of the document doesn't disappear immediately, although you won't be able to access it.
1846
+ Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
1847
+
1642
1848
 
1643
1849
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1644
1850
 
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.
1851
+ :param index: A comma-separated list of data streams, indices, and aliases. It
1852
+ supports wildcards (`*`).
1853
+ :param id: A unique document identifier.
1854
+ :param preference: The node or shard the operation should be performed on. By
1855
+ default, the operation is randomized between the shard replicas. If it is
1856
+ set to `_local`, the operation will prefer to be run on a local allocated
1857
+ shard when possible. If it is set to a custom value, the value is used to
1858
+ guarantee that the same shards will be used for the same custom value. This
1859
+ can help with "jumping values" when hitting different shards in different
1860
+ refresh states. A sample value can be something like the web session ID or
1861
+ the user name.
1650
1862
  :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.
1863
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
1864
+ the document. Setting it to `true` should be done after careful thought and
1865
+ verification that this does not cause a heavy load on the system (and slow
1866
+ down indexing).
1867
+ :param routing: A custom value used to route operations to a specific shard.
1868
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
1869
+ or lists the fields to return.
1870
+ :param source_excludes: A comma-separated list of source fields to exclude from
1871
+ the response. You can also use this parameter to exclude fields from the
1872
+ subset specified in `_source_includes` query parameter. If the `_source`
1873
+ parameter is `false`, this parameter is ignored.
1658
1874
  :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.
1875
+ the response. If this parameter is specified, only these source fields are
1876
+ returned. You can exclude fields from this subset using the `_source_excludes`
1877
+ query parameter. If the `_source` parameter is `false`, this parameter is
1878
+ ignored.
1879
+ :param stored_fields: A comma-separated list of stored fields to return as part
1880
+ of a hit. If no fields are specified, no stored fields are included in the
1881
+ response. If this field is specified, the `_source` parameter defaults to
1882
+ `false`.
1663
1883
  :param version: Explicit version number for concurrency control. The specified
1664
1884
  version must match the current version of the document for the request to
1665
1885
  succeed.
1666
- :param version_type: Specific version type: `external`, `external_gte`.
1886
+ :param version_type: The version type.
1667
1887
  """
1668
1888
  if index in SKIP_IN_PATH:
1669
1889
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1739,29 +1959,38 @@ class Elasticsearch(BaseClient):
1739
1959
  ] = None,
1740
1960
  ) -> HeadApiResponse:
1741
1961
  """
1742
- Check for a document source. Checks if a document's `_source` is stored.
1962
+ .. raw:: html
1963
+
1964
+ <p>Check for a document source.</p>
1965
+ <p>Check whether a document source exists in an index.
1966
+ For example:</p>
1967
+ <pre><code>HEAD my-index-000001/_source/1
1968
+ </code></pre>
1969
+ <p>A document's source is not available if it is disabled in the mapping.</p>
1970
+
1743
1971
 
1744
1972
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1745
1973
 
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.
1974
+ :param index: A comma-separated list of data streams, indices, and aliases. It
1975
+ supports wildcards (`*`).
1976
+ :param id: A unique identifier for the document.
1977
+ :param preference: The node or shard the operation should be performed on. By
1978
+ default, the operation is randomized between the shard replicas.
1979
+ :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1980
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
1981
+ the document. Setting it to `true` should be done after careful thought and
1982
+ verification that this does not cause a heavy load on the system (and slow
1983
+ down indexing).
1984
+ :param routing: A custom value used to route operations to a specific shard.
1985
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
1986
+ or lists the fields to return.
1757
1987
  :param source_excludes: A comma-separated list of source fields to exclude in
1758
1988
  the response.
1759
1989
  :param source_includes: A comma-separated list of source fields to include in
1760
1990
  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`.
1991
+ :param version: The version number for concurrency control. It must match the
1992
+ current version of the document for the request to succeed.
1993
+ :param version_type: The version type.
1765
1994
  """
1766
1995
  if index in SKIP_IN_PATH:
1767
1996
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1839,34 +2068,47 @@ class Elasticsearch(BaseClient):
1839
2068
  body: t.Optional[t.Dict[str, t.Any]] = None,
1840
2069
  ) -> ObjectApiResponse[t.Any]:
1841
2070
  """
1842
- Explain a document match result. Returns information about why a specific document
1843
- matches, or doesn’t match, a query.
2071
+ .. raw:: html
2072
+
2073
+ <p>Explain a document match result.
2074
+ Get information about why a specific document matches, or doesn't match, a query.
2075
+ It computes a score explanation for a query and a specific document.</p>
2076
+
1844
2077
 
1845
2078
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-explain.html>`_
1846
2079
 
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.
2080
+ :param index: Index names that are used to limit the request. Only a single index
2081
+ name can be provided to this parameter.
2082
+ :param id: The document identifier.
1850
2083
  :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.
2084
+ This parameter can be used only when the `q` query string parameter is specified.
2085
+ :param analyzer: The analyzer to use for the query string. This parameter can
2086
+ be used only when the `q` query string parameter is specified.
1853
2087
  :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.
2088
+ `OR`. This parameter can be used only when the `q` query string parameter
2089
+ is specified.
2090
+ :param df: The field to use as default where no field prefix is given in the
2091
+ query string. This parameter can be used only when the `q` query string parameter
2092
+ is specified.
1857
2093
  :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.
2094
+ to a numeric field) in the query string will be ignored. This parameter can
2095
+ be used only when the `q` query string parameter is specified.
2096
+ :param preference: The node or shard the operation should be performed on. It
2097
+ is random by default.
2098
+ :param q: The query in the Lucene query string syntax.
1862
2099
  :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
2100
+ :param routing: A custom value used to route operations to a specific shard.
2101
+ :param source: `True` or `false` to return the `_source` field or not or a list
1865
2102
  of fields to return.
1866
2103
  :param source_excludes: A comma-separated list of source fields to exclude from
1867
- the response.
2104
+ the response. You can also use this parameter to exclude fields from the
2105
+ subset specified in `_source_includes` query parameter. If the `_source`
2106
+ parameter is `false`, this parameter is ignored.
1868
2107
  :param source_includes: A comma-separated list of source fields to include in
1869
- the response.
2108
+ the response. If this parameter is specified, only these source fields are
2109
+ returned. You can exclude fields from this subset using the `_source_excludes`
2110
+ query parameter. If the `_source` parameter is `false`, this parameter is
2111
+ ignored.
1870
2112
  :param stored_fields: A comma-separated list of stored fields to return in the
1871
2113
  response.
1872
2114
  """
@@ -1959,15 +2201,18 @@ class Elasticsearch(BaseClient):
1959
2201
  body: t.Optional[t.Dict[str, t.Any]] = None,
1960
2202
  ) -> ObjectApiResponse[t.Any]:
1961
2203
  """
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.
2204
+ .. raw:: html
2205
+
2206
+ <p>Get the field capabilities.</p>
2207
+ <p>Get information about the capabilities of fields among multiple indices.</p>
2208
+ <p>For data streams, the API returns field capabilities among the stream’s backing indices.
2209
+ It returns runtime fields like any other field.
2210
+ 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>
2211
+
1967
2212
 
1968
2213
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-field-caps.html>`_
1969
2214
 
1970
- :param index: Comma-separated list of data streams, indices, and aliases used
2215
+ :param index: A comma-separated list of data streams, indices, and aliases used
1971
2216
  to limit the request. Supports wildcards (*). To target all data streams
1972
2217
  and indices, omit this parameter or use * or _all.
1973
2218
  :param allow_no_indices: If false, the request returns an error if any wildcard
@@ -1975,25 +2220,32 @@ class Elasticsearch(BaseClient):
1975
2220
  This behavior applies even if the request targets other open indices. For
1976
2221
  example, a request targeting `foo*,bar*` returns an error if an index starts
1977
2222
  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
2223
+ :param expand_wildcards: The type of index that wildcard patterns can match.
2224
+ If the request can target data streams, this argument determines whether
2225
+ wildcard expressions match hidden data streams. Supports comma-separated
2226
+ values, such as `open,hidden`.
2227
+ :param fields: A list of fields to retrieve capabilities for. Wildcard (`*`)
2228
+ expressions are supported.
2229
+ :param filters: A comma-separated list of filters to apply to the response.
1985
2230
  :param ignore_unavailable: If `true`, missing or closed indices are not included
1986
2231
  in the response.
1987
2232
  :param include_empty_fields: If false, empty fields are not included in the response.
1988
2233
  :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
2234
+ :param index_filter: Filter indices if the provided query rewrites to `match_none`
2235
+ on every shard. IMPORTANT: The filtering is done on a best-effort basis,
2236
+ it uses index statistics and mappings to rewrite queries to `match_none`
2237
+ instead of fully running the request. For instance a range query over a date
2238
+ field can rewrite to `match_none` if all documents within a shard (including
2239
+ deleted documents) are outside of the provided range. However, not all queries
2240
+ can rewrite to `match_none` so this API may return an index even if the provided
2241
+ filter matches no document.
2242
+ :param runtime_mappings: Define ad-hoc runtime fields in the request similar
1992
2243
  to the way it is done in search requests. These fields exist only as part
1993
2244
  of the query and take precedence over fields defined with the same name in
1994
2245
  the index mappings.
1995
- :param types: Only return results for fields that have one of the types in the
1996
- list
2246
+ :param types: A comma-separated list of field types to include. Any fields that
2247
+ do not match one of these types will be excluded from the results. It defaults
2248
+ to empty, meaning that all field types are returned.
1997
2249
  """
1998
2250
  __path_parts: t.Dict[str, str]
1999
2251
  if index not in SKIP_IN_PATH:
@@ -2079,36 +2331,87 @@ class Elasticsearch(BaseClient):
2079
2331
  ] = None,
2080
2332
  ) -> ObjectApiResponse[t.Any]:
2081
2333
  """
2082
- Get a document by its ID. Retrieves the document with the specified ID from an
2083
- index.
2334
+ .. raw:: html
2335
+
2336
+ <p>Get a document by its ID.</p>
2337
+ <p>Get a document and its source or stored fields from an index.</p>
2338
+ <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).
2339
+ 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.
2340
+ To turn off realtime behavior, set the <code>realtime</code> parameter to false.</p>
2341
+ <p><strong>Source filtering</strong></p>
2342
+ <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.
2343
+ You can turn off <code>_source</code> retrieval by using the <code>_source</code> parameter:</p>
2344
+ <pre><code>GET my-index-000001/_doc/0?_source=false
2345
+ </code></pre>
2346
+ <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.
2347
+ This can be helpful with large documents where partial retrieval can save on network overhead
2348
+ Both parameters take a comma separated list of fields or wildcard expressions.
2349
+ For example:</p>
2350
+ <pre><code>GET my-index-000001/_doc/0?_source_includes=*.id&amp;_source_excludes=entities
2351
+ </code></pre>
2352
+ <p>If you only want to specify includes, you can use a shorter notation:</p>
2353
+ <pre><code>GET my-index-000001/_doc/0?_source=*.id
2354
+ </code></pre>
2355
+ <p><strong>Routing</strong></p>
2356
+ <p>If routing is used during indexing, the routing value also needs to be specified to retrieve a document.
2357
+ For example:</p>
2358
+ <pre><code>GET my-index-000001/_doc/2?routing=user1
2359
+ </code></pre>
2360
+ <p>This request gets the document with ID 2, but it is routed based on the user.
2361
+ The document is not fetched if the correct routing is not specified.</p>
2362
+ <p><strong>Distributed</strong></p>
2363
+ <p>The GET operation is hashed into a specific shard ID.
2364
+ It is then redirected to one of the replicas within that shard ID and returns the result.
2365
+ The replicas are the primary shard and its replicas within that shard ID group.
2366
+ This means that the more replicas you have, the better your GET scaling will be.</p>
2367
+ <p><strong>Versioning support</strong></p>
2368
+ <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>
2369
+ <p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
2370
+ The old version of the document doesn't disappear immediately, although you won't be able to access it.
2371
+ Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
2372
+
2084
2373
 
2085
2374
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
2086
2375
 
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.
2376
+ :param index: The name of the index that contains the document.
2377
+ :param id: A unique document identifier.
2378
+ :param force_synthetic_source: Indicates whether the request forces synthetic
2379
+ `_source`. Use this paramater to test if the mapping supports synthetic `_source`
2380
+ and to get a sense of the worst case performance. Fetches with this parameter
2381
+ enabled will be slower than enabling synthetic source natively in the index.
2382
+ :param preference: The node or shard the operation should be performed on. By
2383
+ default, the operation is randomized between the shard replicas. If it is
2384
+ set to `_local`, the operation will prefer to be run on a local allocated
2385
+ shard when possible. If it is set to a custom value, the value is used to
2386
+ guarantee that the same shards will be used for the same custom value. This
2387
+ can help with "jumping values" when hitting different shards in different
2388
+ refresh states. A sample value can be something like the web session ID or
2389
+ the user name.
2095
2390
  :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.
2391
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
2392
+ the document. Setting it to `true` should be done after careful thought and
2393
+ verification that this does not cause a heavy load on the system (and slow
2394
+ down indexing).
2395
+ :param routing: A custom value used to route operations to a specific shard.
2396
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
2397
+ or lists the fields to return.
2398
+ :param source_excludes: A comma-separated list of source fields to exclude from
2399
+ the response. You can also use this parameter to exclude fields from the
2400
+ subset specified in `_source_includes` query parameter. If the `_source`
2401
+ parameter is `false`, this parameter is ignored.
2103
2402
  :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.
2403
+ the response. If this parameter is specified, only these source fields are
2404
+ returned. You can exclude fields from this subset using the `_source_excludes`
2405
+ query parameter. If the `_source` parameter is `false`, this parameter is
2406
+ ignored.
2407
+ :param stored_fields: A comma-separated list of stored fields to return as part
2408
+ of a hit. If no fields are specified, no stored fields are included in the
2409
+ response. If this field is specified, the `_source` parameter defaults to
2410
+ `false`. Only leaf fields can be retrieved with the `stored_field` option.
2411
+ Object fields can't be returned;​if specified, the request fails.
2412
+ :param version: The version number for concurrency control. It must match the
2413
+ current version of the document for the request to succeed.
2414
+ :param version_type: The version type.
2112
2415
  """
2113
2416
  if index in SKIP_IN_PATH:
2114
2417
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2169,12 +2472,19 @@ class Elasticsearch(BaseClient):
2169
2472
  pretty: t.Optional[bool] = None,
2170
2473
  ) -> ObjectApiResponse[t.Any]:
2171
2474
  """
2172
- Get a script or search template. Retrieves a stored script or search template.
2475
+ .. raw:: html
2476
+
2477
+ <p>Get a script or search template.
2478
+ Retrieves a stored script or search template.</p>
2479
+
2173
2480
 
2174
2481
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2175
2482
 
2176
- :param id: Identifier for the stored script or search template.
2177
- :param master_timeout: Specify timeout for connection to master
2483
+ :param id: The identifier for the stored script or search template.
2484
+ :param master_timeout: The period to wait for the master node. If the master
2485
+ node is not available before the timeout expires, the request fails and returns
2486
+ an error. It can also be set to `-1` to indicate that the request should
2487
+ never timeout.
2178
2488
  """
2179
2489
  if id in SKIP_IN_PATH:
2180
2490
  raise ValueError("Empty value passed for parameter 'id'")
@@ -2211,9 +2521,13 @@ class Elasticsearch(BaseClient):
2211
2521
  pretty: t.Optional[bool] = None,
2212
2522
  ) -> ObjectApiResponse[t.Any]:
2213
2523
  """
2214
- Get script contexts. Get a list of supported script contexts and their methods.
2524
+ .. raw:: html
2525
+
2526
+ <p>Get script contexts.</p>
2527
+ <p>Get a list of supported script contexts and their methods.</p>
2528
+
2215
2529
 
2216
- `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-contexts.html>`_
2530
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-script-contexts-api.html>`_
2217
2531
  """
2218
2532
  __path_parts: t.Dict[str, str] = {}
2219
2533
  __path = "/_script_context"
@@ -2246,9 +2560,13 @@ class Elasticsearch(BaseClient):
2246
2560
  pretty: t.Optional[bool] = None,
2247
2561
  ) -> ObjectApiResponse[t.Any]:
2248
2562
  """
2249
- Get script languages. Get a list of available script types, languages, and contexts.
2563
+ .. raw:: html
2250
2564
 
2251
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2565
+ <p>Get script languages.</p>
2566
+ <p>Get a list of available script types, languages, and contexts.</p>
2567
+
2568
+
2569
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-script-languages-api.html>`_
2252
2570
  """
2253
2571
  __path_parts: t.Dict[str, str] = {}
2254
2572
  __path = "/_script_language"
@@ -2301,29 +2619,41 @@ class Elasticsearch(BaseClient):
2301
2619
  ] = None,
2302
2620
  ) -> ObjectApiResponse[t.Any]:
2303
2621
  """
2304
- Get a document's source. Returns the source of a document.
2622
+ .. raw:: html
2623
+
2624
+ <p>Get a document's source.</p>
2625
+ <p>Get the source of a document.
2626
+ For example:</p>
2627
+ <pre><code>GET my-index-000001/_source/1
2628
+ </code></pre>
2629
+ <p>You can use the source filtering parameters to control which parts of the <code>_source</code> are returned:</p>
2630
+ <pre><code>GET my-index-000001/_source/1/?_source_includes=*.id&amp;_source_excludes=entities
2631
+ </code></pre>
2632
+
2305
2633
 
2306
2634
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
2307
2635
 
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.
2636
+ :param index: The name of the index that contains the document.
2637
+ :param id: A unique document identifier.
2638
+ :param preference: The node or shard the operation should be performed on. By
2639
+ default, the operation is randomized between the shard replicas.
2640
+ :param realtime: If `true`, the request is real-time as opposed to near-real-time.
2641
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
2642
+ the document. Setting it to `true` should be done after careful thought and
2643
+ verification that this does not cause a heavy load on the system (and slow
2644
+ down indexing).
2645
+ :param routing: A custom value used to route operations to a specific shard.
2646
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
2647
+ or lists the fields to return.
2318
2648
  :param source_excludes: A comma-separated list of source fields to exclude in
2319
2649
  the response.
2320
2650
  :param source_includes: A comma-separated list of source fields to include in
2321
2651
  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.
2652
+ :param stored_fields: A comma-separated list of stored fields to return as part
2653
+ of a hit.
2654
+ :param version: The version number for concurrency control. It must match the
2655
+ current version of the document for the request to succeed.
2656
+ :param version_type: The version type.
2327
2657
  """
2328
2658
  if index in SKIP_IN_PATH:
2329
2659
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2384,26 +2714,22 @@ class Elasticsearch(BaseClient):
2384
2714
  verbose: t.Optional[bool] = None,
2385
2715
  ) -> ObjectApiResponse[t.Any]:
2386
2716
  """
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.
2717
+ .. raw:: html
2718
+
2719
+ <p>Get the cluster health.
2720
+ Get a report with the health status of an Elasticsearch cluster.
2721
+ The report contains a list of indicators that compose Elasticsearch functionality.</p>
2722
+ <p>Each indicator has a health status of: green, unknown, yellow or red.
2723
+ The indicator will provide an explanation and metadata describing the reason for its current health status.</p>
2724
+ <p>The cluster’s status is controlled by the worst indicator status.</p>
2725
+ <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.
2726
+ 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>
2727
+ <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.
2728
+ The root cause and remediation steps are encapsulated in a diagnosis.
2729
+ 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>
2730
+ <p>NOTE: The health indicators perform root cause analysis of non-green health statuses. This can be computationally expensive when called frequently.
2731
+ When setting up automated polling of the API for health status, set verbose to false to disable the more expensive analysis logic.</p>
2732
+
2407
2733
 
2408
2734
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/health-api.html>`_
2409
2735
 
@@ -2478,44 +2804,148 @@ class Elasticsearch(BaseClient):
2478
2804
  ] = None,
2479
2805
  ) -> ObjectApiResponse[t.Any]:
2480
2806
  """
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.
2807
+ .. raw:: html
2808
+
2809
+ <p>Create or update a document in an index.</p>
2810
+ <p>Add a JSON document to the specified data stream or index and make it searchable.
2811
+ If the target is an index and the document already exists, the request updates the document and increments its version.</p>
2812
+ <p>NOTE: You cannot use this API to send update requests for existing documents in a data stream.</p>
2813
+ <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>
2814
+ <ul>
2815
+ <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>
2816
+ <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>
2817
+ <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>
2818
+ </ul>
2819
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
2820
+ <p>NOTE: Replica shards might not all be started when an indexing operation returns successfully.
2821
+ By default, only the primary is required. Set <code>wait_for_active_shards</code> to change this default behavior.</p>
2822
+ <p><strong>Automatically create data streams and indices</strong></p>
2823
+ <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>
2824
+ <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>
2825
+ <p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
2826
+ <p>If no mapping exists, the index operation creates a dynamic mapping.
2827
+ By default, new fields and objects are automatically added to the mapping if needed.</p>
2828
+ <p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
2829
+ If it is <code>true</code>, any index can be created automatically.
2830
+ 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.
2831
+ 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.
2832
+ When a list is specified, the default behaviour is to disallow.</p>
2833
+ <p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
2834
+ It does not affect the creation of data streams.</p>
2835
+ <p><strong>Optimistic concurrency control</strong></p>
2836
+ <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.
2837
+ If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
2838
+ <p><strong>Routing</strong></p>
2839
+ <p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
2840
+ 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>
2841
+ <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.
2842
+ This does come at the (very minimal) cost of an additional document parsing pass.
2843
+ 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>
2844
+ <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>
2845
+ <ul>
2846
+ <li>** Distributed**</li>
2847
+ </ul>
2848
+ <p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
2849
+ After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
2850
+ <p><strong>Active shards</strong></p>
2851
+ <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.
2852
+ 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.
2853
+ 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>).
2854
+ This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
2855
+ To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
2856
+ <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).
2857
+ Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
2858
+ <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).
2859
+ If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
2860
+ 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.
2861
+ 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.
2862
+ This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
2863
+ 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.
2864
+ The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
2865
+ <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.
2866
+ 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.
2867
+ The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
2868
+ <p><strong>No operation (noop) updates</strong></p>
2869
+ <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.
2870
+ If this isn't acceptable use the <code>_update</code> API with <code>detect_noop</code> set to <code>true</code>.
2871
+ 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>
2872
+ <p>There isn't a definitive rule for when noop updates aren't acceptable.
2873
+ 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>
2874
+ <p><strong>Versioning</strong></p>
2875
+ <p>Each indexed document is given a version number.
2876
+ By default, internal versioning is used that starts at 1 and increments with each update, deletes included.
2877
+ Optionally, the version number can be set to an external value (for example, if maintained in a database).
2878
+ To enable this functionality, <code>version_type</code> should be set to <code>external</code>.
2879
+ 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>
2880
+ <p>NOTE: Versioning is completely real time, and is not affected by the near real time aspects of search operations.
2881
+ If no version is provided, the operation runs without any version checks.</p>
2882
+ <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.
2883
+ If true, the document will be indexed and the new version number used.
2884
+ 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>
2885
+ <pre><code>PUT my-index-000001/_doc/1?version=2&amp;version_type=external
2886
+ {
2887
+ &quot;user&quot;: {
2888
+ &quot;id&quot;: &quot;elkbee&quot;
2889
+ }
2890
+ }
2891
+
2892
+ In this example, the operation will succeed since the supplied version of 2 is higher than the current document version of 1.
2893
+ 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).
2894
+
2895
+ 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.
2896
+ 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.
2897
+ </code></pre>
2898
+
2484
2899
 
2485
2900
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
2486
2901
 
2487
- :param index: Name of the data stream or index to target.
2902
+ :param index: The name of the data stream or index to target. If the target doesn't
2903
+ exist and matches the name or wildcard (`*`) pattern of an index template
2904
+ with a `data_stream` definition, this request creates the data stream. If
2905
+ the target doesn't exist and doesn't match a data stream template, this request
2906
+ creates the index. You can check for existing targets with the resolve index
2907
+ API.
2488
2908
  :param document:
2489
- :param id: Unique identifier for the document.
2909
+ :param id: A unique identifier for the document. To automatically generate a
2910
+ document ID, use the `POST /<target>/_doc/` request format and omit this
2911
+ parameter.
2490
2912
  :param if_primary_term: Only perform the operation if the document has this primary
2491
2913
  term.
2492
2914
  :param if_seq_no: Only perform the operation if the document has this sequence
2493
2915
  number.
2494
- :param op_type: Set to create to only index the document if it does not already
2916
+ :param op_type: Set to `create` to only index the document if it does not already
2495
2917
  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.
2918
+ the indexing operation will fail. The behavior is the same as using the `<index>/_create`
2919
+ endpoint. If a document ID is specified, this paramater defaults to `index`.
2920
+ Otherwise, it defaults to `create`. If the request targets a data stream,
2921
+ an `op_type` of `create` is required.
2922
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
2500
2923
  If the index has a default ingest pipeline specified, then setting the value
2501
2924
  to `_none` disables the default ingest pipeline for this request. If a final
2502
2925
  pipeline is configured it will always run, regardless of the value of this
2503
2926
  parameter.
2504
2927
  :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`.
2928
+ this operation visible to search. If `wait_for`, it waits for a refresh to
2929
+ make this operation visible to search. If `false`, it does nothing with refreshes.
2508
2930
  :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`.
2931
+ :param routing: A custom value that is used to route operations to a specific
2932
+ shard.
2933
+ :param timeout: The period the request waits for the following operations: automatic
2934
+ index creation, dynamic mapping updates, waiting for active shards. This
2935
+ parameter is useful for situations where the primary shard assigned to perform
2936
+ the operation might not be available when the operation runs. Some reasons
2937
+ for this might be that the primary shard is currently recovering from a gateway
2938
+ or undergoing relocation. By default, the operation will wait on the primary
2939
+ shard to become available for at least 1 minute before failing and responding
2940
+ with an error. The actual wait time could be longer, particularly when multiple
2941
+ waits occur.
2942
+ :param version: An explicit version number for concurrency control. It must be
2943
+ a non-negative long number.
2944
+ :param version_type: The version type.
2516
2945
  :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`).
2946
+ before proceeding with the operation. You can set it to `all` or any positive
2947
+ integer up to the total number of shards in the index (`number_of_replicas+1`).
2948
+ The default value of `1` means it waits for each primary shard to be active.
2519
2949
  """
2520
2950
  if index in SKIP_IN_PATH:
2521
2951
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2589,7 +3019,11 @@ class Elasticsearch(BaseClient):
2589
3019
  pretty: t.Optional[bool] = None,
2590
3020
  ) -> ObjectApiResponse[t.Any]:
2591
3021
  """
2592
- Get cluster info. Get basic build, version, and cluster information.
3022
+ .. raw:: html
3023
+
3024
+ <p>Get cluster info.
3025
+ Get basic build, version, and cluster information.</p>
3026
+
2593
3027
 
2594
3028
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/rest-api-root.html>`_
2595
3029
  """
@@ -2646,38 +3080,48 @@ class Elasticsearch(BaseClient):
2646
3080
  body: t.Optional[t.Dict[str, t.Any]] = None,
2647
3081
  ) -> ObjectApiResponse[t.Any]:
2648
3082
  """
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>`_
3083
+ .. raw:: html
3084
+
3085
+ <p>Run a knn search.</p>
3086
+ <p>NOTE: The kNN search API has been replaced by the <code>knn</code> option in the search API.</p>
3087
+ <p>Perform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents.
3088
+ Given a query vector, the API finds the k closest vectors and returns those documents as search hits.</p>
3089
+ <p>Elasticsearch uses the HNSW algorithm to support efficient kNN search.
3090
+ Like most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed.
3091
+ This means the results returned are not always the true k closest neighbors.</p>
3092
+ <p>The kNN search API supports restricting the search using a filter.
3093
+ The search will return the top k documents that also match the filter query.</p>
3094
+ <p>A kNN search response has the exact same structure as a search API response.
3095
+ However, certain sections have a meaning specific to kNN search:</p>
3096
+ <ul>
3097
+ <li>The document <code>_score</code> is determined by the similarity between the query and document vector.</li>
3098
+ <li>The <code>hits.total</code> object contains the total number of nearest neighbor candidates considered, which is <code>num_candidates * num_shards</code>. The <code>hits.total.relation</code> will always be <code>eq</code>, indicating an exact value.</li>
3099
+ </ul>
3100
+
3101
+
3102
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/knn-search-api.html>`_
2660
3103
 
2661
3104
  :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
3105
+ to perform the operation on all indices.
3106
+ :param knn: The kNN query to run.
2664
3107
  :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.
3108
+ these patterns in the `hits.fields` property of the response. It accepts
3109
+ wildcard (`*`) patterns.
2667
3110
  :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
3111
+ in the `hits.fields` property of the response. It accepts wildcard (`*`)
3112
+ patterns.
3113
+ :param filter: A query to filter the documents that can match. The kNN search
3114
+ will return the top `k` documents that also match this filter. The value
3115
+ can be a single query or a list of queries. If `filter` isn't provided, all
3116
+ documents are allowed to match.
3117
+ :param routing: A comma-separated list of specific routing values.
2674
3118
  :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.
3119
+ These fields are returned in the `hits._source` property of the search response.
3120
+ :param stored_fields: A list of stored fields to return as part of a hit. If
3121
+ no fields are specified, no stored fields are included in the response. If
3122
+ this field is specified, the `_source` parameter defaults to `false`. You
3123
+ can pass `_source: true` to return both source fields and stored fields in
3124
+ the search response.
2681
3125
  """
2682
3126
  if index in SKIP_IN_PATH:
2683
3127
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2755,10 +3199,21 @@ class Elasticsearch(BaseClient):
2755
3199
  body: t.Optional[t.Dict[str, t.Any]] = None,
2756
3200
  ) -> ObjectApiResponse[t.Any]:
2757
3201
  """
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.
3202
+ .. raw:: html
3203
+
3204
+ <p>Get multiple documents.</p>
3205
+ <p>Get multiple JSON documents by ID from one or more indices.
3206
+ If you specify an index in the request URI, you only need to specify the document IDs in the request body.
3207
+ To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail.</p>
3208
+ <p><strong>Filter source fields</strong></p>
3209
+ <p>By default, the <code>_source</code> field is returned for every document (if stored).
3210
+ 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.
3211
+ 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>
3212
+ <p><strong>Get stored fields</strong></p>
3213
+ <p>Use the <code>stored_fields</code> attribute to specify the set of stored fields you want to retrieve.
3214
+ Any requested fields that are not stored are ignored.
3215
+ 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>
3216
+
2762
3217
 
2763
3218
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-get.html>`_
2764
3219
 
@@ -2879,13 +3334,21 @@ class Elasticsearch(BaseClient):
2879
3334
  typed_keys: t.Optional[bool] = None,
2880
3335
  ) -> ObjectApiResponse[t.Any]:
2881
3336
  """
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`.
3337
+ .. raw:: html
3338
+
3339
+ <p>Run multiple searches.</p>
3340
+ <p>The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format.
3341
+ The structure is as follows:</p>
3342
+ <pre><code>header\\n
3343
+ body\\n
3344
+ header\\n
3345
+ body\\n
3346
+ </code></pre>
3347
+ <p>This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node.</p>
3348
+ <p>IMPORTANT: The final line of data must end with a newline character <code>\\n</code>.
3349
+ Each newline character may be preceded by a carriage return <code>\\r</code>.
3350
+ When sending requests to this endpoint the <code>Content-Type</code> header should be set to <code>application/x-ndjson</code>.</p>
3351
+
2889
3352
 
2890
3353
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
2891
3354
 
@@ -3017,22 +3480,35 @@ class Elasticsearch(BaseClient):
3017
3480
  typed_keys: t.Optional[bool] = None,
3018
3481
  ) -> ObjectApiResponse[t.Any]:
3019
3482
  """
3020
- Run multiple templated searches.
3483
+ .. raw:: html
3021
3484
 
3022
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
3485
+ <p>Run multiple templated searches.</p>
3486
+ <p>Run multiple templated searches with a single request.
3487
+ 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.
3488
+ For example:</p>
3489
+ <pre><code>$ cat requests
3490
+ { &quot;index&quot;: &quot;my-index&quot; }
3491
+ { &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 }}
3492
+ { &quot;index&quot;: &quot;my-other-index&quot; }
3493
+ { &quot;id&quot;: &quot;my-other-search-template&quot;, &quot;params&quot;: { &quot;query_type&quot;: &quot;match_all&quot; }}
3494
+
3495
+ $ curl -H &quot;Content-Type: application/x-ndjson&quot; -XGET localhost:9200/_msearch/template --data-binary &quot;@requests&quot;; echo
3496
+ </code></pre>
3497
+
3498
+
3499
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/multi-search-template.html>`_
3023
3500
 
3024
3501
  :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 `*`.
3502
+ :param index: A comma-separated list of data streams, indices, and aliases to
3503
+ search. It supports wildcards (`*`). To search all data streams and indices,
3504
+ omit this parameter or use `*`.
3028
3505
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
3029
3506
  for cross-cluster search requests.
3030
- :param max_concurrent_searches: Maximum number of concurrent searches the API
3031
- can run.
3507
+ :param max_concurrent_searches: The maximum number of concurrent searches the
3508
+ API can run.
3032
3509
  :param rest_total_hits_as_int: If `true`, the response returns `hits.total` as
3033
3510
  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`.
3511
+ :param search_type: The type of the search operation.
3036
3512
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
3037
3513
  names with their respective types.
3038
3514
  """
@@ -3112,34 +3588,41 @@ class Elasticsearch(BaseClient):
3112
3588
  body: t.Optional[t.Dict[str, t.Any]] = None,
3113
3589
  ) -> ObjectApiResponse[t.Any]:
3114
3590
  """
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.
3591
+ .. raw:: html
3592
+
3593
+ <p>Get multiple term vectors.</p>
3594
+ <p>Get multiple term vectors with a single request.
3595
+ You can specify existing documents by index and ID or provide artificial documents in the body of the request.
3596
+ You can specify the index in the request body or request URI.
3597
+ The response contains a <code>docs</code> array with all the fetched termvectors.
3598
+ Each element has the structure provided by the termvectors API.</p>
3599
+ <p><strong>Artificial documents</strong></p>
3600
+ <p>You can also use <code>mtermvectors</code> to generate term vectors for artificial documents provided in the body of the request.
3601
+ The mapping used is determined by the specified <code>_index</code>.</p>
3602
+
3120
3603
 
3121
3604
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-termvectors.html>`_
3122
3605
 
3123
- :param index: Name of the index that contains the documents.
3124
- :param docs: Array of existing or artificial documents.
3606
+ :param index: The name of the index that contains the documents.
3607
+ :param docs: An array of existing or artificial documents.
3125
3608
  :param field_statistics: If `true`, the response includes the document count,
3126
3609
  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
3610
+ :param fields: A comma-separated list or wildcard expressions of fields to include
3611
+ in the statistics. It is used as the default list unless a specific field
3612
+ list is provided in the `completion_fields` or `fielddata_fields` parameters.
3613
+ :param ids: A simplified syntax to specify documents by their ID if they're in
3131
3614
  the same index.
3132
3615
  :param offsets: If `true`, the response includes term offsets.
3133
3616
  :param payloads: If `true`, the response includes term payloads.
3134
3617
  :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.
3618
+ :param preference: The node or shard the operation should be performed on. It
3619
+ is random by default.
3137
3620
  :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.
3621
+ :param routing: A custom value used to route operations to a specific shard.
3139
3622
  :param term_statistics: If true, the response includes term frequency and document
3140
3623
  frequency.
3141
3624
  :param version: If `true`, returns the document version as part of a hit.
3142
- :param version_type: Specific version type.
3625
+ :param version_type: The version type.
3143
3626
  """
3144
3627
  __path_parts: t.Dict[str, str]
3145
3628
  if index not in SKIP_IN_PATH:
@@ -3228,36 +3711,59 @@ class Elasticsearch(BaseClient):
3228
3711
  body: t.Optional[t.Dict[str, t.Any]] = None,
3229
3712
  ) -> ObjectApiResponse[t.Any]:
3230
3713
  """
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.
3714
+ .. raw:: html
3715
+
3716
+ <p>Open a point in time.</p>
3717
+ <p>A search request by default runs against the most recent visible data of the target indices,
3718
+ which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the
3719
+ state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple
3720
+ search requests using the same point in time. For example, if refreshes happen between
3721
+ <code>search_after</code> requests, then the results of those requests might not be consistent as changes happening
3722
+ between searches are only visible to the more recent point in time.</p>
3723
+ <p>A point in time must be opened explicitly before being used in search requests.</p>
3724
+ <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>
3725
+ <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.
3726
+ If you want to retrieve more hits, use PIT with <code>search_after</code>.</p>
3727
+ <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>
3728
+ <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.
3729
+ 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>
3730
+ <p><strong>Keeping point in time alive</strong></p>
3731
+ <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.
3732
+ 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>
3733
+ <p>Normally, the background merge process optimizes the index by merging together smaller segments to create new, bigger segments.
3734
+ Once the smaller segments are no longer needed they are deleted.
3735
+ However, open point-in-times prevent the old segments from being deleted since they are still in use.</p>
3736
+ <p>TIP: Keeping older segments alive means that more disk space and file handles are needed.
3737
+ Ensure that you have configured your nodes to have ample free file handles.</p>
3738
+ <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.
3739
+ 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.
3740
+ Note that a point-in-time doesn't prevent its associated indices from being deleted.
3741
+ You can check how many point-in-times (that is, search contexts) are open with the nodes stats API.</p>
3742
+
3240
3743
 
3241
3744
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
3242
3745
 
3243
3746
  :param index: A comma-separated list of index names to open point in time; use
3244
3747
  `_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`.
3748
+ :param keep_alive: Extend the length of time that the point in time persists.
3749
+ :param allow_partial_search_results: Indicates whether the point in time tolerates
3750
+ unavailable shards or shard failures when initially creating the PIT. If
3751
+ `false`, creating a point in time request when a shard is missing or unavailable
3752
+ will throw an exception. If `true`, the point in time will contain all the
3753
+ shards that are available at the time of the request.
3754
+ :param expand_wildcards: The type of index that wildcard patterns can match.
3755
+ If the request can target data streams, this argument determines whether
3756
+ wildcard expressions match hidden data streams. It supports comma-separated
3757
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
3758
+ `hidden`, `none`.
3254
3759
  :param ignore_unavailable: If `false`, the request returns an error if it targets
3255
3760
  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.
3761
+ :param index_filter: Filter indices if the provided query rewrites to `match_none`
3762
+ on every shard.
3763
+ :param preference: The node or shard the operation should be performed on. By
3764
+ default, it is random.
3765
+ :param routing: A custom value that is used to route operations to a specific
3766
+ shard.
3261
3767
  """
3262
3768
  if index in SKIP_IN_PATH:
3263
3769
  raise ValueError("Empty value passed for parameter 'index'")
@@ -3323,23 +3829,27 @@ class Elasticsearch(BaseClient):
3323
3829
  body: t.Optional[t.Dict[str, t.Any]] = None,
3324
3830
  ) -> ObjectApiResponse[t.Any]:
3325
3831
  """
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.
3832
+ .. raw:: html
3833
+
3834
+ <p>Create or update a script or search template.
3835
+ Creates or updates a stored script or search template.</p>
3836
+
3837
+
3838
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/create-stored-script-api.html>`_
3839
+
3840
+ :param id: The identifier for the stored script or search template. It must be
3841
+ unique within the cluster.
3842
+ :param script: The script or search template, its parameters, and its language.
3843
+ :param context: The context in which the script or search template should run.
3844
+ To prevent errors, the API immediately compiles the script or template in
3845
+ this context.
3846
+ :param master_timeout: The period to wait for a connection to the master node.
3847
+ If no response is received before the timeout expires, the request fails
3848
+ and returns an error. It can also be set to `-1` to indicate that the request
3849
+ should never timeout.
3850
+ :param timeout: The period to wait for a response. If no response is received
3851
+ before the timeout expires, the request fails and returns an error. It can
3852
+ also be set to `-1` to indicate that the request should never timeout.
3343
3853
  """
3344
3854
  if id in SKIP_IN_PATH:
3345
3855
  raise ValueError("Empty value passed for parameter 'id'")
@@ -3409,14 +3919,17 @@ class Elasticsearch(BaseClient):
3409
3919
  body: t.Optional[t.Dict[str, t.Any]] = None,
3410
3920
  ) -> ObjectApiResponse[t.Any]:
3411
3921
  """
3412
- Evaluate ranked search results. Evaluate the quality of ranked search results
3413
- over a set of typical search queries.
3922
+ .. raw:: html
3923
+
3924
+ <p>Evaluate ranked search results.</p>
3925
+ <p>Evaluate the quality of ranked search results over a set of typical search queries.</p>
3926
+
3414
3927
 
3415
3928
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-rank-eval.html>`_
3416
3929
 
3417
3930
  :param requests: A set of typical search requests, together with their provided
3418
3931
  ratings.
3419
- :param index: Comma-separated list of data streams, indices, and index aliases
3932
+ :param index: A comma-separated list of data streams, indices, and index aliases
3420
3933
  used to limit the request. Wildcard (`*`) expressions are supported. To target
3421
3934
  all data streams and indices in a cluster, omit this parameter or use `_all`
3422
3935
  or `*`.
@@ -3504,33 +4017,187 @@ class Elasticsearch(BaseClient):
3504
4017
  body: t.Optional[t.Dict[str, t.Any]] = None,
3505
4018
  ) -> ObjectApiResponse[t.Any]:
3506
4019
  """
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.
4020
+ .. raw:: html
4021
+
4022
+ <p>Reindex documents.</p>
4023
+ <p>Copy documents from a source to a destination.
4024
+ You can copy all documents to the destination index or reindex a subset of the documents.
4025
+ The source can be any existing index, alias, or data stream.
4026
+ The destination must differ from the source.
4027
+ For example, you cannot reindex a data stream into itself.</p>
4028
+ <p>IMPORTANT: Reindex requires <code>_source</code> to be enabled for all documents in the source.
4029
+ The destination should be configured as wanted before calling the reindex API.
4030
+ Reindex does not copy the settings from the source or its associated template.
4031
+ Mappings, shard counts, and replicas, for example, must be configured ahead of time.</p>
4032
+ <p>If the Elasticsearch security features are enabled, you must have the following security privileges:</p>
4033
+ <ul>
4034
+ <li>The <code>read</code> index privilege for the source data stream, index, or alias.</li>
4035
+ <li>The <code>write</code> index privilege for the destination data stream, index, or index alias.</li>
4036
+ <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>
4037
+ <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>
4038
+ </ul>
4039
+ <p>If reindexing from a remote cluster, you must explicitly allow the remote host in the <code>reindex.remote.whitelist</code> setting.
4040
+ Automatic data stream creation requires a matching index template with data stream enabled.</p>
4041
+ <p>The <code>dest</code> element can be configured like the index API to control optimistic concurrency control.
4042
+ 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>
4043
+ <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>
4044
+ <p>Setting <code>op_type</code> to <code>create</code> causes the reindex API to create only missing documents in the destination.
4045
+ All existing documents will cause a version conflict.</p>
4046
+ <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>.
4047
+ A reindex can only add new documents to a destination data stream.
4048
+ It cannot update existing documents in a destination data stream.</p>
4049
+ <p>By default, version conflicts abort the reindex process.
4050
+ To continue reindexing if there are conflicts, set the <code>conflicts</code> request body property to <code>proceed</code>.
4051
+ In this case, the response includes a count of the version conflicts that were encountered.
4052
+ Note that the handling of other error types is unaffected by the <code>conflicts</code> property.
4053
+ 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>
4054
+ <p>NOTE: The reindex API makes no effort to handle ID collisions.
4055
+ 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.
4056
+ Instead, make sure that IDs are unique by using a script.</p>
4057
+ <p><strong>Running reindex asynchronously</strong></p>
4058
+ <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.
4059
+ Elasticsearch creates a record of this task as a document at <code>_tasks/&lt;task_id&gt;</code>.</p>
4060
+ <p><strong>Reindex from multiple sources</strong></p>
4061
+ <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.
4062
+ That way you can resume the process if there are any errors by removing the partially completed source and starting over.
4063
+ It also makes parallelizing the process fairly simple: split the list of sources to reindex and run each list in parallel.</p>
4064
+ <p>For example, you can use a bash script like this:</p>
4065
+ <pre><code>for index in i1 i2 i3 i4 i5; do
4066
+ curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{
4067
+ &quot;source&quot;: {
4068
+ &quot;index&quot;: &quot;'$index'&quot;
4069
+ },
4070
+ &quot;dest&quot;: {
4071
+ &quot;index&quot;: &quot;'$index'-reindexed&quot;
4072
+ }
4073
+ }'
4074
+ done
4075
+ </code></pre>
4076
+ <p>** Throttling**</p>
4077
+ <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.
4078
+ Requests are throttled by padding each batch with a wait time.
4079
+ To turn off throttling, set <code>requests_per_second</code> to <code>-1</code>.</p>
4080
+ <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.
4081
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
4082
+ By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
4083
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
4084
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
4085
+ </code></pre>
4086
+ <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.
4087
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
4088
+ <p><strong>Slicing</strong></p>
4089
+ <p>Reindex supports sliced scroll to parallelize the reindexing process.
4090
+ This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
4091
+ <p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
4092
+ <p>You can slice a reindex request manually by providing a slice ID and total number of slices to each request.
4093
+ You can also let reindex automatically parallelize by using sliced scroll to slice on <code>_id</code>.
4094
+ The <code>slices</code> parameter specifies the number of slices to use.</p>
4095
+ <p>Adding <code>slices</code> to the reindex request just automates the manual process, creating sub-requests which means it has some quirks:</p>
4096
+ <ul>
4097
+ <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>
4098
+ <li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
4099
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
4100
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
4101
+ <li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
4102
+ <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>
4103
+ <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>
4104
+ <li>Each sub-request gets a slightly different snapshot of the source, though these are all taken at approximately the same time.</li>
4105
+ </ul>
4106
+ <p>If slicing automatically, setting <code>slices</code> to <code>auto</code> will choose a reasonable number for most indices.
4107
+ If slicing manually or otherwise tuning automatic slicing, use the following guidelines.</p>
4108
+ <p>Query performance is most efficient when the number of slices is equal to the number of shards in the index.
4109
+ If that number is large (for example, <code>500</code>), choose a lower number as too many slices will hurt performance.
4110
+ Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</p>
4111
+ <p>Indexing performance scales linearly across available resources with the number of slices.</p>
4112
+ <p>Whether query or indexing performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
4113
+ <p><strong>Modify documents during reindexing</strong></p>
4114
+ <p>Like <code>_update_by_query</code>, reindex operations support a script that modifies the document.
4115
+ Unlike <code>_update_by_query</code>, the script is allowed to modify the document's metadata.</p>
4116
+ <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.
4117
+ 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.
4118
+ Set <code>ctx.op</code> to <code>delete</code> if your script decides that the document must be deleted from the destination.
4119
+ The deletion will be reported in the <code>deleted</code> counter in the response body.
4120
+ Setting <code>ctx.op</code> to anything else will return an error, as will setting any other field in <code>ctx</code>.</p>
4121
+ <p>Think of the possibilities! Just be careful; you are able to change:</p>
4122
+ <ul>
4123
+ <li><code>_id</code></li>
4124
+ <li><code>_index</code></li>
4125
+ <li><code>_version</code></li>
4126
+ <li><code>_routing</code></li>
4127
+ </ul>
4128
+ <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.
4129
+ 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>
4130
+ <p><strong>Reindex from remote</strong></p>
4131
+ <p>Reindex supports reindexing from a remote Elasticsearch cluster.
4132
+ The <code>host</code> parameter must contain a scheme, host, port, and optional path.
4133
+ 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.
4134
+ Be sure to use HTTPS when using basic authentication or the password will be sent in plain text.
4135
+ There are a range of settings available to configure the behavior of the HTTPS connection.</p>
4136
+ <p>When using Elastic Cloud, it is also possible to authenticate against the remote cluster through the use of a valid API key.
4137
+ Remote hosts must be explicitly allowed with the <code>reindex.remote.whitelist</code> setting.
4138
+ It can be set to a comma delimited list of allowed remote host and port combinations.
4139
+ Scheme is ignored; only the host and port are used.
4140
+ For example:</p>
4141
+ <pre><code>reindex.remote.whitelist: [otherhost:9200, another:9200, 127.0.10.*:9200, localhost:*&quot;]
4142
+ </code></pre>
4143
+ <p>The list of allowed hosts must be configured on any nodes that will coordinate the reindex.
4144
+ This feature should work with remote clusters of any version of Elasticsearch.
4145
+ 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>
4146
+ <p>WARNING: Elasticsearch does not support forward compatibility across major versions.
4147
+ For example, you cannot reindex from a 7.x cluster into a 6.x cluster.</p>
4148
+ <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>
4149
+ <p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
4150
+ <p>Reindexing from a remote server uses an on-heap buffer that defaults to a maximum size of 100mb.
4151
+ If the remote index includes very large documents you'll need to use a smaller batch size.
4152
+ 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.
4153
+ Both default to 30 seconds.</p>
4154
+ <p><strong>Configuring SSL parameters</strong></p>
4155
+ <p>Reindex from remote supports configurable SSL settings.
4156
+ 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.
4157
+ It is not possible to configure SSL in the body of the reindex request.</p>
4158
+
3510
4159
 
3511
4160
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3512
4161
 
3513
4162
  :param dest: The destination you are copying to.
3514
4163
  :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.
4164
+ :param conflicts: Indicates whether to continue reindexing even when there are
4165
+ conflicts.
4166
+ :param max_docs: The maximum number of documents to reindex. By default, all
4167
+ documents are reindexed. If it is a value less then or equal to `scroll_size`,
4168
+ a scroll will not be used to retrieve the results for the operation. If `conflicts`
4169
+ is set to `proceed`, the reindex operation could attempt to reindex more
4170
+ documents from the source than `max_docs` until it has successfully indexed
4171
+ `max_docs` documents into the target or it has gone through every document
4172
+ in the source query.
3517
4173
  :param refresh: If `true`, the request refreshes affected shards to make this
3518
4174
  operation visible to search.
3519
4175
  :param requests_per_second: The throttle for this request in sub-requests per
3520
- second. Defaults to no throttle.
4176
+ second. By default, there is no throttle.
3521
4177
  :param require_alias: If `true`, the destination must be an index alias.
3522
4178
  :param script: The script to run to update the document source or metadata when
3523
4179
  reindexing.
3524
- :param scroll: Specifies how long a consistent view of the index should be maintained
3525
- for scrolled search.
4180
+ :param scroll: The period of time that a consistent view of the index should
4181
+ be maintained for scrolled search.
3526
4182
  :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.
4183
+ :param slices: The number of slices this task should be divided into. It defaults
4184
+ to one slice, which means the task isn't sliced into subtasks. Reindex supports
4185
+ sliced scroll to parallelize the reindexing process. This parallelization
4186
+ can improve efficiency and provide a convenient way to break the request
4187
+ down into smaller parts. NOTE: Reindexing from remote clusters does not support
4188
+ manual or automatic slicing. If set to `auto`, Elasticsearch chooses the
4189
+ number of slices to use. This setting will use one slice per shard, up to
4190
+ a certain limit. If there are multiple sources, it will choose the number
4191
+ of slices based on the index or backing index with the smallest number of
4192
+ shards.
4193
+ :param timeout: The period each indexing waits for automatic index creation,
4194
+ dynamic mapping updates, and waiting for active shards. By default, Elasticsearch
4195
+ waits for at least one minute before failing. The actual wait time could
4196
+ be longer, particularly when multiple waits occur.
3531
4197
  :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`).
4198
+ before proceeding with the operation. Set it to `all` or any positive integer
4199
+ up to the total number of shards in the index (`number_of_replicas+1`). The
4200
+ default value is one, which means it waits for each primary shard to be active.
3534
4201
  :param wait_for_completion: If `true`, the request blocks until the operation
3535
4202
  is complete.
3536
4203
  """
@@ -3602,14 +4269,24 @@ class Elasticsearch(BaseClient):
3602
4269
  requests_per_second: t.Optional[float] = None,
3603
4270
  ) -> ObjectApiResponse[t.Any]:
3604
4271
  """
3605
- Throttle a reindex operation. Change the number of requests per second for a
3606
- particular reindex operation.
4272
+ .. raw:: html
4273
+
4274
+ <p>Throttle a reindex operation.</p>
4275
+ <p>Change the number of requests per second for a particular reindex operation.
4276
+ For example:</p>
4277
+ <pre><code>POST _reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
4278
+ </code></pre>
4279
+ <p>Rethrottling that speeds up the query takes effect immediately.
4280
+ Rethrottling that slows down the query will take effect after completing the current batch.
4281
+ This behavior prevents scroll timeouts.</p>
4282
+
3607
4283
 
3608
4284
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3609
4285
 
3610
- :param task_id: Identifier for the task.
4286
+ :param task_id: The task identifier, which can be found by using the tasks API.
3611
4287
  :param requests_per_second: The throttle for this request in sub-requests per
3612
- second.
4288
+ second. It can be either `-1` to turn off throttling or any decimal number
4289
+ like `1.7` or `12` to throttle to that level.
3613
4290
  """
3614
4291
  if task_id in SKIP_IN_PATH:
3615
4292
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -3654,17 +4331,21 @@ class Elasticsearch(BaseClient):
3654
4331
  body: t.Optional[t.Dict[str, t.Any]] = None,
3655
4332
  ) -> ObjectApiResponse[t.Any]:
3656
4333
  """
3657
- Render a search template. Render a search template as a search request body.
4334
+ .. raw:: html
4335
+
4336
+ <p>Render a search template.</p>
4337
+ <p>Render a search template as a search request body.</p>
4338
+
3658
4339
 
3659
4340
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/render-search-template-api.html>`_
3660
4341
 
3661
- :param id: ID of the search template to render. If no `source` is specified,
4342
+ :param id: The ID of the search template to render. If no `source` is specified,
3662
4343
  this or the `id` request body parameter is required.
3663
4344
  :param file:
3664
4345
  :param params: Key-value pairs used to replace Mustache variables in the template.
3665
4346
  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.
4347
+ :param source: An inline search template. It supports the same parameters as
4348
+ the search API's request body. These parameters also support Mustache variables.
3668
4349
  If no `id` or `<templated-id>` is specified, this parameter is required.
3669
4350
  """
3670
4351
  __path_parts: t.Dict[str, str]
@@ -3723,7 +4404,11 @@ class Elasticsearch(BaseClient):
3723
4404
  body: t.Optional[t.Dict[str, t.Any]] = None,
3724
4405
  ) -> ObjectApiResponse[t.Any]:
3725
4406
  """
3726
- Run a script. Runs a script and returns a result.
4407
+ .. raw:: html
4408
+
4409
+ <p>Run a script.
4410
+ Runs a script and returns a result.</p>
4411
+
3727
4412
 
3728
4413
  `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-execute-api.html>`_
3729
4414
 
@@ -3781,30 +4466,27 @@ class Elasticsearch(BaseClient):
3781
4466
  body: t.Optional[t.Dict[str, t.Any]] = None,
3782
4467
  ) -> ObjectApiResponse[t.Any]:
3783
4468
  """
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.
4469
+ .. raw:: html
4470
+
4471
+ <p>Run a scrolling search.</p>
4472
+ <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>
4473
+ <p>The scroll API gets large sets of results from a single scrolling search request.
4474
+ To get the necessary scroll ID, submit a search API request that includes an argument for the <code>scroll</code> query parameter.
4475
+ The <code>scroll</code> parameter indicates how long Elasticsearch should retain the search context for the request.
4476
+ The search response returns a scroll ID in the <code>_scroll_id</code> response body parameter.
4477
+ You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request.
4478
+ 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>
4479
+ <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>
4480
+ <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>
4481
+
4482
+
4483
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/scroll-api.html>`_
4484
+
4485
+ :param scroll_id: The scroll ID of the search.
3804
4486
  :param rest_total_hits_as_int: If true, the API response’s hit.total property
3805
4487
  is returned as an integer. If false, the API response’s hit.total property
3806
4488
  is returned as an object.
3807
- :param scroll: Period to retain the search context for scrolling.
4489
+ :param scroll: The period to retain the search context for scrolling.
3808
4490
  """
3809
4491
  if scroll_id is None and body is None:
3810
4492
  raise ValueError("Empty value passed for parameter 'scroll_id'")
@@ -3986,15 +4668,29 @@ class Elasticsearch(BaseClient):
3986
4668
  body: t.Optional[t.Dict[str, t.Any]] = None,
3987
4669
  ) -> ObjectApiResponse[t.Any]:
3988
4670
  """
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.
4671
+ .. raw:: html
4672
+
4673
+ <p>Run a search.</p>
4674
+ <p>Get search hits that match the query defined in the request.
4675
+ You can provide search queries using the <code>q</code> query string parameter or the request body.
4676
+ If both are specified, only the query parameter is used.</p>
4677
+ <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.
4678
+ 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>
4679
+ <p><strong>Search slicing</strong></p>
4680
+ <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.
4681
+ By default the splitting is done first on the shards, then locally on each shard.
4682
+ The local splitting partitions the shard into contiguous ranges based on Lucene document IDs.</p>
4683
+ <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>
4684
+ <p>IMPORTANT: The same point-in-time ID should be used for all slices.
4685
+ If different PIT IDs are used, slices can overlap and miss documents.
4686
+ This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index.</p>
4687
+
3992
4688
 
3993
4689
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
3994
4690
 
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`.
4691
+ :param index: A comma-separated list of data streams, indices, and aliases to
4692
+ search. It supports wildcards (`*`). To search all data streams and indices,
4693
+ omit this parameter or use `*` or `_all`.
3998
4694
  :param aggregations: Defines the aggregations that are run as part of the search
3999
4695
  request.
4000
4696
  :param aggs: Defines the aggregations that are run as part of the search request.
@@ -4003,45 +4699,46 @@ class Elasticsearch(BaseClient):
4003
4699
  This behavior applies even if the request targets other open indices. For
4004
4700
  example, a request targeting `foo*,bar*` returns an error if an index starts
4005
4701
  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.
4702
+ :param allow_partial_search_results: If `true` and there are shard request timeouts
4703
+ or shard failures, the request returns partial results. If `false`, it returns
4704
+ an error with no partial results. To override the default behavior, you can
4705
+ set the `search.default_allow_partial_results` cluster setting to `false`.
4706
+ :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
4707
+ This parameter can be used only when the `q` query string parameter is specified.
4708
+ :param analyzer: The analyzer to use for the query string. This parameter can
4709
+ be used only when the `q` query string parameter is specified.
4013
4710
  :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
4711
+ at once on the coordinating node. If the potential number of shards in the
4712
+ request can be large, this value should be used as a protection mechanism
4713
+ to reduce the memory overhead per search request.
4714
+ :param ccs_minimize_roundtrips: If `true`, network round-trips between the coordinating
4715
+ node and the remote clusters are minimized when running cross-cluster search
4019
4716
  (CCS) requests.
4020
4717
  :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
4718
+ :param default_operator: The default operator for the query string query: `AND`
4719
+ or `OR`. This parameter can be used only when the `q` query string parameter
4026
4720
  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.
4721
+ :param df: The field to use as a default when no field prefix is given in the
4722
+ query string. This parameter can be used only when the `q` query string parameter
4723
+ is specified.
4724
+ :param docvalue_fields: An array of wildcard (`*`) field patterns. The request
4725
+ returns doc values for field names matching these patterns in the `hits.fields`
4726
+ property of the response.
4727
+ :param expand_wildcards: The type of index that wildcard patterns can match.
4728
+ If the request can target data streams, this argument determines whether
4729
+ wildcard expressions match hidden data streams. It supports comma-separated
4730
+ values such as `open,hidden`.
4731
+ :param explain: If `true`, the request returns detailed information about score
4732
+ computation as part of a hit.
4036
4733
  :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.
4734
+ :param fields: An array of wildcard (`*`) field patterns. The request returns
4735
+ values for field names matching these patterns in the `hits.fields` property
4736
+ of the response.
4040
4737
  :param force_synthetic_source: Should this request force synthetic _source? Use
4041
4738
  this to test if the mapping supports synthetic _source and to get a sense
4042
4739
  of the worst case performance. Fetches with this enabled will be slower the
4043
4740
  enabling synthetic source natively in the index.
4044
- :param from_: Starting document offset. Needs to be non-negative. By default,
4741
+ :param from_: The starting document offset, which must be non-negative. By default,
4045
4742
  you cannot page through more than 10,000 hits using the `from` and `size`
4046
4743
  parameters. To page through more hits, use the `search_after` parameter.
4047
4744
  :param highlight: Specifies the highlighter to use for retrieving highlighted
@@ -4050,95 +4747,101 @@ class Elasticsearch(BaseClient):
4050
4747
  be ignored when frozen.
4051
4748
  :param ignore_unavailable: If `false`, the request returns an error if it targets
4052
4749
  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.
4750
+ :param include_named_queries_score: If `true`, the response includes the score
4751
+ contribution from any named queries. This functionality reruns each named
4752
+ query on every hit in a search response. Typically, this adds a small overhead
4753
+ to a request. However, using computationally expensive named queries on a
4754
+ large number of hits may add significant overhead.
4755
+ :param indices_boost: Boost the `_score` of documents from specified indices.
4756
+ The boost value is the factor by which scores are multiplied. A boost value
4757
+ greater than `1.0` increases the score. A boost value between `0` and `1.0`
4758
+ decreases the score.
4759
+ :param knn: The approximate kNN search to run.
4062
4760
  :param lenient: If `true`, format-based query failures (such as providing text
4063
4761
  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.
4762
+ be used only when the `q` query string parameter is specified.
4763
+ :param max_concurrent_shard_requests: The number of concurrent shard requests
4764
+ per node that the search runs concurrently. This value should be used to
4765
+ limit the impact of the search on the cluster in order to limit the number
4766
+ of concurrent shard requests.
4069
4767
  :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,
4768
+ the request. Any handling node with a lower version will fail the request.
4769
+ :param min_score: The minimum `_score` for matching documents. Documents with
4770
+ a lower `_score` are not included in the search results.
4771
+ :param pit: Limit the search to a point in time (PIT). If you provide a PIT,
4074
4772
  you cannot specify an `<index>` in the request path.
4075
4773
  :param post_filter: Use the `post_filter` parameter to filter search results.
4076
4774
  The search hits are filtered after the aggregations are calculated. A post
4077
4775
  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
4776
+ :param pre_filter_shard_size: A threshold that enforces a pre-filter roundtrip
4777
+ to prefilter search shards based on query rewriting if the number of shards
4778
+ the search request expands to exceeds the threshold. This filter roundtrip
4779
+ can limit the number of shards significantly if for instance a shard can
4780
+ not match any documents based on its rewrite method (if date filters are
4781
+ mandatory to match but the shard bounds and the query are disjoint). When
4782
+ unspecified, the pre-filter phase is executed if any of these conditions
4783
+ is met: * The request targets more than 128 shards. * The request targets
4784
+ one or more read-only index. * The primary sort of the query targets an indexed
4087
4785
  field.
4088
- :param preference: Nodes and shards used for the search. By default, Elasticsearch
4786
+ :param preference: The nodes and shards used for the search. By default, Elasticsearch
4089
4787
  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
4788
+ accounting for allocation awareness. Valid values are: * `_only_local` to
4789
+ run the search only on shards on the local node; * `_local` to, if possible,
4790
+ run the search on shards on the local node, or if not, select shards using
4791
+ the default method; * `_only_nodes:<node-id>,<node-id>` to run the search
4792
+ on only the specified nodes IDs, where, if suitable shards exist on more
4793
+ than one selected node, use shards on those nodes using the default method,
4794
+ or if none of the specified nodes are available, select shards from any available
4795
+ node using the default method; * `_prefer_nodes:<node-id>,<node-id>` to if
4098
4796
  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
4797
+ using the default method; * `_shards:<shard>,<shard>` to run the search only
4798
+ on the specified shards; * `<custom-string>` (any string that does not start
4101
4799
  with `_`) to route searches with the same `<custom-string>` to the same shards
4102
4800
  in the same order.
4103
4801
  :param profile: Set to `true` to return detailed timing information about the
4104
4802
  execution of individual components in a search request. NOTE: This is a debugging
4105
4803
  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.
4804
+ :param q: A query in the Lucene query string syntax. Query parameter searches
4805
+ do not support the full Elasticsearch Query DSL but are handy for testing.
4806
+ IMPORTANT: This parameter overrides the query parameter in the request body.
4807
+ If both parameters are specified, documents matching the query request body
4808
+ parameter are not returned.
4809
+ :param query: The search definition using the Query DSL.
4810
+ :param rank: The Reciprocal Rank Fusion (RRF) to use.
4111
4811
  :param request_cache: If `true`, the caching of search results is enabled for
4112
- requests where `size` is `0`. Defaults to index level settings.
4812
+ requests where `size` is `0`. It defaults to index level settings.
4113
4813
  :param rescore: Can be used to improve precision by reordering just the top (for
4114
4814
  example 100 - 500) documents returned by the `query` and `post_filter` phases.
4115
4815
  :param rest_total_hits_as_int: Indicates whether `hits.total` should be rendered
4116
4816
  as an integer or an object in the rest search response.
4117
4817
  :param retriever: A retriever is a specification to describe top documents returned
4118
4818
  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.
4819
+ also return top documents such as `query` and `knn`.
4820
+ :param routing: A custom value that is used to route operations to a specific
4821
+ shard.
4822
+ :param runtime_mappings: One or more runtime fields in the search request. These
4823
+ fields take precedence over mapped fields with the same name.
4123
4824
  :param script_fields: Retrieve a script evaluation (based on different fields)
4124
4825
  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.
4826
+ :param scroll: The period to retain the search context for scrolling. By default,
4827
+ this value cannot exceed `1d` (24 hours). You can change this limit by using
4828
+ the `search.max_keep_alive` cluster-level setting.
4128
4829
  :param search_after: Used to retrieve the next page of hits using a set of sort
4129
4830
  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.
4831
+ :param search_type: Indicates how distributed term frequencies are calculated
4832
+ for relevance scoring.
4833
+ :param seq_no_primary_term: If `true`, the request returns sequence number and
4834
+ primary term of the last modification of each hit.
4835
+ :param size: The number of hits to return, which must not be negative. By default,
4836
+ you cannot page through more than 10,000 hits using the `from` and `size`
4837
+ parameters. To page through more hits, use the `search_after` property.
4838
+ :param slice: Split a scrolled search into multiple slices that can be consumed
4839
+ independently.
4139
4840
  :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.
4841
+ :param source: The source fields that are returned for matching documents. These
4842
+ fields are returned in the `hits._source` property of the search response.
4843
+ If the `stored_fields` property is specified, the `_source` property defaults
4844
+ to `false`. Otherwise, it defaults to `true`.
4142
4845
  :param source_excludes: A comma-separated list of source fields to exclude from
4143
4846
  the response. You can also use this parameter to exclude fields from the
4144
4847
  subset specified in `_source_includes` query parameter. If the `_source`
@@ -4148,45 +4851,46 @@ class Elasticsearch(BaseClient):
4148
4851
  returned. You can exclude fields from this subset using the `_source_excludes`
4149
4852
  query parameter. If the `_source` parameter is `false`, this parameter is
4150
4853
  ignored.
4151
- :param stats: Stats groups to associate with the search. Each group maintains
4854
+ :param stats: The stats groups to associate with the search. Each group maintains
4152
4855
  a statistics aggregation for its associated searches. You can retrieve these
4153
4856
  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.
4857
+ :param stored_fields: A comma-separated list of stored fields to return as part
4858
+ of a hit. If no fields are specified, no stored fields are included in the
4859
+ response. If this field is specified, the `_source` property defaults to
4860
+ `false`. You can pass `_source: true` to return both source fields and stored
4861
+ fields in the search response.
4159
4862
  :param suggest: Defines a suggester that provides similar looking terms based
4160
4863
  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
4864
+ :param suggest_field: The field to use for suggestions.
4865
+ :param suggest_mode: The suggest mode. This parameter can be used only when the
4866
+ `suggest_field` and `suggest_text` query string parameters are specified.
4867
+ :param suggest_size: The number of suggestions to return. This parameter can
4868
+ be used only when the `suggest_field` and `suggest_text` query string parameters
4166
4869
  are specified.
4167
4870
  :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`
4871
+ This parameter can be used only when the `suggest_field` and `suggest_text`
4169
4872
  query string parameters are specified.
4170
- :param terminate_after: Maximum number of documents to collect for each shard.
4873
+ :param terminate_after: The maximum number of documents to collect for each shard.
4171
4874
  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.
4875
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
4876
+ Elasticsearch applies this property to each shard handling the request. When
4877
+ possible, let Elasticsearch perform early termination automatically. Avoid
4878
+ specifying this property for requests that target data streams with backing
4879
+ indices across multiple data tiers. If set to `0` (default), the query does
4880
+ not terminate early.
4881
+ :param timeout: The period of time to wait for a response from each shard. If
4882
+ no response is received before the timeout expires, the request fails and
4883
+ returns an error. Defaults to no timeout.
4884
+ :param track_scores: If `true`, calculate and return document scores, even if
4885
+ the scores are not used for sorting.
4183
4886
  :param track_total_hits: Number of hits matching the query to count accurately.
4184
4887
  If `true`, the exact number of hits is returned at the cost of some performance.
4185
4888
  If `false`, the response does not include the total number of hits matching
4186
4889
  the query.
4187
4890
  :param typed_keys: If `true`, aggregation and suggester names are be prefixed
4188
4891
  by their respective types in the response.
4189
- :param version: If true, returns document version as part of a hit.
4892
+ :param version: If `true`, the request returns the document version as part of
4893
+ a hit.
4190
4894
  """
4191
4895
  __path_parts: t.Dict[str, str]
4192
4896
  if index not in SKIP_IN_PATH:
@@ -4418,7 +5122,319 @@ class Elasticsearch(BaseClient):
4418
5122
  body: t.Optional[t.Dict[str, t.Any]] = None,
4419
5123
  ) -> BinaryApiResponse:
4420
5124
  """
4421
- Search a vector tile. Search a vector tile for geospatial values.
5125
+ .. raw:: html
5126
+
5127
+ <p>Search a vector tile.</p>
5128
+ <p>Search a vector tile for geospatial values.
5129
+ Before using this API, you should be familiar with the Mapbox vector tile specification.
5130
+ The API returns results as a binary mapbox vector tile.</p>
5131
+ <p>Internally, Elasticsearch translates a vector tile search API request into a search containing:</p>
5132
+ <ul>
5133
+ <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>
5134
+ <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>
5135
+ <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>
5136
+ <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>
5137
+ </ul>
5138
+ <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>
5139
+ <pre><code>GET my-index/_search
5140
+ {
5141
+ &quot;size&quot;: 10000,
5142
+ &quot;query&quot;: {
5143
+ &quot;geo_bounding_box&quot;: {
5144
+ &quot;my-geo-field&quot;: {
5145
+ &quot;top_left&quot;: {
5146
+ &quot;lat&quot;: -40.979898069620134,
5147
+ &quot;lon&quot;: -45
5148
+ },
5149
+ &quot;bottom_right&quot;: {
5150
+ &quot;lat&quot;: -66.51326044311186,
5151
+ &quot;lon&quot;: 0
5152
+ }
5153
+ }
5154
+ }
5155
+ },
5156
+ &quot;aggregations&quot;: {
5157
+ &quot;grid&quot;: {
5158
+ &quot;geotile_grid&quot;: {
5159
+ &quot;field&quot;: &quot;my-geo-field&quot;,
5160
+ &quot;precision&quot;: 11,
5161
+ &quot;size&quot;: 65536,
5162
+ &quot;bounds&quot;: {
5163
+ &quot;top_left&quot;: {
5164
+ &quot;lat&quot;: -40.979898069620134,
5165
+ &quot;lon&quot;: -45
5166
+ },
5167
+ &quot;bottom_right&quot;: {
5168
+ &quot;lat&quot;: -66.51326044311186,
5169
+ &quot;lon&quot;: 0
5170
+ }
5171
+ }
5172
+ }
5173
+ },
5174
+ &quot;bounds&quot;: {
5175
+ &quot;geo_bounds&quot;: {
5176
+ &quot;field&quot;: &quot;my-geo-field&quot;,
5177
+ &quot;wrap_longitude&quot;: false
5178
+ }
5179
+ }
5180
+ }
5181
+ }
5182
+ </code></pre>
5183
+ <p>The API returns results as a binary Mapbox vector tile.
5184
+ Mapbox vector tiles are encoded as Google Protobufs (PBF). By default, the tile contains three layers:</p>
5185
+ <ul>
5186
+ <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>
5187
+ <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>
5188
+ <li>A meta layer containing:
5189
+ <ul>
5190
+ <li>A feature containing a bounding box. By default, this is the bounding box of the tile.</li>
5191
+ <li>Value ranges for any sub-aggregations on the <code>geotile_grid</code> or <code>geohex_grid</code>.</li>
5192
+ <li>Metadata for the search.</li>
5193
+ </ul>
5194
+ </li>
5195
+ </ul>
5196
+ <p>The API only returns features that can display at its zoom level.
5197
+ For example, if a polygon feature has no area at its zoom level, the API omits it.
5198
+ The API returns errors as UTF-8 encoded JSON.</p>
5199
+ <p>IMPORTANT: You can specify several options for this API as either a query parameter or request body parameter.
5200
+ If you specify both parameters, the query parameter takes precedence.</p>
5201
+ <p><strong>Grid precision for geotile</strong></p>
5202
+ <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.
5203
+ <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>.
5204
+ 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.
5205
+ The maximum final precision is 29.
5206
+ 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>.
5207
+ For example, a value of 8 divides the tile into a grid of 256 x 256 cells.
5208
+ The <code>aggs</code> layer only contains features for cells with matching data.</p>
5209
+ <p><strong>Grid precision for geohex</strong></p>
5210
+ <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>
5211
+ <p>This precision determines the H3 resolution of the hexagonal cells produced by the <code>geohex</code> aggregation.
5212
+ The following table maps the H3 resolution for each precision.
5213
+ For example, if <code>&lt;zoom&gt;</code> is 3 and <code>grid_precision</code> is 3, the precision is 6.
5214
+ At a precision of 6, hexagonal cells have an H3 resolution of 2.
5215
+ If <code>&lt;zoom&gt;</code> is 3 and <code>grid_precision</code> is 4, the precision is 7.
5216
+ At a precision of 7, hexagonal cells have an H3 resolution of 3.</p>
5217
+ <table>
5218
+ <thead>
5219
+ <tr>
5220
+ <th>Precision</th>
5221
+ <th>Unique tile bins</th>
5222
+ <th>H3 resolution</th>
5223
+ <th>Unique hex bins</th>
5224
+ <th>Ratio</th>
5225
+ </tr>
5226
+ </thead>
5227
+ <tbody>
5228
+ <tr>
5229
+ <td>1</td>
5230
+ <td>4</td>
5231
+ <td>0</td>
5232
+ <td>122</td>
5233
+ <td>30.5</td>
5234
+ </tr>
5235
+ <tr>
5236
+ <td>2</td>
5237
+ <td>16</td>
5238
+ <td>0</td>
5239
+ <td>122</td>
5240
+ <td>7.625</td>
5241
+ </tr>
5242
+ <tr>
5243
+ <td>3</td>
5244
+ <td>64</td>
5245
+ <td>1</td>
5246
+ <td>842</td>
5247
+ <td>13.15625</td>
5248
+ </tr>
5249
+ <tr>
5250
+ <td>4</td>
5251
+ <td>256</td>
5252
+ <td>1</td>
5253
+ <td>842</td>
5254
+ <td>3.2890625</td>
5255
+ </tr>
5256
+ <tr>
5257
+ <td>5</td>
5258
+ <td>1024</td>
5259
+ <td>2</td>
5260
+ <td>5882</td>
5261
+ <td>5.744140625</td>
5262
+ </tr>
5263
+ <tr>
5264
+ <td>6</td>
5265
+ <td>4096</td>
5266
+ <td>2</td>
5267
+ <td>5882</td>
5268
+ <td>1.436035156</td>
5269
+ </tr>
5270
+ <tr>
5271
+ <td>7</td>
5272
+ <td>16384</td>
5273
+ <td>3</td>
5274
+ <td>41162</td>
5275
+ <td>2.512329102</td>
5276
+ </tr>
5277
+ <tr>
5278
+ <td>8</td>
5279
+ <td>65536</td>
5280
+ <td>3</td>
5281
+ <td>41162</td>
5282
+ <td>0.6280822754</td>
5283
+ </tr>
5284
+ <tr>
5285
+ <td>9</td>
5286
+ <td>262144</td>
5287
+ <td>4</td>
5288
+ <td>288122</td>
5289
+ <td>1.099098206</td>
5290
+ </tr>
5291
+ <tr>
5292
+ <td>10</td>
5293
+ <td>1048576</td>
5294
+ <td>4</td>
5295
+ <td>288122</td>
5296
+ <td>0.2747745514</td>
5297
+ </tr>
5298
+ <tr>
5299
+ <td>11</td>
5300
+ <td>4194304</td>
5301
+ <td>5</td>
5302
+ <td>2016842</td>
5303
+ <td>0.4808526039</td>
5304
+ </tr>
5305
+ <tr>
5306
+ <td>12</td>
5307
+ <td>16777216</td>
5308
+ <td>6</td>
5309
+ <td>14117882</td>
5310
+ <td>0.8414913416</td>
5311
+ </tr>
5312
+ <tr>
5313
+ <td>13</td>
5314
+ <td>67108864</td>
5315
+ <td>6</td>
5316
+ <td>14117882</td>
5317
+ <td>0.2103728354</td>
5318
+ </tr>
5319
+ <tr>
5320
+ <td>14</td>
5321
+ <td>268435456</td>
5322
+ <td>7</td>
5323
+ <td>98825162</td>
5324
+ <td>0.3681524172</td>
5325
+ </tr>
5326
+ <tr>
5327
+ <td>15</td>
5328
+ <td>1073741824</td>
5329
+ <td>8</td>
5330
+ <td>691776122</td>
5331
+ <td>0.644266719</td>
5332
+ </tr>
5333
+ <tr>
5334
+ <td>16</td>
5335
+ <td>4294967296</td>
5336
+ <td>8</td>
5337
+ <td>691776122</td>
5338
+ <td>0.1610666797</td>
5339
+ </tr>
5340
+ <tr>
5341
+ <td>17</td>
5342
+ <td>17179869184</td>
5343
+ <td>9</td>
5344
+ <td>4842432842</td>
5345
+ <td>0.2818666889</td>
5346
+ </tr>
5347
+ <tr>
5348
+ <td>18</td>
5349
+ <td>68719476736</td>
5350
+ <td>10</td>
5351
+ <td>33897029882</td>
5352
+ <td>0.4932667053</td>
5353
+ </tr>
5354
+ <tr>
5355
+ <td>19</td>
5356
+ <td>274877906944</td>
5357
+ <td>11</td>
5358
+ <td>237279209162</td>
5359
+ <td>0.8632167343</td>
5360
+ </tr>
5361
+ <tr>
5362
+ <td>20</td>
5363
+ <td>1099511627776</td>
5364
+ <td>11</td>
5365
+ <td>237279209162</td>
5366
+ <td>0.2158041836</td>
5367
+ </tr>
5368
+ <tr>
5369
+ <td>21</td>
5370
+ <td>4398046511104</td>
5371
+ <td>12</td>
5372
+ <td>1660954464122</td>
5373
+ <td>0.3776573213</td>
5374
+ </tr>
5375
+ <tr>
5376
+ <td>22</td>
5377
+ <td>17592186044416</td>
5378
+ <td>13</td>
5379
+ <td>11626681248842</td>
5380
+ <td>0.6609003122</td>
5381
+ </tr>
5382
+ <tr>
5383
+ <td>23</td>
5384
+ <td>70368744177664</td>
5385
+ <td>13</td>
5386
+ <td>11626681248842</td>
5387
+ <td>0.165225078</td>
5388
+ </tr>
5389
+ <tr>
5390
+ <td>24</td>
5391
+ <td>281474976710656</td>
5392
+ <td>14</td>
5393
+ <td>81386768741882</td>
5394
+ <td>0.2891438866</td>
5395
+ </tr>
5396
+ <tr>
5397
+ <td>25</td>
5398
+ <td>1125899906842620</td>
5399
+ <td>15</td>
5400
+ <td>569707381193162</td>
5401
+ <td>0.5060018015</td>
5402
+ </tr>
5403
+ <tr>
5404
+ <td>26</td>
5405
+ <td>4503599627370500</td>
5406
+ <td>15</td>
5407
+ <td>569707381193162</td>
5408
+ <td>0.1265004504</td>
5409
+ </tr>
5410
+ <tr>
5411
+ <td>27</td>
5412
+ <td>18014398509482000</td>
5413
+ <td>15</td>
5414
+ <td>569707381193162</td>
5415
+ <td>0.03162511259</td>
5416
+ </tr>
5417
+ <tr>
5418
+ <td>28</td>
5419
+ <td>72057594037927900</td>
5420
+ <td>15</td>
5421
+ <td>569707381193162</td>
5422
+ <td>0.007906278149</td>
5423
+ </tr>
5424
+ <tr>
5425
+ <td>29</td>
5426
+ <td>288230376151712000</td>
5427
+ <td>15</td>
5428
+ <td>569707381193162</td>
5429
+ <td>0.001976569537</td>
5430
+ </tr>
5431
+ </tbody>
5432
+ </table>
5433
+ <p>Hexagonal cells don't align perfectly on a vector tile.
5434
+ Some cells may intersect more than one vector tile.
5435
+ 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.
5436
+ Elasticsearch uses the H3 resolution that is closest to the corresponding geotile density.</p>
5437
+
4422
5438
 
4423
5439
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-vector-tile-api.html>`_
4424
5440
 
@@ -4427,43 +5443,55 @@ class Elasticsearch(BaseClient):
4427
5443
  :param zoom: Zoom level for the vector tile to search
4428
5444
  :param x: X coordinate for the vector tile to search
4429
5445
  :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
5446
+ :param aggs: Sub-aggregations for the geotile_grid. It supports the following
5447
+ aggregation types: - `avg` - `boxplot` - `cardinality` - `extended stats`
5448
+ - `max` - `median absolute deviation` - `min` - `percentile` - `percentile-rank`
5449
+ - `stats` - `sum` - `value count` The aggregation names can't start with
5450
+ `_mvt_`. The `_mvt_` prefix is reserved for internal aggregations.
5451
+ :param buffer: The size, in pixels, of a clipping buffer outside the tile. This
5452
+ allows renderers to avoid outline artifacts from geometries that extend past
5453
+ the extent of the tile.
5454
+ :param exact_bounds: If `false`, the meta layer's feature is the bounding box
5455
+ of the tile. If `true`, the meta layer's feature is a bounding box resulting
5456
+ from a `geo_bounds` aggregation. The aggregation runs on <field> values that
5457
+ intersect the `<zoom>/<x>/<y>` tile with `wrap_longitude` set to `false`.
5458
+ The resulting bounding box may be larger than the vector tile.
5459
+ :param extent: The size, in pixels, of a side of the tile. Vector tiles are square
4441
5460
  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`.
5461
+ :param fields: The fields to return in the `hits` layer. It supports wildcards
5462
+ (`*`). This parameter does not support fields with array values. Fields with
5463
+ array values may return inconsistent results.
5464
+ :param grid_agg: The aggregation used to create a grid for the `field`.
4446
5465
  :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.
5466
+ For example, if `<zoom>` is `7` and `grid_precision` is `8`, you can zoom
5467
+ in up to level 15. Accepts 0-8. If 0, results don't include the aggs layer.
4449
5468
  :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
5469
+ In the aggs layer, each feature represents a `geotile_grid` cell. If `grid,
5470
+ each feature is a polygon of the cells bounding box. If `point`, each feature
4452
5471
  is a Point that is the centroid of the cell.
4453
- :param query: Query DSL used to filter documents for the search.
5472
+ :param query: The query DSL used to filter documents for the search.
4454
5473
  :param runtime_mappings: Defines one or more runtime fields in the search request.
4455
5474
  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
5475
+ :param size: The maximum number of features to return in the hits layer. Accepts
5476
+ 0-10000. If 0, results don't include the hits layer.
5477
+ :param sort: Sort the features in the hits layer. By default, the API calculates
5478
+ a bounding box for each feature. It sorts features based on this box's diagonal
4460
5479
  length, from longest to shortest.
4461
- :param track_total_hits: Number of hits matching the query to count accurately.
5480
+ :param track_total_hits: The number of hits matching the query to count accurately.
4462
5481
  If `true`, the exact number of hits is returned at the cost of some performance.
4463
5482
  If `false`, the response does not include the total number of hits matching
4464
5483
  the query.
4465
5484
  :param with_labels: If `true`, the hits and aggs layers will contain additional
4466
5485
  point features representing suggested label positions for the original features.
5486
+ * `Point` and `MultiPoint` features will have one of the points selected.
5487
+ * `Polygon` and `MultiPolygon` features will have a single point generated,
5488
+ either the centroid, if it is within the polygon, or another point within
5489
+ the polygon selected from the sorted triangle-tree. * `LineString` features
5490
+ will likewise provide a roughly central point selected from the triangle-tree.
5491
+ * The aggregation results will provide one central point for each aggregation
5492
+ bucket. All attributes from the original features will also be copied to
5493
+ the new label features. In addition, the new features will be distinguishable
5494
+ using the tag `_mvt_label_position`.
4467
5495
  """
4468
5496
  if index in SKIP_IN_PATH:
4469
5497
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4572,15 +5600,20 @@ class Elasticsearch(BaseClient):
4572
5600
  routing: t.Optional[str] = None,
4573
5601
  ) -> ObjectApiResponse[t.Any]:
4574
5602
  """
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.
5603
+ .. raw:: html
5604
+
5605
+ <p>Get the search shards.</p>
5606
+ <p>Get the indices and shards that a search request would be run against.
5607
+ This information can be useful for working out issues or planning optimizations with routing and shard preferences.
5608
+ When filtered aliases are used, the filter is returned as part of the <code>indices</code> section.</p>
5609
+ <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>
5610
+
4579
5611
 
4580
5612
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-shards.html>`_
4581
5613
 
4582
- :param index: Returns the indices and shards that a search request would be executed
4583
- against.
5614
+ :param index: A comma-separated list of data streams, indices, and aliases to
5615
+ search. It supports wildcards (`*`). To search all data streams and indices,
5616
+ omit this parameter or use `*` or `_all`.
4584
5617
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4585
5618
  expression, index alias, or `_all` value targets only missing or closed indices.
4586
5619
  This behavior applies even if the request targets other open indices. For
@@ -4594,9 +5627,9 @@ class Elasticsearch(BaseClient):
4594
5627
  a missing or closed index.
4595
5628
  :param local: If `true`, the request retrieves information from the local node
4596
5629
  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.
5630
+ :param preference: The node or shard the operation should be performed on. It
5631
+ is random by default.
5632
+ :param routing: A custom value used to route operations to a specific shard.
4600
5633
  """
4601
5634
  __path_parts: t.Dict[str, str]
4602
5635
  if index not in SKIP_IN_PATH:
@@ -4676,12 +5709,15 @@ class Elasticsearch(BaseClient):
4676
5709
  body: t.Optional[t.Dict[str, t.Any]] = None,
4677
5710
  ) -> ObjectApiResponse[t.Any]:
4678
5711
  """
4679
- Run a search with a search template.
5712
+ .. raw:: html
5713
+
5714
+ <p>Run a search with a search template.</p>
4680
5715
 
4681
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-template.html>`_
4682
5716
 
4683
- :param index: Comma-separated list of data streams, indices, and aliases to search.
4684
- Supports wildcards (*).
5717
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-template-api.html>`_
5718
+
5719
+ :param index: A comma-separated list of data streams, indices, and aliases to
5720
+ search. It supports wildcards (`*`).
4685
5721
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4686
5722
  expression, index alias, or `_all` value targets only missing or closed indices.
4687
5723
  This behavior applies even if the request targets other open indices. For
@@ -4689,32 +5725,34 @@ class Elasticsearch(BaseClient):
4689
5725
  with `foo` but no index starts with `bar`.
4690
5726
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
4691
5727
  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`.
5728
+ :param expand_wildcards: The type of index that wildcard patterns can match.
5729
+ If the request can target data streams, this argument determines whether
5730
+ wildcard expressions match hidden data streams. Supports comma-separated
5731
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
5732
+ `hidden`, `none`.
4696
5733
  :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.
5734
+ as part of each hit. If you specify both this and the `explain` query parameter,
5735
+ the API uses only the query parameter.
5736
+ :param id: The ID of the search template to use. If no `source` is specified,
5737
+ this parameter is required.
4700
5738
  :param ignore_throttled: If `true`, specified concrete, expanded, or aliased
4701
5739
  indices are not included in the response when throttled.
4702
5740
  :param ignore_unavailable: If `false`, the request returns an error if it targets
4703
5741
  a missing or closed index.
4704
5742
  :param params: Key-value pairs used to replace Mustache variables in the template.
4705
5743
  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.
5744
+ :param preference: The node or shard the operation should be performed on. It
5745
+ is random by default.
4708
5746
  :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.
5747
+ :param rest_total_hits_as_int: If `true`, `hits.total` is rendered as an integer
5748
+ in the response. If `false`, it is rendered as an object.
5749
+ :param routing: A custom value used to route operations to a specific shard.
4712
5750
  :param scroll: Specifies how long a consistent view of the index should be maintained
4713
5751
  for scrolled search.
4714
5752
  :param search_type: The type of the search operation.
4715
5753
  :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.
5754
+ search API's request body. It also supports Mustache variables. If no `id`
5755
+ is specified, this parameter is required.
4718
5756
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
4719
5757
  names with their respective types.
4720
5758
  """
@@ -4808,34 +5846,39 @@ class Elasticsearch(BaseClient):
4808
5846
  body: t.Optional[t.Dict[str, t.Any]] = None,
4809
5847
  ) -> ObjectApiResponse[t.Any]:
4810
5848
  """
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.
5849
+ .. raw:: html
5850
+
5851
+ <p>Get terms in an index.</p>
5852
+ <p>Discover terms that match a partial string in an index.
5853
+ This API is designed for low-latency look-ups used in auto-complete scenarios.</p>
5854
+ <blockquote>
5855
+ <p>info
5856
+ 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>
5857
+ </blockquote>
5858
+
4820
5859
 
4821
5860
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-terms-enum.html>`_
4822
5861
 
4823
- :param index: Comma-separated list of data streams, indices, and index aliases
4824
- to search. Wildcard (*) expressions are supported.
5862
+ :param index: A comma-separated list of data streams, indices, and index aliases
5863
+ to search. Wildcard (`*`) expressions are supported. To search all data streams
5864
+ or indices, omit this parameter or use `*` or `_all`.
4825
5865
  :param field: The string to match at the start of indexed terms. If not provided,
4826
5866
  all terms in the field are considered.
4827
- :param case_insensitive: When true the provided search string is matched against
5867
+ :param case_insensitive: When `true`, the provided search string is matched against
4828
5868
  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.
5869
+ :param index_filter: Filter an index shard if the provided query rewrites to
5870
+ `match_none`.
5871
+ :param search_after: The string after which terms in the index should be returned.
5872
+ It allows for a form of pagination if the last result from one request is
5873
+ passed as the `search_after` parameter for a subsequent request.
5874
+ :param size: The number of matching terms to return.
5875
+ :param string: The string to match at the start of indexed terms. If it is not
5876
+ provided, all terms in the field are considered. > info > The prefix string
5877
+ cannot be larger than the largest possible keyword value, which is Lucene's
5878
+ term byte-length limit of 32766.
5879
+ :param timeout: The maximum length of time to spend collecting results. If the
5880
+ timeout is exceeded the `complete` flag set to `false` in the response and
5881
+ the results may be partial or empty.
4839
5882
  """
4840
5883
  if index in SKIP_IN_PATH:
4841
5884
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4914,33 +5957,77 @@ class Elasticsearch(BaseClient):
4914
5957
  body: t.Optional[t.Dict[str, t.Any]] = None,
4915
5958
  ) -> ObjectApiResponse[t.Any]:
4916
5959
  """
4917
- Get term vector information. Get information and statistics about terms in the
4918
- fields of a particular document.
5960
+ .. raw:: html
5961
+
5962
+ <p>Get term vector information.</p>
5963
+ <p>Get information and statistics about terms in the fields of a particular document.</p>
5964
+ <p>You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request.
5965
+ You can specify the fields you are interested in through the <code>fields</code> parameter or by adding the fields to the request body.
5966
+ For example:</p>
5967
+ <pre><code>GET /my-index-000001/_termvectors/1?fields=message
5968
+ </code></pre>
5969
+ <p>Fields can be specified using wildcards, similar to the multi match query.</p>
5970
+ <p>Term vectors are real-time by default, not near real-time.
5971
+ This can be changed by setting <code>realtime</code> parameter to <code>false</code>.</p>
5972
+ <p>You can request three types of values: <em>term information</em>, <em>term statistics</em>, and <em>field statistics</em>.
5973
+ By default, all term information and field statistics are returned for all fields but term statistics are excluded.</p>
5974
+ <p><strong>Term information</strong></p>
5975
+ <ul>
5976
+ <li>term frequency in the field (always returned)</li>
5977
+ <li>term positions (<code>positions: true</code>)</li>
5978
+ <li>start and end offsets (<code>offsets: true</code>)</li>
5979
+ <li>term payloads (<code>payloads: true</code>), as base64 encoded bytes</li>
5980
+ </ul>
5981
+ <p>If the requested information wasn't stored in the index, it will be computed on the fly if possible.
5982
+ Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.</p>
5983
+ <blockquote>
5984
+ <p>warn
5985
+ 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>
5986
+ </blockquote>
5987
+ <p><strong>Behaviour</strong></p>
5988
+ <p>The term and field statistics are not accurate.
5989
+ Deleted documents are not taken into account.
5990
+ The information is only retrieved for the shard the requested document resides in.
5991
+ The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
5992
+ By default, when requesting term vectors of artificial documents, a shard to get the statistics from is randomly selected.
5993
+ Use <code>routing</code> only to hit a particular shard.</p>
5994
+
4919
5995
 
4920
5996
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-termvectors.html>`_
4921
5997
 
4922
- :param index: Name of the index that contains the document.
4923
- :param id: Unique identifier of the document.
5998
+ :param index: The name of the index that contains the document.
5999
+ :param id: A unique identifier for the document.
4924
6000
  :param doc: An artificial document (a document not present in the index) for
4925
6001
  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.
6002
+ :param field_statistics: If `true`, the response includes: * The document count
6003
+ (how many documents contain this field). * The sum of document frequencies
6004
+ (the sum of document frequencies for all terms in this field). * The sum
6005
+ of total term frequencies (the sum of total term frequencies of each term
6006
+ in this field).
6007
+ :param fields: A comma-separated list or wildcard expressions of fields to include
6008
+ in the statistics. It is used as the default list unless a specific field
6009
+ list is provided in the `completion_fields` or `fielddata_fields` parameters.
6010
+ :param filter: Filter terms based on their tf-idf scores. This could be useful
6011
+ in order find out a good characteristic vector of a document. This feature
6012
+ works in a similar manner to the second phase of the More Like This Query.
4932
6013
  :param offsets: If `true`, the response includes term offsets.
4933
6014
  :param payloads: If `true`, the response includes term payloads.
4934
- :param per_field_analyzer: Overrides the default per-field analyzer.
6015
+ :param per_field_analyzer: Override the default per-field analyzer. This is useful
6016
+ in order to generate term vectors in any fashion, especially when using artificial
6017
+ documents. When providing an analyzer for a field that already stores term
6018
+ vectors, the term vectors will be regenerated.
4935
6019
  :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.
6020
+ :param preference: The node or shard the operation should be performed on. It
6021
+ is random by default.
4938
6022
  :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.
6023
+ :param routing: A custom value that is used to route operations to a specific
6024
+ shard.
6025
+ :param term_statistics: If `true`, the response includes: * The total term frequency
6026
+ (how often a term occurs in all documents). * The document frequency (the
6027
+ number of documents containing the current term). By default these values
6028
+ are not returned since term statistics can have a serious performance impact.
4942
6029
  :param version: If `true`, returns the document version as part of a hit.
4943
- :param version_type: Specific version type.
6030
+ :param version_type: The version type.
4944
6031
  """
4945
6032
  if index in SKIP_IN_PATH:
4946
6033
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5057,46 +6144,65 @@ class Elasticsearch(BaseClient):
5057
6144
  body: t.Optional[t.Dict[str, t.Any]] = None,
5058
6145
  ) -> ObjectApiResponse[t.Any]:
5059
6146
  """
5060
- Update a document. Updates a document by running a script or passing a partial
5061
- document.
6147
+ .. raw:: html
6148
+
6149
+ <p>Update a document.</p>
6150
+ <p>Update a document by running a script or passing a partial document.</p>
6151
+ <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>
6152
+ <p>The script can update, delete, or skip modifying the document.
6153
+ The API also supports passing a partial document, which is merged into the existing document.
6154
+ To fully replace an existing document, use the index API.
6155
+ This operation:</p>
6156
+ <ul>
6157
+ <li>Gets the document (collocated with the shard) from the index.</li>
6158
+ <li>Runs the specified script.</li>
6159
+ <li>Indexes the result.</li>
6160
+ </ul>
6161
+ <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>
6162
+ <p>The <code>_source</code> field must be enabled to use this API.
6163
+ 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>
6164
+
5062
6165
 
5063
6166
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update.html>`_
5064
6167
 
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'
6168
+ :param index: The name of the target index. By default, the index is created
6169
+ automatically if it doesn't exist.
6170
+ :param id: A unique identifier for the document to be updated.
6171
+ :param detect_noop: If `true`, the `result` in the response is set to `noop`
6172
+ (no operation) when there are no changes to the document.
6173
+ :param doc: A partial update to an existing document. If both `doc` and `script`
6174
+ are specified, `doc` is ignored.
6175
+ :param doc_as_upsert: If `true`, use the contents of 'doc' as the value of 'upsert'.
6176
+ NOTE: Using ingest pipelines with `doc_as_upsert` is not supported.
5072
6177
  :param if_primary_term: Only perform the operation if the document has this primary
5073
6178
  term.
5074
6179
  :param if_seq_no: Only perform the operation if the document has this sequence
5075
6180
  number.
5076
6181
  :param lang: The script language.
5077
6182
  :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
6183
+ this operation visible to search. If 'wait_for', it waits for a refresh to
6184
+ make this operation visible to search. If 'false', it does nothing with refreshes.
6185
+ :param require_alias: If `true`, the destination must be an index alias.
6186
+ :param retry_on_conflict: The number of times the operation should be retried
5082
6187
  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.
6188
+ :param routing: A custom value used to route operations to a specific shard.
6189
+ :param script: The script to run to update the document.
6190
+ :param scripted_upsert: If `true`, run the script whether or not the document
6191
+ exists.
6192
+ :param source: If `false`, turn off source retrieval. You can also specify a
6193
+ comma-separated list of the fields you want to retrieve.
6194
+ :param source_excludes: The source fields you want to exclude.
6195
+ :param source_includes: The source fields you want to retrieve.
6196
+ :param timeout: The period to wait for the following operations: dynamic mapping
6197
+ updates and waiting for active shards. Elasticsearch waits for at least the
6198
+ timeout period before failing. The actual wait time could be longer, particularly
6199
+ when multiple waits occur.
5094
6200
  :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.
6201
+ are inserted as a new document. If the document exists, the 'script' is run.
6202
+ :param wait_for_active_shards: The number of copies of each shard that must be
6203
+ active before proceeding with the operation. Set to 'all' or any positive
6204
+ integer up to the total number of shards in the index (`number_of_replicas`+1).
6205
+ The default value of `1` means it waits for each primary shard to be active.
5100
6206
  """
5101
6207
  if index in SKIP_IN_PATH:
5102
6208
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5222,82 +6328,166 @@ class Elasticsearch(BaseClient):
5222
6328
  body: t.Optional[t.Dict[str, t.Any]] = None,
5223
6329
  ) -> ObjectApiResponse[t.Any]:
5224
6330
  """
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.
6331
+ .. raw:: html
6332
+
6333
+ <p>Update documents.
6334
+ Updates documents that match the specified query.
6335
+ 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>
6336
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
6337
+ <ul>
6338
+ <li><code>read</code></li>
6339
+ <li><code>index</code> or <code>write</code></li>
6340
+ </ul>
6341
+ <p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.</p>
6342
+ <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.
6343
+ When the versions match, the document is updated and the version number is incremented.
6344
+ 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.
6345
+ You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
6346
+ 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>
6347
+ <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>
6348
+ <p>While processing an update by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents.
6349
+ A bulk update request is performed for each batch of matching documents.
6350
+ Any query or update failures cause the update by query request to fail and the failures are shown in the response.
6351
+ Any update requests that completed successfully still stick, they are not rolled back.</p>
6352
+ <p><strong>Throttling update requests</strong></p>
6353
+ <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.
6354
+ This pads each batch with a wait time to throttle the rate.
6355
+ Set <code>requests_per_second</code> to <code>-1</code> to turn off throttling.</p>
6356
+ <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.
6357
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
6358
+ By default the batch size is 1000, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
6359
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
6360
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
6361
+ </code></pre>
6362
+ <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.
6363
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
6364
+ <p><strong>Slicing</strong></p>
6365
+ <p>Update by query supports sliced scroll to parallelize the update process.
6366
+ This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
6367
+ <p>Setting <code>slices</code> to <code>auto</code> chooses a reasonable number for most data streams and indices.
6368
+ This setting will use one slice per shard, up to a certain limit.
6369
+ 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>
6370
+ <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>
6371
+ <ul>
6372
+ <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>
6373
+ <li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
6374
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
6375
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
6376
+ <li>Canceling the request with slices will cancel each sub-request.</li>
6377
+ <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>
6378
+ <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>
6379
+ <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>
6380
+ </ul>
6381
+ <p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
6382
+ <ul>
6383
+ <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>
6384
+ <li>Update performance scales linearly across available resources with the number of slices.</li>
6385
+ </ul>
6386
+ <p>Whether query or update performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
6387
+ <p><strong>Update the document source</strong></p>
6388
+ <p>Update by query supports scripts to update the document source.
6389
+ As with the update API, you can set <code>ctx.op</code> to change the operation that is performed.</p>
6390
+ <p>Set <code>ctx.op = &quot;noop&quot;</code> if your script decides that it doesn't have to make any changes.
6391
+ The update by query operation skips updating the document and increments the <code>noop</code> counter.</p>
6392
+ <p>Set <code>ctx.op = &quot;delete&quot;</code> if your script decides that the document should be deleted.
6393
+ The update by query operation deletes the document and increments the <code>deleted</code> counter.</p>
6394
+ <p>Update by query supports only <code>index</code>, <code>noop</code>, and <code>delete</code>.
6395
+ Setting <code>ctx.op</code> to anything else is an error.
6396
+ Setting any other field in <code>ctx</code> is an error.
6397
+ This API enables you to only modify the source of matching documents; you cannot move them.</p>
6398
+
5228
6399
 
5229
6400
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
5230
6401
 
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`.
6402
+ :param index: A comma-separated list of data streams, indices, and aliases to
6403
+ search. It supports wildcards (`*`). To search all data streams or indices,
6404
+ omit this parameter or use `*` or `_all`.
5234
6405
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
5235
6406
  expression, index alias, or `_all` value targets only missing or closed indices.
5236
6407
  This behavior applies even if the request targets other open indices. For
5237
6408
  example, a request targeting `foo*,bar*` returns an error if an index starts
5238
6409
  with `foo` but no index starts with `bar`.
5239
6410
  :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`.
6411
+ This parameter can be used only when the `q` query string parameter is specified.
6412
+ :param analyzer: The analyzer to use for the query string. This parameter can
6413
+ be used only when the `q` query string parameter is specified.
6414
+ :param conflicts: The preferred behavior when update by query hits version conflicts:
6415
+ `abort` or `proceed`.
5243
6416
  :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`.
6417
+ `OR`. This parameter can be used only when the `q` query string parameter
6418
+ is specified.
6419
+ :param df: The field to use as default where no field prefix is given in the
6420
+ query string. This parameter can be used only when the `q` query string parameter
6421
+ is specified.
6422
+ :param expand_wildcards: The type of index that wildcard patterns can match.
6423
+ If the request can target data streams, this argument determines whether
6424
+ wildcard expressions match hidden data streams. It supports comma-separated
6425
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
6426
+ `hidden`, `none`.
5251
6427
  :param from_: Starting offset (default: 0)
5252
6428
  :param ignore_unavailable: If `false`, the request returns an error if it targets
5253
6429
  a missing or closed index.
5254
6430
  :param lenient: If `true`, format-based query failures (such as providing text
5255
- to a numeric field) in the query string will be ignored.
6431
+ to a numeric field) in the query string will be ignored. This parameter can
6432
+ be used only when the `q` query string parameter is specified.
5256
6433
  :param max_docs: The maximum number of documents to update.
5257
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
6434
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
5258
6435
  If the index has a default ingest pipeline specified, then setting the value
5259
6436
  to `_none` disables the default ingest pipeline for this request. If a final
5260
6437
  pipeline is configured it will always run, regardless of the value of this
5261
6438
  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.
6439
+ :param preference: The node or shard the operation should be performed on. It
6440
+ is random by default.
6441
+ :param q: A query in the Lucene query string syntax.
6442
+ :param query: The documents to update using the Query DSL.
5266
6443
  :param refresh: If `true`, Elasticsearch refreshes affected shards to make the
5267
- operation visible to search.
6444
+ operation visible to search after the request completes. This is different
6445
+ than the update API's `refresh` parameter, which causes just the shard that
6446
+ received the request to be refreshed.
5268
6447
  :param request_cache: If `true`, the request cache is used for this request.
6448
+ It defaults to the index-level setting.
5269
6449
  :param requests_per_second: The throttle for this request in sub-requests per
5270
6450
  second.
5271
- :param routing: Custom value used to route operations to a specific shard.
6451
+ :param routing: A custom value used to route operations to a specific shard.
5272
6452
  :param script: The script to run to update the document source or metadata when
5273
6453
  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`.
6454
+ :param scroll: The period to retain the search context for scrolling.
6455
+ :param scroll_size: The size of the scroll request that powers the operation.
6456
+ :param search_timeout: An explicit timeout for each search request. By default,
6457
+ there is no timeout.
6458
+ :param search_type: The type of the search operation. Available options include
6459
+ `query_then_fetch` and `dfs_query_then_fetch`.
5279
6460
  :param slice: Slice the request manually using the provided slice ID and total
5280
6461
  number of slices.
5281
6462
  :param slices: The number of slices this task should be divided into.
5282
6463
  :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.
6464
+ :param stats: The specific `tag` of the request for logging and statistical purposes.
6465
+ :param terminate_after: The maximum number of documents to collect for each shard.
5285
6466
  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.
6467
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
6468
+ Elasticsearch applies this parameter to each shard handling the request.
6469
+ When possible, let Elasticsearch perform early termination automatically.
6470
+ Avoid specifying this parameter for requests that target data streams with
6471
+ backing indices across multiple data tiers.
6472
+ :param timeout: The period each update request waits for the following operations:
6473
+ dynamic mapping updates, waiting for active shards. By default, it is one
6474
+ minute. This guarantees Elasticsearch waits for at least the timeout before
6475
+ failing. The actual wait time could be longer, particularly when multiple
6476
+ waits occur.
5293
6477
  :param version: If `true`, returns the document version as part of a hit.
5294
6478
  :param version_type: Should the document increment the version number (internal)
5295
6479
  on hit or not (reindex)
5296
6480
  :param wait_for_active_shards: The number of shard copies that must be active
5297
6481
  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`).
6482
+ up to the total number of shards in the index (`number_of_replicas+1`). The
6483
+ `timeout` parameter controls how long each write request waits for unavailable
6484
+ shards to become available. Both work exactly the way they work in the bulk
6485
+ API.
5299
6486
  :param wait_for_completion: If `true`, the request blocks until the operation
5300
- is complete.
6487
+ is complete. If `false`, Elasticsearch performs some preflight checks, launches
6488
+ the request, and returns a task ID that you can use to cancel or get the
6489
+ status of the task. Elasticsearch creates a record of this task as a document
6490
+ at `.tasks/task/${taskId}`.
5301
6491
  """
5302
6492
  if index in SKIP_IN_PATH:
5303
6493
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5420,16 +6610,18 @@ class Elasticsearch(BaseClient):
5420
6610
  requests_per_second: t.Optional[float] = None,
5421
6611
  ) -> ObjectApiResponse[t.Any]:
5422
6612
  """
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.
6613
+ .. raw:: html
6614
+
6615
+ <p>Throttle an update by query operation.</p>
6616
+ <p>Change the number of requests per second for a particular update by query operation.
6617
+ 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
6618
 
5428
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
6619
+
6620
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html#docs-update-by-query-rethrottle>`_
5429
6621
 
5430
6622
  :param task_id: The ID for the task.
5431
6623
  :param requests_per_second: The throttle for this request in sub-requests per
5432
- second.
6624
+ second. To turn off throttling, set it to `-1`.
5433
6625
  """
5434
6626
  if task_id in SKIP_IN_PATH:
5435
6627
  raise ValueError("Empty value passed for parameter 'task_id'")