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