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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. elasticsearch/__init__.py +2 -2
  2. elasticsearch/_async/client/__init__.py +2034 -740
  3. elasticsearch/_async/client/async_search.py +33 -22
  4. elasticsearch/_async/client/autoscaling.py +27 -21
  5. elasticsearch/_async/client/cat.py +280 -336
  6. elasticsearch/_async/client/ccr.py +96 -70
  7. elasticsearch/_async/client/cluster.py +152 -144
  8. elasticsearch/_async/client/connector.py +488 -55
  9. elasticsearch/_async/client/dangling_indices.py +22 -16
  10. elasticsearch/_async/client/enrich.py +25 -6
  11. elasticsearch/_async/client/eql.py +22 -9
  12. elasticsearch/_async/client/esql.py +295 -3
  13. elasticsearch/_async/client/features.py +25 -25
  14. elasticsearch/_async/client/fleet.py +15 -9
  15. elasticsearch/_async/client/graph.py +9 -8
  16. elasticsearch/_async/client/ilm.py +91 -61
  17. elasticsearch/_async/client/indices.py +746 -324
  18. elasticsearch/_async/client/inference.py +101 -4
  19. elasticsearch/_async/client/ingest.py +231 -19
  20. elasticsearch/_async/client/license.py +48 -31
  21. elasticsearch/_async/client/logstash.py +20 -6
  22. elasticsearch/_async/client/migration.py +25 -7
  23. elasticsearch/_async/client/ml.py +532 -278
  24. elasticsearch/_async/client/monitoring.py +5 -1
  25. elasticsearch/_async/client/nodes.py +46 -30
  26. elasticsearch/_async/client/query_rules.py +65 -18
  27. elasticsearch/_async/client/rollup.py +126 -13
  28. elasticsearch/_async/client/search_application.py +170 -13
  29. elasticsearch/_async/client/searchable_snapshots.py +45 -23
  30. elasticsearch/_async/client/security.py +1299 -340
  31. elasticsearch/_async/client/shutdown.py +43 -15
  32. elasticsearch/_async/client/simulate.py +145 -0
  33. elasticsearch/_async/client/slm.py +163 -19
  34. elasticsearch/_async/client/snapshot.py +288 -23
  35. elasticsearch/_async/client/sql.py +94 -53
  36. elasticsearch/_async/client/ssl.py +16 -17
  37. elasticsearch/_async/client/synonyms.py +67 -26
  38. elasticsearch/_async/client/tasks.py +103 -28
  39. elasticsearch/_async/client/text_structure.py +475 -46
  40. elasticsearch/_async/client/transform.py +108 -72
  41. elasticsearch/_async/client/watcher.py +245 -43
  42. elasticsearch/_async/client/xpack.py +20 -6
  43. elasticsearch/_async/helpers.py +1 -1
  44. elasticsearch/_sync/client/__init__.py +2034 -740
  45. elasticsearch/_sync/client/async_search.py +33 -22
  46. elasticsearch/_sync/client/autoscaling.py +27 -21
  47. elasticsearch/_sync/client/cat.py +280 -336
  48. elasticsearch/_sync/client/ccr.py +96 -70
  49. elasticsearch/_sync/client/cluster.py +152 -144
  50. elasticsearch/_sync/client/connector.py +488 -55
  51. elasticsearch/_sync/client/dangling_indices.py +22 -16
  52. elasticsearch/_sync/client/enrich.py +25 -6
  53. elasticsearch/_sync/client/eql.py +22 -9
  54. elasticsearch/_sync/client/esql.py +295 -3
  55. elasticsearch/_sync/client/features.py +25 -25
  56. elasticsearch/_sync/client/fleet.py +15 -9
  57. elasticsearch/_sync/client/graph.py +9 -8
  58. elasticsearch/_sync/client/ilm.py +91 -61
  59. elasticsearch/_sync/client/indices.py +746 -324
  60. elasticsearch/_sync/client/inference.py +101 -4
  61. elasticsearch/_sync/client/ingest.py +231 -19
  62. elasticsearch/_sync/client/license.py +48 -31
  63. elasticsearch/_sync/client/logstash.py +20 -6
  64. elasticsearch/_sync/client/migration.py +25 -7
  65. elasticsearch/_sync/client/ml.py +532 -278
  66. elasticsearch/_sync/client/monitoring.py +5 -1
  67. elasticsearch/_sync/client/nodes.py +46 -30
  68. elasticsearch/_sync/client/query_rules.py +65 -18
  69. elasticsearch/_sync/client/rollup.py +126 -13
  70. elasticsearch/_sync/client/search_application.py +170 -13
  71. elasticsearch/_sync/client/searchable_snapshots.py +45 -23
  72. elasticsearch/_sync/client/security.py +1299 -340
  73. elasticsearch/_sync/client/shutdown.py +43 -15
  74. elasticsearch/_sync/client/simulate.py +145 -0
  75. elasticsearch/_sync/client/slm.py +163 -19
  76. elasticsearch/_sync/client/snapshot.py +288 -23
  77. elasticsearch/_sync/client/sql.py +94 -53
  78. elasticsearch/_sync/client/ssl.py +16 -17
  79. elasticsearch/_sync/client/synonyms.py +67 -26
  80. elasticsearch/_sync/client/tasks.py +103 -28
  81. elasticsearch/_sync/client/text_structure.py +475 -46
  82. elasticsearch/_sync/client/transform.py +108 -72
  83. elasticsearch/_sync/client/utils.py +1 -1
  84. elasticsearch/_sync/client/watcher.py +245 -43
  85. elasticsearch/_sync/client/xpack.py +20 -6
  86. elasticsearch/_version.py +1 -1
  87. elasticsearch/client.py +4 -0
  88. elasticsearch/helpers/actions.py +1 -1
  89. elasticsearch/helpers/vectorstore/_sync/vectorstore.py +4 -1
  90. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/METADATA +1 -1
  91. elasticsearch-8.17.2.dist-info/RECORD +119 -0
  92. elasticsearch-8.17.0.dist-info/RECORD +0 -117
  93. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/WHEEL +0 -0
  94. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/licenses/LICENSE +0 -0
  95. {elasticsearch-8.17.0.dist-info → elasticsearch-8.17.2.dist-info}/licenses/NOTICE +0 -0
@@ -70,6 +70,7 @@ from .search_application import SearchApplicationClient
70
70
  from .searchable_snapshots import SearchableSnapshotsClient
71
71
  from .security import SecurityClient
72
72
  from .shutdown import ShutdownClient
73
+ from .simulate import SimulateClient
73
74
  from .slm import SlmClient
74
75
  from .snapshot import SnapshotClient
75
76
  from .sql import SqlClient
@@ -465,6 +466,7 @@ class AsyncElasticsearch(BaseClient):
465
466
  self.searchable_snapshots = SearchableSnapshotsClient(self)
466
467
  self.security = SecurityClient(self)
467
468
  self.slm = SlmClient(self)
469
+ self.simulate = SimulateClient(self)
468
470
  self.shutdown = ShutdownClient(self)
469
471
  self.sql = SqlClient(self)
470
472
  self.ssl = SslClient(self)
@@ -644,41 +646,131 @@ class AsyncElasticsearch(BaseClient):
644
646
  ] = None,
645
647
  ) -> ObjectApiResponse[t.Any]:
646
648
  """
647
- Bulk index or delete documents. Performs multiple indexing or delete operations
648
- in a single API call. This reduces overhead and can greatly increase indexing
649
- speed.
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
+
650
732
 
651
733
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-bulk.html>`_
652
734
 
653
735
  :param operations:
654
- :param index: Name of the data stream, index, or index alias to perform bulk
736
+ :param index: The name of the data stream, index, or index alias to perform bulk
655
737
  actions on.
656
738
  :param list_executed_pipelines: If `true`, the response will include the ingest
657
- pipelines that were executed for each index or create.
658
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
659
- If the index has a default ingest pipeline specified, then setting the value
660
- to `_none` disables the default ingest pipeline for this request. If a final
661
- pipeline is configured it will always run, regardless of the value of this
739
+ pipelines that were run for each index or create.
740
+ :param pipeline: The pipeline identifier to use to preprocess incoming documents.
741
+ If the index has a default ingest pipeline specified, setting the value to
742
+ `_none` turns off the default ingest pipeline for this request. If a final
743
+ pipeline is configured, it will always run regardless of the value of this
662
744
  parameter.
663
745
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
664
- this operation visible to search, if `wait_for` then wait for a refresh to
665
- make this operation visible to search, if `false` do nothing with refreshes.
746
+ this operation visible to search. If `wait_for`, wait for a refresh to make
747
+ this operation visible to search. If `false`, do nothing with refreshes.
666
748
  Valid values: `true`, `false`, `wait_for`.
667
- :param require_alias: If `true`, the requests actions must target an index alias.
749
+ :param require_alias: If `true`, the request's actions must target an index alias.
668
750
  :param require_data_stream: If `true`, the request's actions must target a data
669
- stream (existing or to-be-created).
670
- :param routing: Custom value used to route operations to a specific shard.
671
- :param source: `true` or `false` to return the `_source` field or not, or a list
672
- of fields to return.
751
+ stream (existing or to be created).
752
+ :param routing: A custom value that is used to route operations to a specific
753
+ shard.
754
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
755
+ or contains a list of fields to return.
673
756
  :param source_excludes: A comma-separated list of source fields to exclude from
674
- the response.
757
+ the response. You can also use this parameter to exclude fields from the
758
+ subset specified in `_source_includes` query parameter. If the `_source`
759
+ parameter is `false`, this parameter is ignored.
675
760
  :param source_includes: A comma-separated list of source fields to include in
676
- the response.
677
- :param timeout: Period each action waits for the following operations: automatic
678
- index creation, dynamic mapping updates, waiting for active shards.
761
+ the response. If this parameter is specified, only these source fields are
762
+ returned. You can exclude fields from this subset using the `_source_excludes`
763
+ query parameter. If the `_source` parameter is `false`, this parameter is
764
+ ignored.
765
+ :param timeout: The period each action waits for the following operations: automatic
766
+ index creation, dynamic mapping updates, and waiting for active shards. The
767
+ default is `1m` (one minute), which guarantees Elasticsearch waits for at
768
+ least the timeout before failing. The actual wait time could be longer, particularly
769
+ when multiple waits occur.
679
770
  :param wait_for_active_shards: The number of shard copies that must be active
680
- before proceeding with the operation. Set to all or any positive integer
681
- up to the total number of shards in the index (`number_of_replicas+1`).
771
+ before proceeding with the operation. Set to `all` or any positive integer
772
+ up to the total number of shards in the index (`number_of_replicas+1`). The
773
+ default is `1`, which waits for each primary shard to be active.
682
774
  """
683
775
  if operations is None and body is None:
684
776
  raise ValueError(
@@ -753,12 +845,15 @@ class AsyncElasticsearch(BaseClient):
753
845
  body: t.Optional[t.Dict[str, t.Any]] = None,
754
846
  ) -> ObjectApiResponse[t.Any]:
755
847
  """
756
- Clear a scrolling search. Clear the search context and results for a scrolling
757
- search.
848
+ .. raw:: html
849
+
850
+ <p>Clear a scrolling search.
851
+ Clear the search context and results for a scrolling search.</p>
852
+
758
853
 
759
854
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/clear-scroll-api.html>`_
760
855
 
761
- :param scroll_id: Scroll IDs to clear. To clear all scroll IDs, use `_all`.
856
+ :param scroll_id: The scroll IDs to clear. To clear all scroll IDs, use `_all`.
762
857
  """
763
858
  __path_parts: t.Dict[str, str] = {}
764
859
  __path = "/_search/scroll"
@@ -804,11 +899,14 @@ class AsyncElasticsearch(BaseClient):
804
899
  body: t.Optional[t.Dict[str, t.Any]] = None,
805
900
  ) -> ObjectApiResponse[t.Any]:
806
901
  """
807
- Close a point in time. A point in time must be opened explicitly before being
808
- used in search requests. The `keep_alive` parameter tells Elasticsearch how long
809
- it should persist. A point in time is automatically closed when the `keep_alive`
810
- period has elapsed. However, keeping points in time has a cost; close them as
811
- 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
+
812
910
 
813
911
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
814
912
 
@@ -882,46 +980,65 @@ class AsyncElasticsearch(BaseClient):
882
980
  body: t.Optional[t.Dict[str, t.Any]] = None,
883
981
  ) -> ObjectApiResponse[t.Any]:
884
982
  """
885
- Count search results. Get the number of documents matching a query.
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
+
886
994
 
887
995
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-count.html>`_
888
996
 
889
- :param index: Comma-separated list of data streams, indices, and aliases to search.
890
- Supports wildcards (`*`). To search all data streams and indices, omit this
891
- parameter or use `*` or `_all`.
997
+ :param index: A comma-separated list of data streams, indices, and aliases to
998
+ search. It supports wildcards (`*`). To search all data streams and indices,
999
+ omit this parameter or use `*` or `_all`.
892
1000
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
893
1001
  expression, index alias, or `_all` value targets only missing or closed indices.
894
- This behavior applies even if the request targets other open indices.
1002
+ This behavior applies even if the request targets other open indices. For
1003
+ example, a request targeting `foo*,bar*` returns an error if an index starts
1004
+ with `foo` but no index starts with `bar`.
895
1005
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
896
- This parameter can only be used when the `q` query string parameter is specified.
897
- :param analyzer: Analyzer to use for the query string. This parameter can only
898
- be used when the `q` query string parameter is specified.
1006
+ This parameter can be used only when the `q` query string parameter is specified.
1007
+ :param analyzer: The analyzer to use for the query string. This parameter can
1008
+ be used only when the `q` query string parameter is specified.
899
1009
  :param default_operator: The default operator for query string query: `AND` or
900
- `OR`. This parameter can only be used when the `q` query string parameter
1010
+ `OR`. This parameter can be used only when the `q` query string parameter
901
1011
  is specified.
902
- :param df: Field to use as default where no field prefix is given in the query
903
- string. This parameter can only be used when the `q` query string parameter
1012
+ :param df: The field to use as a default when no field prefix is given in the
1013
+ query string. This parameter can be used only when the `q` query string parameter
904
1014
  is specified.
905
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
906
- request can target data streams, this argument determines whether wildcard
907
- expressions match hidden data streams. Supports comma-separated values, such
908
- as `open,hidden`.
909
- :param ignore_throttled: If `true`, concrete, expanded or aliased indices are
1015
+ :param expand_wildcards: The type of index that wildcard patterns can match.
1016
+ If the request can target data streams, this argument determines whether
1017
+ wildcard expressions match hidden data streams. It supports comma-separated
1018
+ values, such as `open,hidden`.
1019
+ :param ignore_throttled: If `true`, concrete, expanded, or aliased indices are
910
1020
  ignored when frozen.
911
1021
  :param ignore_unavailable: If `false`, the request returns an error if it targets
912
1022
  a missing or closed index.
913
1023
  :param lenient: If `true`, format-based query failures (such as providing text
914
- to a numeric field) in the query string will be ignored.
915
- :param min_score: Sets the minimum `_score` value that documents must have to
916
- be included in the result.
917
- :param preference: Specifies the node or shard the operation should be performed
918
- on. Random by default.
919
- :param q: Query in the Lucene query string syntax.
920
- :param query: Defines the search definition using the Query DSL.
921
- :param routing: Custom value used to route operations to a specific shard.
922
- :param terminate_after: Maximum number of documents to collect for each shard.
1024
+ to a numeric field) in the query string will be ignored. This parameter can
1025
+ be used only when the `q` query string parameter is specified.
1026
+ :param min_score: The minimum `_score` value that documents must have to be included
1027
+ in the result.
1028
+ :param preference: The node or shard the operation should be performed on. By
1029
+ default, it is random.
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.
1034
+ :param routing: A custom value used to route operations to a specific shard.
1035
+ :param terminate_after: The maximum number of documents to collect for each shard.
923
1036
  If a query reaches this limit, Elasticsearch terminates the query early.
924
- Elasticsearch collects documents before sorting.
1037
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
1038
+ Elasticsearch applies this parameter to each shard handling the request.
1039
+ When possible, let Elasticsearch perform early termination automatically.
1040
+ Avoid specifying this parameter for requests that target data streams with
1041
+ backing indices across multiple data tiers.
925
1042
  """
926
1043
  __path_parts: t.Dict[str, str]
927
1044
  if index not in SKIP_IN_PATH:
@@ -1015,38 +1132,100 @@ class AsyncElasticsearch(BaseClient):
1015
1132
  ] = None,
1016
1133
  ) -> ObjectApiResponse[t.Any]:
1017
1134
  """
1018
- Index a document. Adds a JSON document to the specified data stream or index
1019
- and makes it searchable. If the target is an index and the document already exists,
1020
- 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
+
1021
1190
 
1022
1191
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
1023
1192
 
1024
- :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
1025
1194
  exist and matches the name or wildcard (`*`) pattern of an index template
1026
1195
  with a `data_stream` definition, this request creates the data stream. If
1027
- 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
1028
1197
  creates the index.
1029
- :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.
1030
1200
  :param document:
1031
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
1032
- If the index has a default ingest pipeline specified, then setting the value
1033
- to `_none` disables the default ingest pipeline for this request. If a final
1034
- 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
1035
1205
  parameter.
1036
1206
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
1037
- this operation visible to search, if `wait_for` then wait for a refresh to
1038
- make this operation visible to search, if `false` do nothing with refreshes.
1039
- Valid values: `true`, `false`, `wait_for`.
1040
- :param routing: Custom value used to route operations to a specific shard.
1041
- :param timeout: Period the request waits for the following operations: automatic
1042
- index creation, dynamic mapping updates, waiting for active shards.
1043
- :param version: Explicit version number for concurrency control. The specified
1044
- version must match the current version of the document for the request to
1045
- succeed.
1046
- :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.
1047
1225
  :param wait_for_active_shards: The number of shard copies that must be active
1048
- before proceeding with the operation. Set to `all` or any positive integer
1049
- 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.
1050
1229
  """
1051
1230
  if index in SKIP_IN_PATH:
1052
1231
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1121,29 +1300,60 @@ class AsyncElasticsearch(BaseClient):
1121
1300
  ] = None,
1122
1301
  ) -> ObjectApiResponse[t.Any]:
1123
1302
  """
1124
- 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
+
1125
1330
 
1126
1331
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete.html>`_
1127
1332
 
1128
- :param index: Name of the target index.
1129
- :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.
1130
1335
  :param if_primary_term: Only perform the operation if the document has this primary
1131
1336
  term.
1132
1337
  :param if_seq_no: Only perform the operation if the document has this sequence
1133
1338
  number.
1134
1339
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
1135
- this operation visible to search, if `wait_for` then wait for a refresh to
1136
- make this operation visible to search, if `false` do nothing with refreshes.
1137
- Valid values: `true`, `false`, `wait_for`.
1138
- :param routing: Custom value used to route operations to a specific shard.
1139
- :param timeout: Period to wait for active shards.
1140
- :param version: Explicit version number for concurrency control. The specified
1141
- version must match the current version of the document for the request to
1142
- succeed.
1143
- :param version_type: Specific version type: `external`, `external_gte`.
1144
- :param wait_for_active_shards: The number of shard copies that must be active
1145
- before proceeding with the operation. Set to `all` or any positive integer
1146
- 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.
1147
1357
  """
1148
1358
  if index in SKIP_IN_PATH:
1149
1359
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1243,72 +1453,148 @@ class AsyncElasticsearch(BaseClient):
1243
1453
  body: t.Optional[t.Dict[str, t.Any]] = None,
1244
1454
  ) -> ObjectApiResponse[t.Any]:
1245
1455
  """
1246
- 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
+
1247
1519
 
1248
1520
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1249
1521
 
1250
- :param index: Comma-separated list of data streams, indices, and aliases to search.
1251
- Supports wildcards (`*`). To search all data streams or indices, omit this
1252
- 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`.
1253
1525
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
1254
1526
  expression, index alias, or `_all` value targets only missing or closed indices.
1255
1527
  This behavior applies even if the request targets other open indices. For
1256
1528
  example, a request targeting `foo*,bar*` returns an error if an index starts
1257
1529
  with `foo` but no index starts with `bar`.
1258
1530
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1259
- :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.
1260
1534
  :param conflicts: What to do if delete by query hits version conflicts: `abort`
1261
1535
  or `proceed`.
1262
1536
  :param default_operator: The default operator for query string query: `AND` or
1263
- `OR`.
1264
- :param df: Field to use as default where no field prefix is given in the query
1265
- string.
1266
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
1267
- request can target data streams, this argument determines whether wildcard
1268
- expressions match hidden data streams. Supports comma-separated values, such
1269
- 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`.
1270
1546
  :param from_: Starting offset (default: 0)
1271
1547
  :param ignore_unavailable: If `false`, the request returns an error if it targets
1272
1548
  a missing or closed index.
1273
1549
  :param lenient: If `true`, format-based query failures (such as providing text
1274
- 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.
1275
1552
  :param max_docs: The maximum number of documents to delete.
1276
- :param preference: Specifies the node or shard the operation should be performed
1277
- on. Random by default.
1278
- :param q: Query in the Lucene query string syntax.
1279
- :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.
1280
1557
  :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1281
- 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`.
1282
1562
  :param request_cache: If `true`, the request cache is used for this request.
1283
1563
  Defaults to the index-level setting.
1284
1564
  :param requests_per_second: The throttle for this request in sub-requests per
1285
1565
  second.
1286
- :param routing: Custom value used to route operations to a specific shard.
1287
- :param scroll: Period to retain the search context for scrolling.
1288
- :param scroll_size: Size of the scroll request that powers the operation.
1289
- :param search_timeout: Explicit timeout for each search request. Defaults to
1290
- no timeout.
1291
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
1292
- `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`.
1293
1573
  :param slice: Slice the request manually using the provided slice ID and total
1294
1574
  number of slices.
1295
1575
  :param slices: The number of slices this task should be divided into.
1296
- :param sort: A comma-separated list of <field>:<direction> pairs.
1297
- :param stats: Specific `tag` of the request for logging and statistical purposes.
1298
- :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.
1299
1579
  If a query reaches this limit, Elasticsearch terminates the query early.
1300
1580
  Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
1301
1581
  applies this parameter to each shard handling the request. When possible,
1302
1582
  let Elasticsearch perform early termination automatically. Avoid specifying
1303
1583
  this parameter for requests that target data streams with backing indices
1304
1584
  across multiple data tiers.
1305
- :param timeout: Period each deletion request waits for active shards.
1585
+ :param timeout: The period each deletion request waits for active shards.
1306
1586
  :param version: If `true`, returns the document version as part of a hit.
1307
1587
  :param wait_for_active_shards: The number of shard copies that must be active
1308
- before proceeding with the operation. Set to all or any positive integer
1309
- 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.
1310
1592
  :param wait_for_completion: If `true`, the request blocks until the operation
1311
- 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.
1312
1598
  """
1313
1599
  if index in SKIP_IN_PATH:
1314
1600
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1421,16 +1707,18 @@ class AsyncElasticsearch(BaseClient):
1421
1707
  requests_per_second: t.Optional[float] = None,
1422
1708
  ) -> ObjectApiResponse[t.Any]:
1423
1709
  """
1424
- Throttle a delete by query operation. Change the number of requests per second
1425
- for a particular delete by query operation. Rethrottling that speeds up the query
1426
- takes effect immediately but rethrotting that slows down the query takes effect
1427
- after completing the current batch to prevent scroll timeouts.
1710
+ .. raw:: html
1428
1711
 
1429
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
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>
1715
+
1716
+
1717
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html#docs-delete-by-query-rethrottle>`_
1430
1718
 
1431
1719
  :param task_id: The ID for the task.
1432
1720
  :param requests_per_second: The throttle for this request in sub-requests per
1433
- second.
1721
+ second. To disable throttling, set it to `-1`.
1434
1722
  """
1435
1723
  if task_id in SKIP_IN_PATH:
1436
1724
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -1470,16 +1758,22 @@ class AsyncElasticsearch(BaseClient):
1470
1758
  timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1471
1759
  ) -> ObjectApiResponse[t.Any]:
1472
1760
  """
1473
- Delete a script or search template. Deletes a stored script or search template.
1761
+ .. raw:: html
1474
1762
 
1475
- `<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>
1476
1765
 
1477
- :param id: Identifier for the stored script or search template.
1478
- :param master_timeout: Period to wait for a connection to the master node. If
1479
- no response is received before the timeout expires, the request fails and
1480
- returns an error.
1481
- :param timeout: Period to wait for a response. If no response is received before
1482
- 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.
1483
1777
  """
1484
1778
  if id in SKIP_IN_PATH:
1485
1779
  raise ValueError("Empty value passed for parameter 'id'")
@@ -1538,32 +1832,60 @@ class AsyncElasticsearch(BaseClient):
1538
1832
  ] = None,
1539
1833
  ) -> HeadApiResponse:
1540
1834
  """
1541
- 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
+
1542
1850
 
1543
1851
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1544
1852
 
1545
- :param index: Comma-separated list of data streams, indices, and aliases. Supports
1546
- wildcards (`*`).
1547
- :param id: Identifier of the document.
1548
- :param preference: Specifies the node or shard the operation should be performed
1549
- 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.
1550
1864
  :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1551
- :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1552
- delete by query after the request completes.
1553
- :param routing: Target the specified primary shard.
1554
- :param source: `true` or `false` to return the `_source` field or not, or a list
1555
- of fields to return.
1556
- :param source_excludes: A comma-separated list of source fields to exclude in
1557
- 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.
1558
1876
  :param source_includes: A comma-separated list of source fields to include in
1559
- the response.
1560
- :param stored_fields: List of stored fields to return as part of a hit. If no
1561
- fields are specified, no stored fields are included in the response. If this
1562
- 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`.
1563
1885
  :param version: Explicit version number for concurrency control. The specified
1564
1886
  version must match the current version of the document for the request to
1565
1887
  succeed.
1566
- :param version_type: Specific version type: `external`, `external_gte`.
1888
+ :param version_type: The version type.
1567
1889
  """
1568
1890
  if index in SKIP_IN_PATH:
1569
1891
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1639,29 +1961,38 @@ class AsyncElasticsearch(BaseClient):
1639
1961
  ] = None,
1640
1962
  ) -> HeadApiResponse:
1641
1963
  """
1642
- 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
+
1643
1973
 
1644
1974
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1645
1975
 
1646
- :param index: Comma-separated list of data streams, indices, and aliases. Supports
1647
- wildcards (`*`).
1648
- :param id: Identifier of the document.
1649
- :param preference: Specifies the node or shard the operation should be performed
1650
- on. Random by default.
1651
- :param realtime: If true, the request is real-time as opposed to near-real-time.
1652
- :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1653
- delete by query after the request completes.
1654
- :param routing: Target the specified primary shard.
1655
- :param source: `true` or `false` to return the `_source` field or not, or a list
1656
- 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.
1657
1989
  :param source_excludes: A comma-separated list of source fields to exclude in
1658
1990
  the response.
1659
1991
  :param source_includes: A comma-separated list of source fields to include in
1660
1992
  the response.
1661
- :param version: Explicit version number for concurrency control. The specified
1662
- version must match the current version of the document for the request to
1663
- succeed.
1664
- :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.
1665
1996
  """
1666
1997
  if index in SKIP_IN_PATH:
1667
1998
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1739,34 +2070,47 @@ class AsyncElasticsearch(BaseClient):
1739
2070
  body: t.Optional[t.Dict[str, t.Any]] = None,
1740
2071
  ) -> ObjectApiResponse[t.Any]:
1741
2072
  """
1742
- Explain a document match result. Returns information about why a specific document
1743
- 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
+
1744
2079
 
1745
2080
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-explain.html>`_
1746
2081
 
1747
- :param index: Index names used to limit the request. Only a single index name
1748
- can be provided to this parameter.
1749
- :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.
1750
2085
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1751
- :param analyzer: Analyzer to use for the query string. This parameter can only
1752
- 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.
1753
2089
  :param default_operator: The default operator for query string query: `AND` or
1754
- `OR`.
1755
- :param df: Field to use as default where no field prefix is given in the query
1756
- 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.
1757
2095
  :param lenient: If `true`, format-based query failures (such as providing text
1758
- to a numeric field) in the query string will be ignored.
1759
- :param preference: Specifies the node or shard the operation should be performed
1760
- on. Random by default.
1761
- :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.
1762
2101
  :param query: Defines the search definition using the Query DSL.
1763
- :param routing: Custom value used to route operations to a specific shard.
1764
- :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
1765
2104
  of fields to return.
1766
2105
  :param source_excludes: A comma-separated list of source fields to exclude from
1767
- 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.
1768
2109
  :param source_includes: A comma-separated list of source fields to include in
1769
- 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.
1770
2114
  :param stored_fields: A comma-separated list of stored fields to return in the
1771
2115
  response.
1772
2116
  """
@@ -1859,15 +2203,18 @@ class AsyncElasticsearch(BaseClient):
1859
2203
  body: t.Optional[t.Dict[str, t.Any]] = None,
1860
2204
  ) -> ObjectApiResponse[t.Any]:
1861
2205
  """
1862
- Get the field capabilities. Get information about the capabilities of fields
1863
- among multiple indices. For data streams, the API returns field capabilities
1864
- among the stream’s backing indices. It returns runtime fields like any other
1865
- field. For example, a runtime field with a type of keyword is returned the same
1866
- 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
+
1867
2214
 
1868
2215
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-field-caps.html>`_
1869
2216
 
1870
- :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
1871
2218
  to limit the request. Supports wildcards (*). To target all data streams
1872
2219
  and indices, omit this parameter or use * or _all.
1873
2220
  :param allow_no_indices: If false, the request returns an error if any wildcard
@@ -1875,25 +2222,32 @@ class AsyncElasticsearch(BaseClient):
1875
2222
  This behavior applies even if the request targets other open indices. For
1876
2223
  example, a request targeting `foo*,bar*` returns an error if an index starts
1877
2224
  with foo but no index starts with bar.
1878
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
1879
- request can target data streams, this argument determines whether wildcard
1880
- expressions match hidden data streams. Supports comma-separated values, such
1881
- as `open,hidden`.
1882
- :param fields: List of fields to retrieve capabilities for. Wildcard (`*`) expressions
1883
- are supported.
1884
- :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.
1885
2232
  :param ignore_unavailable: If `true`, missing or closed indices are not included
1886
2233
  in the response.
1887
2234
  :param include_empty_fields: If false, empty fields are not included in the response.
1888
2235
  :param include_unmapped: If true, unmapped fields are included in the response.
1889
- :param index_filter: Allows to filter indices if the provided query rewrites
1890
- to match_none on every shard.
1891
- :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
1892
2245
  to the way it is done in search requests. These fields exist only as part
1893
2246
  of the query and take precedence over fields defined with the same name in
1894
2247
  the index mappings.
1895
- :param types: Only return results for fields that have one of the types in the
1896
- 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.
1897
2251
  """
1898
2252
  __path_parts: t.Dict[str, str]
1899
2253
  if index not in SKIP_IN_PATH:
@@ -1979,36 +2333,87 @@ class AsyncElasticsearch(BaseClient):
1979
2333
  ] = None,
1980
2334
  ) -> ObjectApiResponse[t.Any]:
1981
2335
  """
1982
- Get a document by its ID. Retrieves the document with the specified ID from an
1983
- 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
+
1984
2375
 
1985
2376
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1986
2377
 
1987
- :param index: Name of the index that contains the document.
1988
- :param id: Unique identifier of the document.
1989
- :param force_synthetic_source: Should this request force synthetic _source? Use
1990
- this to test if the mapping supports synthetic _source and to get a sense
1991
- of the worst case performance. Fetches with this enabled will be slower the
1992
- enabling synthetic source natively in the index.
1993
- :param preference: Specifies the node or shard the operation should be performed
1994
- 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.
1995
2392
  :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1996
- :param refresh: If true, Elasticsearch refreshes the affected shards to make
1997
- this operation visible to search. If false, do nothing with refreshes.
1998
- :param routing: Target the specified primary shard.
1999
- :param source: True or false to return the _source field or not, or a list of
2000
- fields to return.
2001
- :param source_excludes: A comma-separated list of source fields to exclude in
2002
- 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.
2003
2404
  :param source_includes: A comma-separated list of source fields to include in
2004
- the response.
2005
- :param stored_fields: List of stored fields to return as part of a hit. If no
2006
- fields are specified, no stored fields are included in the response. If this
2007
- field is specified, the `_source` parameter defaults to false.
2008
- :param version: Explicit version number for concurrency control. The specified
2009
- version must match the current version of the document for the request to
2010
- succeed.
2011
- :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.
2012
2417
  """
2013
2418
  if index in SKIP_IN_PATH:
2014
2419
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2069,12 +2474,19 @@ class AsyncElasticsearch(BaseClient):
2069
2474
  pretty: t.Optional[bool] = None,
2070
2475
  ) -> ObjectApiResponse[t.Any]:
2071
2476
  """
2072
- 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
+
2073
2482
 
2074
2483
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2075
2484
 
2076
- :param id: Identifier for the stored script or search template.
2077
- :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.
2078
2490
  """
2079
2491
  if id in SKIP_IN_PATH:
2080
2492
  raise ValueError("Empty value passed for parameter 'id'")
@@ -2111,9 +2523,13 @@ class AsyncElasticsearch(BaseClient):
2111
2523
  pretty: t.Optional[bool] = None,
2112
2524
  ) -> ObjectApiResponse[t.Any]:
2113
2525
  """
2114
- 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
+
2115
2531
 
2116
- `<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>`_
2117
2533
  """
2118
2534
  __path_parts: t.Dict[str, str] = {}
2119
2535
  __path = "/_script_context"
@@ -2146,9 +2562,13 @@ class AsyncElasticsearch(BaseClient):
2146
2562
  pretty: t.Optional[bool] = None,
2147
2563
  ) -> ObjectApiResponse[t.Any]:
2148
2564
  """
2149
- Get script languages. Get a list of available script types, languages, and contexts.
2565
+ .. raw:: html
2150
2566
 
2151
- `<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>`_
2152
2572
  """
2153
2573
  __path_parts: t.Dict[str, str] = {}
2154
2574
  __path = "/_script_language"
@@ -2201,29 +2621,41 @@ class AsyncElasticsearch(BaseClient):
2201
2621
  ] = None,
2202
2622
  ) -> ObjectApiResponse[t.Any]:
2203
2623
  """
2204
- 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
+
2205
2635
 
2206
2636
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
2207
2637
 
2208
- :param index: Name of the index that contains the document.
2209
- :param id: Unique identifier of the document.
2210
- :param preference: Specifies the node or shard the operation should be performed
2211
- on. Random by default.
2212
- :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time.
2213
- :param refresh: If true, Elasticsearch refreshes the affected shards to make
2214
- this operation visible to search. If false, do nothing with refreshes.
2215
- :param routing: Target the specified primary shard.
2216
- :param source: True or false to return the _source field or not, or a list of
2217
- 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.
2218
2650
  :param source_excludes: A comma-separated list of source fields to exclude in
2219
2651
  the response.
2220
2652
  :param source_includes: A comma-separated list of source fields to include in
2221
2653
  the response.
2222
- :param stored_fields:
2223
- :param version: Explicit version number for concurrency control. The specified
2224
- version must match the current version of the document for the request to
2225
- succeed.
2226
- :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.
2227
2659
  """
2228
2660
  if index in SKIP_IN_PATH:
2229
2661
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2284,26 +2716,22 @@ class AsyncElasticsearch(BaseClient):
2284
2716
  verbose: t.Optional[bool] = None,
2285
2717
  ) -> ObjectApiResponse[t.Any]:
2286
2718
  """
2287
- Get the cluster health. Get a report with the health status of an Elasticsearch
2288
- cluster. The report contains a list of indicators that compose Elasticsearch
2289
- functionality. Each indicator has a health status of: green, unknown, yellow
2290
- or red. The indicator will provide an explanation and metadata describing the
2291
- reason for its current health status. The cluster’s status is controlled by the
2292
- worst indicator status. In the event that an indicator’s status is non-green,
2293
- a list of impacts may be present in the indicator result which detail the functionalities
2294
- that are negatively affected by the health issue. Each impact carries with it
2295
- a severity level, an area of the system that is affected, and a simple description
2296
- of the impact on the system. Some health indicators can determine the root cause
2297
- of a health problem and prescribe a set of steps that can be performed in order
2298
- to improve the health of the system. The root cause and remediation steps are
2299
- encapsulated in a diagnosis. A diagnosis contains a cause detailing a root cause
2300
- analysis, an action containing a brief description of the steps to take to fix
2301
- the problem, the list of affected resources (if applicable), and a detailed step-by-step
2302
- troubleshooting guide to fix the diagnosed problem. NOTE: The health indicators
2303
- perform root cause analysis of non-green health statuses. This can be computationally
2304
- expensive when called frequently. When setting up automated polling of the API
2305
- for health status, set verbose to false to disable the more expensive analysis
2306
- 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
+
2307
2735
 
2308
2736
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/health-api.html>`_
2309
2737
 
@@ -2378,44 +2806,148 @@ class AsyncElasticsearch(BaseClient):
2378
2806
  ] = None,
2379
2807
  ) -> ObjectApiResponse[t.Any]:
2380
2808
  """
2381
- Index a document. Adds a JSON document to the specified data stream or index
2382
- and makes it searchable. If the target is an index and the document already exists,
2383
- 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
+
2384
2901
 
2385
2902
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
2386
2903
 
2387
- :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.
2388
2910
  :param document:
2389
- :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.
2390
2914
  :param if_primary_term: Only perform the operation if the document has this primary
2391
2915
  term.
2392
2916
  :param if_seq_no: Only perform the operation if the document has this sequence
2393
2917
  number.
2394
- :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
2395
2919
  exist (put if absent). If a document with the specified `_id` already exists,
2396
- the indexing operation will fail. Same as using the `<index>/_create` endpoint.
2397
- Valid values: `index`, `create`. If document id is specified, it defaults
2398
- to `index`. Otherwise, it defaults to `create`.
2399
- :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.
2400
2925
  If the index has a default ingest pipeline specified, then setting the value
2401
2926
  to `_none` disables the default ingest pipeline for this request. If a final
2402
2927
  pipeline is configured it will always run, regardless of the value of this
2403
2928
  parameter.
2404
2929
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
2405
- this operation visible to search, if `wait_for` then wait for a refresh to
2406
- make this operation visible to search, if `false` do nothing with refreshes.
2407
- 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.
2408
2932
  :param require_alias: If `true`, the destination must be an index alias.
2409
- :param routing: Custom value used to route operations to a specific shard.
2410
- :param timeout: Period the request waits for the following operations: automatic
2411
- index creation, dynamic mapping updates, waiting for active shards.
2412
- :param version: Explicit version number for concurrency control. The specified
2413
- version must match the current version of the document for the request to
2414
- succeed.
2415
- :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.
2416
2947
  :param wait_for_active_shards: The number of shard copies that must be active
2417
- before proceeding with the operation. Set to all or any positive integer
2418
- 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.
2419
2951
  """
2420
2952
  if index in SKIP_IN_PATH:
2421
2953
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2489,9 +3021,13 @@ class AsyncElasticsearch(BaseClient):
2489
3021
  pretty: t.Optional[bool] = None,
2490
3022
  ) -> ObjectApiResponse[t.Any]:
2491
3023
  """
2492
- Get cluster info. Returns basic information about the cluster.
3024
+ .. raw:: html
3025
+
3026
+ <p>Get cluster info.
3027
+ Get basic build, version, and cluster information.</p>
3028
+
2493
3029
 
2494
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/index.html>`_
3030
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/rest-api-root.html>`_
2495
3031
  """
2496
3032
  __path_parts: t.Dict[str, str] = {}
2497
3033
  __path = "/"
@@ -2546,38 +3082,48 @@ class AsyncElasticsearch(BaseClient):
2546
3082
  body: t.Optional[t.Dict[str, t.Any]] = None,
2547
3083
  ) -> ObjectApiResponse[t.Any]:
2548
3084
  """
2549
- Run a knn search. NOTE: The kNN search API has been replaced by the `knn` option
2550
- in the search API. Perform a k-nearest neighbor (kNN) search on a dense_vector
2551
- field and return the matching documents. Given a query vector, the API finds
2552
- the k closest vectors and returns those documents as search hits. Elasticsearch
2553
- uses the HNSW algorithm to support efficient kNN search. Like most kNN algorithms,
2554
- HNSW is an approximate method that sacrifices result accuracy for improved search
2555
- speed. This means the results returned are not always the true k closest neighbors.
2556
- The kNN search API supports restricting the search using a filter. The search
2557
- will return the top k documents that also match the filter query.
2558
-
2559
- `<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>`_
2560
3105
 
2561
3106
  :param index: A comma-separated list of index names to search; use `_all` or
2562
- to perform the operation on all indices
2563
- :param knn: kNN query to execute
3107
+ to perform the operation on all indices.
3108
+ :param knn: The kNN query to run.
2564
3109
  :param docvalue_fields: The request returns doc values for field names matching
2565
- these patterns in the hits.fields property of the response. Accepts wildcard
2566
- (*) patterns.
3110
+ these patterns in the `hits.fields` property of the response. It accepts
3111
+ wildcard (`*`) patterns.
2567
3112
  :param fields: The request returns values for field names matching these patterns
2568
- in the hits.fields property of the response. Accepts wildcard (*) patterns.
2569
- :param filter: Query to filter the documents that can match. The kNN search will
2570
- return the top `k` documents that also match this filter. The value can be
2571
- a single query or a list of queries. If `filter` isn't provided, all documents
2572
- are allowed to match.
2573
- :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.
2574
3120
  :param source: Indicates which source fields are returned for matching documents.
2575
- These fields are returned in the hits._source property of the search response.
2576
- :param stored_fields: List of stored fields to return as part of a hit. If no
2577
- fields are specified, no stored fields are included in the response. If this
2578
- field is specified, the _source parameter defaults to false. You can pass
2579
- _source: true to return both source fields and stored fields in the search
2580
- 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.
2581
3127
  """
2582
3128
  if index in SKIP_IN_PATH:
2583
3129
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2655,10 +3201,21 @@ class AsyncElasticsearch(BaseClient):
2655
3201
  body: t.Optional[t.Dict[str, t.Any]] = None,
2656
3202
  ) -> ObjectApiResponse[t.Any]:
2657
3203
  """
2658
- Get multiple documents. Get multiple JSON documents by ID from one or more indices.
2659
- If you specify an index in the request URI, you only need to specify the document
2660
- IDs in the request body. To ensure fast responses, this multi get (mget) API
2661
- 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
+
2662
3219
 
2663
3220
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-get.html>`_
2664
3221
 
@@ -2779,13 +3336,21 @@ class AsyncElasticsearch(BaseClient):
2779
3336
  typed_keys: t.Optional[bool] = None,
2780
3337
  ) -> ObjectApiResponse[t.Any]:
2781
3338
  """
2782
- Run multiple searches. The format of the request is similar to the bulk API format
2783
- and makes use of the newline delimited JSON (NDJSON) format. The structure is
2784
- as follows: ``` header\\n body\\n header\\n body\\n ``` This structure is specifically
2785
- optimized to reduce parsing if a specific search ends up redirected to another
2786
- node. IMPORTANT: The final line of data must end with a newline character `\\n`.
2787
- Each newline character may be preceded by a carriage return `\\r`. When sending
2788
- 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
+
2789
3354
 
2790
3355
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
2791
3356
 
@@ -2917,22 +3482,35 @@ class AsyncElasticsearch(BaseClient):
2917
3482
  typed_keys: t.Optional[bool] = None,
2918
3483
  ) -> ObjectApiResponse[t.Any]:
2919
3484
  """
2920
- Run multiple templated searches.
3485
+ .. raw:: html
3486
+
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>
2921
3499
 
2922
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
3500
+
3501
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/multi-search-template.html>`_
2923
3502
 
2924
3503
  :param search_templates:
2925
- :param index: Comma-separated list of data streams, indices, and aliases to search.
2926
- Supports wildcards (`*`). To search all data streams and indices, omit this
2927
- 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 `*`.
2928
3507
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
2929
3508
  for cross-cluster search requests.
2930
- :param max_concurrent_searches: Maximum number of concurrent searches the API
2931
- can run.
3509
+ :param max_concurrent_searches: The maximum number of concurrent searches the
3510
+ API can run.
2932
3511
  :param rest_total_hits_as_int: If `true`, the response returns `hits.total` as
2933
3512
  an integer. If `false`, it returns `hits.total` as an object.
2934
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
2935
- `dfs_query_then_fetch`.
3513
+ :param search_type: The type of the search operation.
2936
3514
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
2937
3515
  names with their respective types.
2938
3516
  """
@@ -3012,34 +3590,41 @@ class AsyncElasticsearch(BaseClient):
3012
3590
  body: t.Optional[t.Dict[str, t.Any]] = None,
3013
3591
  ) -> ObjectApiResponse[t.Any]:
3014
3592
  """
3015
- Get multiple term vectors. You can specify existing documents by index and ID
3016
- or provide artificial documents in the body of the request. You can specify the
3017
- index in the request body or request URI. The response contains a `docs` array
3018
- with all the fetched termvectors. Each element has the structure provided by
3019
- 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
+
3020
3605
 
3021
3606
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-termvectors.html>`_
3022
3607
 
3023
- :param index: Name of the index that contains the documents.
3024
- :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.
3025
3610
  :param field_statistics: If `true`, the response includes the document count,
3026
3611
  sum of document frequencies, and sum of total term frequencies.
3027
- :param fields: Comma-separated list or wildcard expressions of fields to include
3028
- in the statistics. Used as the default list unless a specific field list
3029
- is provided in the `completion_fields` or `fielddata_fields` parameters.
3030
- :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
3031
3616
  the same index.
3032
3617
  :param offsets: If `true`, the response includes term offsets.
3033
3618
  :param payloads: If `true`, the response includes term payloads.
3034
3619
  :param positions: If `true`, the response includes term positions.
3035
- :param preference: Specifies the node or shard the operation should be performed
3036
- on. Random by default.
3620
+ :param preference: The node or shard the operation should be performed on. It
3621
+ is random by default.
3037
3622
  :param realtime: If true, the request is real-time as opposed to near-real-time.
3038
- :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.
3039
3624
  :param term_statistics: If true, the response includes term frequency and document
3040
3625
  frequency.
3041
3626
  :param version: If `true`, returns the document version as part of a hit.
3042
- :param version_type: Specific version type.
3627
+ :param version_type: The version type.
3043
3628
  """
3044
3629
  __path_parts: t.Dict[str, str]
3045
3630
  if index not in SKIP_IN_PATH:
@@ -3128,36 +3713,59 @@ class AsyncElasticsearch(BaseClient):
3128
3713
  body: t.Optional[t.Dict[str, t.Any]] = None,
3129
3714
  ) -> ObjectApiResponse[t.Any]:
3130
3715
  """
3131
- Open a point in time. A search request by default runs against the most recent
3132
- visible data of the target indices, which is called point in time. Elasticsearch
3133
- pit (point in time) is a lightweight view into the state of the data as it existed
3134
- when initiated. In some cases, it’s preferred to perform multiple search requests
3135
- using the same point in time. For example, if refreshes happen between `search_after`
3136
- requests, then the results of those requests might not be consistent as changes
3137
- happening between searches are only visible to the more recent point in time.
3138
- A point in time must be opened explicitly before being used in search requests.
3139
- 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
+
3140
3745
 
3141
3746
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
3142
3747
 
3143
3748
  :param index: A comma-separated list of index names to open point in time; use
3144
3749
  `_all` or empty string to perform the operation on all indices
3145
- :param keep_alive: Extends the time to live of the corresponding point in time.
3146
- :param allow_partial_search_results: If `false`, creating a point in time request
3147
- when a shard is missing or unavailable will throw an exception. If `true`,
3148
- the point in time will contain all the shards that are available at the time
3149
- of the request.
3150
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
3151
- request can target data streams, this argument determines whether wildcard
3152
- expressions match hidden data streams. Supports comma-separated values, such
3153
- 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`.
3154
3761
  :param ignore_unavailable: If `false`, the request returns an error if it targets
3155
3762
  a missing or closed index.
3156
- :param index_filter: Allows to filter indices if the provided query rewrites
3157
- to `match_none` on every shard.
3158
- :param preference: Specifies the node or shard the operation should be performed
3159
- on. Random by default.
3160
- :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.
3161
3769
  """
3162
3770
  if index in SKIP_IN_PATH:
3163
3771
  raise ValueError("Empty value passed for parameter 'index'")
@@ -3223,23 +3831,27 @@ class AsyncElasticsearch(BaseClient):
3223
3831
  body: t.Optional[t.Dict[str, t.Any]] = None,
3224
3832
  ) -> ObjectApiResponse[t.Any]:
3225
3833
  """
3226
- Create or update a script or search template. Creates or updates a stored script
3227
- or search template.
3228
-
3229
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
3230
-
3231
- :param id: Identifier for the stored script or search template. Must be unique
3232
- within the cluster.
3233
- :param script: Contains the script or search template, its parameters, and its
3234
- language.
3235
- :param context: Context in which the script or search template should run. To
3236
- prevent errors, the API immediately compiles the script or template in this
3237
- context.
3238
- :param master_timeout: Period to wait for a connection to the master node. If
3239
- no response is received before the timeout expires, the request fails and
3240
- returns an error.
3241
- :param timeout: Period to wait for a response. If no response is received before
3242
- 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.
3243
3855
  """
3244
3856
  if id in SKIP_IN_PATH:
3245
3857
  raise ValueError("Empty value passed for parameter 'id'")
@@ -3309,14 +3921,17 @@ class AsyncElasticsearch(BaseClient):
3309
3921
  body: t.Optional[t.Dict[str, t.Any]] = None,
3310
3922
  ) -> ObjectApiResponse[t.Any]:
3311
3923
  """
3312
- Evaluate ranked search results. Evaluate the quality of ranked search results
3313
- 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
+
3314
3929
 
3315
3930
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-rank-eval.html>`_
3316
3931
 
3317
3932
  :param requests: A set of typical search requests, together with their provided
3318
3933
  ratings.
3319
- :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
3320
3935
  used to limit the request. Wildcard (`*`) expressions are supported. To target
3321
3936
  all data streams and indices in a cluster, omit this parameter or use `_all`
3322
3937
  or `*`.
@@ -3404,33 +4019,187 @@ class AsyncElasticsearch(BaseClient):
3404
4019
  body: t.Optional[t.Dict[str, t.Any]] = None,
3405
4020
  ) -> ObjectApiResponse[t.Any]:
3406
4021
  """
3407
- Reindex documents. Copies documents from a source to a destination. The source
3408
- can be any existing index, alias, or data stream. The destination must differ
3409
- 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
+
3410
4161
 
3411
4162
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3412
4163
 
3413
4164
  :param dest: The destination you are copying to.
3414
4165
  :param source: The source you are copying from.
3415
- :param conflicts: Set to proceed to continue reindexing even if there are conflicts.
3416
- :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.
3417
4175
  :param refresh: If `true`, the request refreshes affected shards to make this
3418
4176
  operation visible to search.
3419
4177
  :param requests_per_second: The throttle for this request in sub-requests per
3420
- second. Defaults to no throttle.
4178
+ second. By default, there is no throttle.
3421
4179
  :param require_alias: If `true`, the destination must be an index alias.
3422
4180
  :param script: The script to run to update the document source or metadata when
3423
4181
  reindexing.
3424
- :param scroll: Specifies how long a consistent view of the index should be maintained
3425
- for scrolled search.
4182
+ :param scroll: The period of time that a consistent view of the index should
4183
+ be maintained for scrolled search.
3426
4184
  :param size:
3427
- :param slices: The number of slices this task should be divided into. Defaults
3428
- to 1 slice, meaning the task isnt sliced into subtasks.
3429
- :param timeout: Period each indexing waits for automatic index creation, dynamic
3430
- 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.
3431
4199
  :param wait_for_active_shards: The number of shard copies that must be active
3432
- before proceeding with the operation. Set to `all` or any positive integer
3433
- 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.
3434
4203
  :param wait_for_completion: If `true`, the request blocks until the operation
3435
4204
  is complete.
3436
4205
  """
@@ -3502,14 +4271,24 @@ class AsyncElasticsearch(BaseClient):
3502
4271
  requests_per_second: t.Optional[float] = None,
3503
4272
  ) -> ObjectApiResponse[t.Any]:
3504
4273
  """
3505
- Throttle a reindex operation. Change the number of requests per second for a
3506
- 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
+
3507
4285
 
3508
4286
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3509
4287
 
3510
- :param task_id: Identifier for the task.
4288
+ :param task_id: The task identifier, which can be found by using the tasks API.
3511
4289
  :param requests_per_second: The throttle for this request in sub-requests per
3512
- 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.
3513
4292
  """
3514
4293
  if task_id in SKIP_IN_PATH:
3515
4294
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -3554,17 +4333,21 @@ class AsyncElasticsearch(BaseClient):
3554
4333
  body: t.Optional[t.Dict[str, t.Any]] = None,
3555
4334
  ) -> ObjectApiResponse[t.Any]:
3556
4335
  """
3557
- 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
+
3558
4341
 
3559
4342
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/render-search-template-api.html>`_
3560
4343
 
3561
- :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,
3562
4345
  this or the `id` request body parameter is required.
3563
4346
  :param file:
3564
4347
  :param params: Key-value pairs used to replace Mustache variables in the template.
3565
4348
  The key is the variable name. The value is the variable value.
3566
- :param source: An inline search template. Supports the same parameters as the
3567
- 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.
3568
4351
  If no `id` or `<templated-id>` is specified, this parameter is required.
3569
4352
  """
3570
4353
  __path_parts: t.Dict[str, str]
@@ -3623,7 +4406,11 @@ class AsyncElasticsearch(BaseClient):
3623
4406
  body: t.Optional[t.Dict[str, t.Any]] = None,
3624
4407
  ) -> ObjectApiResponse[t.Any]:
3625
4408
  """
3626
- 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
+
3627
4414
 
3628
4415
  `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-execute-api.html>`_
3629
4416
 
@@ -3681,30 +4468,27 @@ class AsyncElasticsearch(BaseClient):
3681
4468
  body: t.Optional[t.Dict[str, t.Any]] = None,
3682
4469
  ) -> ObjectApiResponse[t.Any]:
3683
4470
  """
3684
- Run a scrolling search. IMPORTANT: The scroll API is no longer recommend for
3685
- deep pagination. If you need to preserve the index state while paging through
3686
- more than 10,000 hits, use the `search_after` parameter with a point in time
3687
- (PIT). The scroll API gets large sets of results from a single scrolling search
3688
- request. To get the necessary scroll ID, submit a search API request that includes
3689
- an argument for the `scroll` query parameter. The `scroll` parameter indicates
3690
- how long Elasticsearch should retain the search context for the request. The
3691
- search response returns a scroll ID in the `_scroll_id` response body parameter.
3692
- You can then use the scroll ID with the scroll API to retrieve the next batch
3693
- of results for the request. If the Elasticsearch security features are enabled,
3694
- the access to the results of a specific scroll ID is restricted to the user or
3695
- API key that submitted the search. You can also use the scroll API to specify
3696
- a new scroll parameter that extends or shortens the retention period for the
3697
- search context. IMPORTANT: Results from a scrolling search reflect the state
3698
- of the index at the time of the initial search request. Subsequent indexing or
3699
- document changes only affect later search and scroll requests.
3700
-
3701
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-request-body.html#request-body-search-scroll>`_
3702
-
3703
- :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.
3704
4488
  :param rest_total_hits_as_int: If true, the API response’s hit.total property
3705
4489
  is returned as an integer. If false, the API response’s hit.total property
3706
4490
  is returned as an object.
3707
- :param scroll: Period to retain the search context for scrolling.
4491
+ :param scroll: The period to retain the search context for scrolling.
3708
4492
  """
3709
4493
  if scroll_id is None and body is None:
3710
4494
  raise ValueError("Empty value passed for parameter 'scroll_id'")
@@ -3886,15 +4670,29 @@ class AsyncElasticsearch(BaseClient):
3886
4670
  body: t.Optional[t.Dict[str, t.Any]] = None,
3887
4671
  ) -> ObjectApiResponse[t.Any]:
3888
4672
  """
3889
- Run a search. Get search hits that match the query defined in the request. You
3890
- can provide search queries using the `q` query string parameter or the request
3891
- 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
+
3892
4690
 
3893
4691
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
3894
4692
 
3895
- :param index: Comma-separated list of data streams, indices, and aliases to search.
3896
- Supports wildcards (`*`). To search all data streams and indices, omit this
3897
- 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`.
3898
4696
  :param aggregations: Defines the aggregations that are run as part of the search
3899
4697
  request.
3900
4698
  :param aggs: Defines the aggregations that are run as part of the search request.
@@ -3903,45 +4701,46 @@ class AsyncElasticsearch(BaseClient):
3903
4701
  This behavior applies even if the request targets other open indices. For
3904
4702
  example, a request targeting `foo*,bar*` returns an error if an index starts
3905
4703
  with `foo` but no index starts with `bar`.
3906
- :param allow_partial_search_results: If true, returns partial results if there
3907
- are shard request timeouts or shard failures. If false, returns an error
3908
- with no partial results.
3909
- :param analyze_wildcard: If true, wildcard and prefix queries are analyzed. This
3910
- parameter can only be used when the q query string parameter is specified.
3911
- :param analyzer: Analyzer to use for the query string. This parameter can only
3912
- 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.
3913
4712
  :param batched_reduce_size: The number of shard results that should be reduced
3914
- at once on the coordinating node. This value should be used as a protection
3915
- mechanism to reduce the memory overhead per search request if the potential
3916
- number of shards in the request can be large.
3917
- :param ccs_minimize_roundtrips: If true, network round-trips between the coordinating
3918
- 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
3919
4718
  (CCS) requests.
3920
4719
  :param collapse: Collapses search results the values of the specified field.
3921
- :param default_operator: The default operator for query string query: AND or
3922
- OR. This parameter can only be used when the `q` query string parameter is
3923
- specified.
3924
- :param df: Field to use as default where no field prefix is given in the query
3925
- 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
3926
4722
  is specified.
3927
- :param docvalue_fields: Array of wildcard (`*`) patterns. The request returns
3928
- doc values for field names matching these patterns in the `hits.fields` property
3929
- of the response.
3930
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
3931
- request can target data streams, this argument determines whether wildcard
3932
- expressions match hidden data streams. Supports comma-separated values, such
3933
- as `open,hidden`.
3934
- :param explain: If true, returns detailed information about score computation
3935
- 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.
3936
4735
  :param ext: Configuration of search extensions defined by Elasticsearch plugins.
3937
- :param fields: Array of wildcard (`*`) patterns. The request returns values for
3938
- field names matching these patterns in the `hits.fields` property of the
3939
- 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.
3940
4739
  :param force_synthetic_source: Should this request force synthetic _source? Use
3941
4740
  this to test if the mapping supports synthetic _source and to get a sense
3942
4741
  of the worst case performance. Fetches with this enabled will be slower the
3943
4742
  enabling synthetic source natively in the index.
3944
- :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,
3945
4744
  you cannot page through more than 10,000 hits using the `from` and `size`
3946
4745
  parameters. To page through more hits, use the `search_after` parameter.
3947
4746
  :param highlight: Specifies the highlighter to use for retrieving highlighted
@@ -3950,95 +4749,101 @@ class AsyncElasticsearch(BaseClient):
3950
4749
  be ignored when frozen.
3951
4750
  :param ignore_unavailable: If `false`, the request returns an error if it targets
3952
4751
  a missing or closed index.
3953
- :param include_named_queries_score: Indicates whether hit.matched_queries should
3954
- be rendered as a map that includes the name of the matched query associated
3955
- with its score (true) or as an array containing the name of the matched queries
3956
- (false) This functionality reruns each named query on every hit in a search
3957
- response. Typically, this adds a small overhead to a request. However, using
3958
- computationally expensive named queries on a large number of hits may add
3959
- significant overhead.
3960
- :param indices_boost: Boosts the _score of documents from specified indices.
3961
- :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.
3962
4762
  :param lenient: If `true`, format-based query failures (such as providing text
3963
4763
  to a numeric field) in the query string will be ignored. This parameter can
3964
- only be used when the `q` query string parameter is specified.
3965
- :param max_concurrent_shard_requests: Defines the number of concurrent shard
3966
- requests per node this search executes concurrently. This value should be
3967
- used to limit the impact of the search on the cluster in order to limit the
3968
- 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.
3969
4769
  :param min_compatible_shard_node: The minimum version of the node that can handle
3970
- the request Any handling node with a lower version will fail the request.
3971
- :param min_score: Minimum `_score` for matching documents. Documents with a lower
3972
- `_score` are not included in the search results.
3973
- :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,
3974
4774
  you cannot specify an `<index>` in the request path.
3975
4775
  :param post_filter: Use the `post_filter` parameter to filter search results.
3976
4776
  The search hits are filtered after the aggregations are calculated. A post
3977
4777
  filter has no impact on the aggregation results.
3978
- :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
3979
- roundtrip to prefilter search shards based on query rewriting if the number
3980
- of shards the search request expands to exceeds the threshold. This filter
3981
- roundtrip can limit the number of shards significantly if for instance a
3982
- shard can not match any documents based on its rewrite method (if date filters
3983
- are mandatory to match but the shard bounds and the query are disjoint).
3984
- When unspecified, the pre-filter phase is executed if any of these conditions
3985
- is met: the request targets more than 128 shards; the request targets one
3986
- 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
3987
4787
  field.
3988
- :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
3989
4789
  selects from eligible nodes and shards using adaptive replica selection,
3990
- accounting for allocation awareness. Valid values are: `_only_local` to run
3991
- the search only on shards on the local node; `_local` to, if possible, run
3992
- the search on shards on the local node, or if not, select shards using the
3993
- default method; `_only_nodes:<node-id>,<node-id>` to run the search on only
3994
- the specified nodes IDs, where, if suitable shards exist on more than one
3995
- selected node, use shards on those nodes using the default method, or if
3996
- none of the specified nodes are available, select shards from any available
3997
- 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
3998
4798
  possible, run the search on the specified nodes IDs, or if not, select shards
3999
- using the default method; `_shards:<shard>,<shard>` to run the search only
4000
- 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
4001
4801
  with `_`) to route searches with the same `<custom-string>` to the same shards
4002
4802
  in the same order.
4003
4803
  :param profile: Set to `true` to return detailed timing information about the
4004
4804
  execution of individual components in a search request. NOTE: This is a debugging
4005
4805
  tool and adds significant overhead to search execution.
4006
- :param q: Query in the Lucene query string syntax using query parameter search.
4007
- Query parameter searches do not support the full Elasticsearch Query DSL
4008
- but are handy for testing.
4009
- :param query: Defines the search definition using the Query DSL.
4010
- :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.
4011
4813
  :param request_cache: If `true`, the caching of search results is enabled for
4012
- requests where `size` is `0`. Defaults to index level settings.
4814
+ requests where `size` is `0`. It defaults to index level settings.
4013
4815
  :param rescore: Can be used to improve precision by reordering just the top (for
4014
4816
  example 100 - 500) documents returned by the `query` and `post_filter` phases.
4015
4817
  :param rest_total_hits_as_int: Indicates whether `hits.total` should be rendered
4016
4818
  as an integer or an object in the rest search response.
4017
4819
  :param retriever: A retriever is a specification to describe top documents returned
4018
4820
  from a search. A retriever replaces other elements of the search API that
4019
- also return top documents such as query and knn.
4020
- :param routing: Custom value used to route operations to a specific shard.
4021
- :param runtime_mappings: Defines one or more runtime fields in the search request.
4022
- 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.
4023
4826
  :param script_fields: Retrieve a script evaluation (based on different fields)
4024
4827
  for each hit.
4025
- :param scroll: Period to retain the search context for scrolling. See Scroll
4026
- search results. By default, this value cannot exceed `1d` (24 hours). You
4027
- 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.
4028
4831
  :param search_after: Used to retrieve the next page of hits using a set of sort
4029
4832
  values from the previous page.
4030
- :param search_type: How distributed term frequencies are calculated for relevance
4031
- scoring.
4032
- :param seq_no_primary_term: If `true`, returns sequence number and primary term
4033
- of the last modification of each hit.
4034
- :param size: The number of hits to return. By default, you cannot page through
4035
- more than 10,000 hits using the `from` and `size` parameters. To page through
4036
- more hits, use the `search_after` parameter.
4037
- :param slice: Can be used to split a scrolled search into multiple slices that
4038
- 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.
4039
4842
  :param sort: A comma-separated list of <field>:<direction> pairs.
4040
- :param source: Indicates which source fields are returned for matching documents.
4041
- 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`.
4042
4847
  :param source_excludes: A comma-separated list of source fields to exclude from
4043
4848
  the response. You can also use this parameter to exclude fields from the
4044
4849
  subset specified in `_source_includes` query parameter. If the `_source`
@@ -4048,45 +4853,46 @@ class AsyncElasticsearch(BaseClient):
4048
4853
  returned. You can exclude fields from this subset using the `_source_excludes`
4049
4854
  query parameter. If the `_source` parameter is `false`, this parameter is
4050
4855
  ignored.
4051
- :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
4052
4857
  a statistics aggregation for its associated searches. You can retrieve these
4053
4858
  stats using the indices stats API.
4054
- :param stored_fields: List of stored fields to return as part of a hit. If no
4055
- fields are specified, no stored fields are included in the response. If this
4056
- field is specified, the `_source` parameter defaults to `false`. You can
4057
- pass `_source: true` to return both source fields and stored fields in the
4058
- 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.
4059
4864
  :param suggest: Defines a suggester that provides similar looking terms based
4060
4865
  on a provided text.
4061
- :param suggest_field: Specifies which field to use for suggestions.
4062
- :param suggest_mode: Specifies the suggest mode. This parameter can only be used
4063
- when the `suggest_field` and `suggest_text` query string parameters are specified.
4064
- :param suggest_size: Number of suggestions to return. This parameter can only
4065
- 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
4066
4871
  are specified.
4067
4872
  :param suggest_text: The source text for which the suggestions should be returned.
4068
- 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`
4069
4874
  query string parameters are specified.
4070
- :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.
4071
4876
  If a query reaches this limit, Elasticsearch terminates the query early.
4072
- Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
4073
- applies this parameter to each shard handling the request. When possible,
4074
- let Elasticsearch perform early termination automatically. Avoid specifying
4075
- this parameter for requests that target data streams with backing indices
4076
- across multiple data tiers. If set to `0` (default), the query does not terminate
4077
- early.
4078
- :param timeout: Specifies the period of time to wait for a response from each
4079
- shard. If no response is received before the timeout expires, the request
4080
- fails and returns an error. Defaults to no timeout.
4081
- :param track_scores: If true, calculate and return document scores, even if the
4082
- 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.
4083
4888
  :param track_total_hits: Number of hits matching the query to count accurately.
4084
4889
  If `true`, the exact number of hits is returned at the cost of some performance.
4085
4890
  If `false`, the response does not include the total number of hits matching
4086
4891
  the query.
4087
4892
  :param typed_keys: If `true`, aggregation and suggester names are be prefixed
4088
4893
  by their respective types in the response.
4089
- :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.
4090
4896
  """
4091
4897
  __path_parts: t.Dict[str, str]
4092
4898
  if index not in SKIP_IN_PATH:
@@ -4318,7 +5124,319 @@ class AsyncElasticsearch(BaseClient):
4318
5124
  body: t.Optional[t.Dict[str, t.Any]] = None,
4319
5125
  ) -> BinaryApiResponse:
4320
5126
  """
4321
- 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
+
4322
5440
 
4323
5441
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-vector-tile-api.html>`_
4324
5442
 
@@ -4327,43 +5445,55 @@ class AsyncElasticsearch(BaseClient):
4327
5445
  :param zoom: Zoom level for the vector tile to search
4328
5446
  :param x: X coordinate for the vector tile to search
4329
5447
  :param y: Y coordinate for the vector tile to search
4330
- :param aggs: Sub-aggregations for the geotile_grid. Supports the following aggregation
4331
- types: - avg - cardinality - max - min - sum
4332
- :param buffer: Size, in pixels, of a clipping buffer outside the tile. This allows
4333
- renderers to avoid outline artifacts from geometries that extend past the
4334
- extent of the tile.
4335
- :param exact_bounds: If false, the meta layer’s feature is the bounding box of
4336
- the tile. If true, the meta layer’s feature is a bounding box resulting from
4337
- a geo_bounds aggregation. The aggregation runs on <field> values that intersect
4338
- the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting bounding
4339
- box may be larger than the vector tile.
4340
- :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
4341
5462
  with equal sides.
4342
- :param fields: Fields to return in the `hits` layer. Supports wildcards (`*`).
4343
- This parameter does not support fields with array values. Fields with array
4344
- values may return inconsistent results.
4345
- :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`.
4346
5467
  :param grid_precision: Additional zoom levels available through the aggs layer.
4347
- For example, if <zoom> is 7 and grid_precision is 8, you can zoom in up to
4348
- 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.
4349
5470
  :param grid_type: Determines the geometry type for features in the aggs layer.
4350
- In the aggs layer, each feature represents a geotile_grid cell. If 'grid'
4351
- 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
4352
5473
  is a Point that is the centroid of the cell.
4353
- :param query: Query DSL used to filter documents for the search.
5474
+ :param query: The query DSL used to filter documents for the search.
4354
5475
  :param runtime_mappings: Defines one or more runtime fields in the search request.
4355
5476
  These fields take precedence over mapped fields with the same name.
4356
- :param size: Maximum number of features to return in the hits layer. Accepts
4357
- 0-10000. If 0, results dont include the hits layer.
4358
- :param sort: Sorts features in the hits layer. By default, the API calculates
4359
- 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
4360
5481
  length, from longest to shortest.
4361
- :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.
4362
5483
  If `true`, the exact number of hits is returned at the cost of some performance.
4363
5484
  If `false`, the response does not include the total number of hits matching
4364
5485
  the query.
4365
5486
  :param with_labels: If `true`, the hits and aggs layers will contain additional
4366
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`.
4367
5497
  """
4368
5498
  if index in SKIP_IN_PATH:
4369
5499
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4472,15 +5602,20 @@ class AsyncElasticsearch(BaseClient):
4472
5602
  routing: t.Optional[str] = None,
4473
5603
  ) -> ObjectApiResponse[t.Any]:
4474
5604
  """
4475
- Get the search shards. Get the indices and shards that a search request would
4476
- be run against. This information can be useful for working out issues or planning
4477
- optimizations with routing and shard preferences. When filtered aliases are used,
4478
- 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
+
4479
5613
 
4480
5614
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-shards.html>`_
4481
5615
 
4482
- :param index: Returns the indices and shards that a search request would be executed
4483
- 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`.
4484
5619
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4485
5620
  expression, index alias, or `_all` value targets only missing or closed indices.
4486
5621
  This behavior applies even if the request targets other open indices. For
@@ -4494,9 +5629,9 @@ class AsyncElasticsearch(BaseClient):
4494
5629
  a missing or closed index.
4495
5630
  :param local: If `true`, the request retrieves information from the local node
4496
5631
  only.
4497
- :param preference: Specifies the node or shard the operation should be performed
4498
- on. Random by default.
4499
- :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.
4500
5635
  """
4501
5636
  __path_parts: t.Dict[str, str]
4502
5637
  if index not in SKIP_IN_PATH:
@@ -4576,12 +5711,15 @@ class AsyncElasticsearch(BaseClient):
4576
5711
  body: t.Optional[t.Dict[str, t.Any]] = None,
4577
5712
  ) -> ObjectApiResponse[t.Any]:
4578
5713
  """
4579
- Run a search with a search template.
5714
+ .. raw:: html
5715
+
5716
+ <p>Run a search with a search template.</p>
4580
5717
 
4581
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-template.html>`_
4582
5718
 
4583
- :param index: Comma-separated list of data streams, indices, and aliases to search.
4584
- 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 (`*`).
4585
5723
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4586
5724
  expression, index alias, or `_all` value targets only missing or closed indices.
4587
5725
  This behavior applies even if the request targets other open indices. For
@@ -4589,32 +5727,34 @@ class AsyncElasticsearch(BaseClient):
4589
5727
  with `foo` but no index starts with `bar`.
4590
5728
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
4591
5729
  for cross-cluster search requests.
4592
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
4593
- request can target data streams, this argument determines whether wildcard
4594
- expressions match hidden data streams. Supports comma-separated values, such
4595
- 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`.
4596
5735
  :param explain: If `true`, returns detailed information about score calculation
4597
- as part of each hit.
4598
- :param id: ID of the search template to use. If no source is specified, this
4599
- 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.
4600
5740
  :param ignore_throttled: If `true`, specified concrete, expanded, or aliased
4601
5741
  indices are not included in the response when throttled.
4602
5742
  :param ignore_unavailable: If `false`, the request returns an error if it targets
4603
5743
  a missing or closed index.
4604
5744
  :param params: Key-value pairs used to replace Mustache variables in the template.
4605
5745
  The key is the variable name. The value is the variable value.
4606
- :param preference: Specifies the node or shard the operation should be performed
4607
- on. Random by default.
5746
+ :param preference: The node or shard the operation should be performed on. It
5747
+ is random by default.
4608
5748
  :param profile: If `true`, the query execution is profiled.
4609
- :param rest_total_hits_as_int: If true, hits.total are rendered as an integer
4610
- in the response.
4611
- :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.
4612
5752
  :param scroll: Specifies how long a consistent view of the index should be maintained
4613
5753
  for scrolled search.
4614
5754
  :param search_type: The type of the search operation.
4615
5755
  :param source: An inline search template. Supports the same parameters as the
4616
- search API's request body. Also supports Mustache variables. If no id is
4617
- 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.
4618
5758
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
4619
5759
  names with their respective types.
4620
5760
  """
@@ -4708,34 +5848,39 @@ class AsyncElasticsearch(BaseClient):
4708
5848
  body: t.Optional[t.Dict[str, t.Any]] = None,
4709
5849
  ) -> ObjectApiResponse[t.Any]:
4710
5850
  """
4711
- Get terms in an index. Discover terms that match a partial string in an index.
4712
- This "terms enum" API is designed for low-latency look-ups used in auto-complete
4713
- scenarios. If the `complete` property in the response is false, the returned
4714
- terms set may be incomplete and should be treated as approximate. This can occur
4715
- due to a few reasons, such as a request timeout or a node error. NOTE: The terms
4716
- enum API may return terms from deleted documents. Deleted documents are initially
4717
- only marked as deleted. It is not until their segments are merged that documents
4718
- are actually deleted. Until that happens, the terms enum API will return terms
4719
- 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
+
4720
5861
 
4721
5862
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-terms-enum.html>`_
4722
5863
 
4723
- :param index: Comma-separated list of data streams, indices, and index aliases
4724
- 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`.
4725
5867
  :param field: The string to match at the start of indexed terms. If not provided,
4726
5868
  all terms in the field are considered.
4727
- :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
4728
5870
  index terms without case sensitivity.
4729
- :param index_filter: Allows to filter an index shard if the provided query rewrites
4730
- to match_none.
4731
- :param search_after:
4732
- :param size: How many matching terms to return.
4733
- :param string: The string after which terms in the index should be returned.
4734
- Allows for a form of pagination if the last result from one request is passed
4735
- as the search_after parameter for a subsequent request.
4736
- :param timeout: The maximum length of time to spend collecting results. Defaults
4737
- to "1s" (one second). If the timeout is exceeded the complete flag set to
4738
- 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.
4739
5884
  """
4740
5885
  if index in SKIP_IN_PATH:
4741
5886
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4814,33 +5959,77 @@ class AsyncElasticsearch(BaseClient):
4814
5959
  body: t.Optional[t.Dict[str, t.Any]] = None,
4815
5960
  ) -> ObjectApiResponse[t.Any]:
4816
5961
  """
4817
- Get term vector information. Get information and statistics about terms in the
4818
- 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
+
4819
5997
 
4820
5998
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-termvectors.html>`_
4821
5999
 
4822
- :param index: Name of the index that contains the document.
4823
- :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.
4824
6002
  :param doc: An artificial document (a document not present in the index) for
4825
6003
  which you want to retrieve term vectors.
4826
- :param field_statistics: If `true`, the response includes the document count,
4827
- sum of document frequencies, and sum of total term frequencies.
4828
- :param fields: Comma-separated list or wildcard expressions of fields to include
4829
- in the statistics. Used as the default list unless a specific field list
4830
- is provided in the `completion_fields` or `fielddata_fields` parameters.
4831
- :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.
4832
6015
  :param offsets: If `true`, the response includes term offsets.
4833
6016
  :param payloads: If `true`, the response includes term payloads.
4834
- :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.
4835
6021
  :param positions: If `true`, the response includes term positions.
4836
- :param preference: Specifies the node or shard the operation should be performed
4837
- on. Random by default.
6022
+ :param preference: The node or shard the operation should be performed on. It
6023
+ is random by default.
4838
6024
  :param realtime: If true, the request is real-time as opposed to near-real-time.
4839
- :param routing: Custom value used to route operations to a specific shard.
4840
- :param term_statistics: If `true`, the response includes term frequency and document
4841
- 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.
4842
6031
  :param version: If `true`, returns the document version as part of a hit.
4843
- :param version_type: Specific version type.
6032
+ :param version_type: The version type.
4844
6033
  """
4845
6034
  if index in SKIP_IN_PATH:
4846
6035
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4957,46 +6146,65 @@ class AsyncElasticsearch(BaseClient):
4957
6146
  body: t.Optional[t.Dict[str, t.Any]] = None,
4958
6147
  ) -> ObjectApiResponse[t.Any]:
4959
6148
  """
4960
- Update a document. Updates a document by running a script or passing a partial
4961
- 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
+
4962
6167
 
4963
6168
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update.html>`_
4964
6169
 
4965
- :param index: The name of the index
4966
- :param id: Document ID
4967
- :param detect_noop: Set to false to disable setting 'result' in the response
4968
- to 'noop' if no change to the document occurred.
4969
- :param doc: A partial update to an existing document.
4970
- :param doc_as_upsert: Set to true to use the contents of 'doc' as the value of
4971
- '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.
4972
6179
  :param if_primary_term: Only perform the operation if the document has this primary
4973
6180
  term.
4974
6181
  :param if_seq_no: Only perform the operation if the document has this sequence
4975
6182
  number.
4976
6183
  :param lang: The script language.
4977
6184
  :param refresh: If 'true', Elasticsearch refreshes the affected shards to make
4978
- this operation visible to search, if 'wait_for' then wait for a refresh to
4979
- make this operation visible to search, if 'false' do nothing with refreshes.
4980
- :param require_alias: If true, the destination must be an index alias.
4981
- :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
4982
6189
  when a conflict occurs.
4983
- :param routing: Custom value used to route operations to a specific shard.
4984
- :param script: Script to execute to update the document.
4985
- :param scripted_upsert: Set to true to execute the script whether or not the
4986
- document exists.
4987
- :param source: Set to false to disable source retrieval. You can also specify
4988
- a comma-separated list of the fields you want to retrieve.
4989
- :param source_excludes: Specify the source fields you want to exclude.
4990
- :param source_includes: Specify the source fields you want to retrieve.
4991
- :param timeout: Period to wait for dynamic mapping updates and active shards.
4992
- This guarantees Elasticsearch waits for at least the timeout before failing.
4993
- 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.
4994
6202
  :param upsert: If the document does not already exist, the contents of 'upsert'
4995
- are inserted as a new document. If the document exists, the 'script' is executed.
4996
- :param wait_for_active_shards: The number of shard copies that must be active
4997
- before proceeding with the operations. Set to 'all' or any positive integer
4998
- up to the total number of shards in the index (number_of_replicas+1). Defaults
4999
- 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.
5000
6208
  """
5001
6209
  if index in SKIP_IN_PATH:
5002
6210
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5122,82 +6330,166 @@ class AsyncElasticsearch(BaseClient):
5122
6330
  body: t.Optional[t.Dict[str, t.Any]] = None,
5123
6331
  ) -> ObjectApiResponse[t.Any]:
5124
6332
  """
5125
- Update documents. Updates documents that match the specified query. If no query
5126
- is specified, performs an update on every document in the data stream or index
5127
- 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
+
5128
6401
 
5129
6402
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
5130
6403
 
5131
- :param index: Comma-separated list of data streams, indices, and aliases to search.
5132
- Supports wildcards (`*`). To search all data streams or indices, omit this
5133
- 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`.
5134
6407
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
5135
6408
  expression, index alias, or `_all` value targets only missing or closed indices.
5136
6409
  This behavior applies even if the request targets other open indices. For
5137
6410
  example, a request targeting `foo*,bar*` returns an error if an index starts
5138
6411
  with `foo` but no index starts with `bar`.
5139
6412
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
5140
- :param analyzer: Analyzer to use for the query string.
5141
- :param conflicts: What to do if update by query hits version conflicts: `abort`
5142
- 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`.
5143
6418
  :param default_operator: The default operator for query string query: `AND` or
5144
- `OR`.
5145
- :param df: Field to use as default where no field prefix is given in the query
5146
- string.
5147
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
5148
- request can target data streams, this argument determines whether wildcard
5149
- expressions match hidden data streams. Supports comma-separated values, such
5150
- 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`.
5151
6429
  :param from_: Starting offset (default: 0)
5152
6430
  :param ignore_unavailable: If `false`, the request returns an error if it targets
5153
6431
  a missing or closed index.
5154
6432
  :param lenient: If `true`, format-based query failures (such as providing text
5155
- 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.
5156
6435
  :param max_docs: The maximum number of documents to update.
5157
- :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.
5158
6437
  If the index has a default ingest pipeline specified, then setting the value
5159
6438
  to `_none` disables the default ingest pipeline for this request. If a final
5160
6439
  pipeline is configured it will always run, regardless of the value of this
5161
6440
  parameter.
5162
- :param preference: Specifies the node or shard the operation should be performed
5163
- on. Random by default.
5164
- :param q: Query in the Lucene query string syntax.
5165
- :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.
5166
6445
  :param refresh: If `true`, Elasticsearch refreshes affected shards to make the
5167
- 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.
5168
6449
  :param request_cache: If `true`, the request cache is used for this request.
6450
+ It defaults to the index-level setting.
5169
6451
  :param requests_per_second: The throttle for this request in sub-requests per
5170
6452
  second.
5171
- :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.
5172
6454
  :param script: The script to run to update the document source or metadata when
5173
6455
  updating.
5174
- :param scroll: Period to retain the search context for scrolling.
5175
- :param scroll_size: Size of the scroll request that powers the operation.
5176
- :param search_timeout: Explicit timeout for each search request.
5177
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
5178
- `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`.
5179
6462
  :param slice: Slice the request manually using the provided slice ID and total
5180
6463
  number of slices.
5181
6464
  :param slices: The number of slices this task should be divided into.
5182
6465
  :param sort: A comma-separated list of <field>:<direction> pairs.
5183
- :param stats: Specific `tag` of the request for logging and statistical purposes.
5184
- :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.
5185
6468
  If a query reaches this limit, Elasticsearch terminates the query early.
5186
- Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
5187
- applies this parameter to each shard handling the request. When possible,
5188
- let Elasticsearch perform early termination automatically. Avoid specifying
5189
- this parameter for requests that target data streams with backing indices
5190
- across multiple data tiers.
5191
- :param timeout: Period each update request waits for the following operations:
5192
- 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.
5193
6479
  :param version: If `true`, returns the document version as part of a hit.
5194
6480
  :param version_type: Should the document increment the version number (internal)
5195
6481
  on hit or not (reindex)
5196
6482
  :param wait_for_active_shards: The number of shard copies that must be active
5197
6483
  before proceeding with the operation. Set to `all` or any positive integer
5198
- 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.
5199
6488
  :param wait_for_completion: If `true`, the request blocks until the operation
5200
- 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}`.
5201
6493
  """
5202
6494
  if index in SKIP_IN_PATH:
5203
6495
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5320,16 +6612,18 @@ class AsyncElasticsearch(BaseClient):
5320
6612
  requests_per_second: t.Optional[float] = None,
5321
6613
  ) -> ObjectApiResponse[t.Any]:
5322
6614
  """
5323
- Throttle an update by query operation. Change the number of requests per second
5324
- for a particular update by query operation. Rethrottling that speeds up the query
5325
- takes effect immediately but rethrotting that slows down the query takes effect
5326
- 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>
5327
6620
 
5328
- `<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>`_
5329
6623
 
5330
6624
  :param task_id: The ID for the task.
5331
6625
  :param requests_per_second: The throttle for this request in sub-requests per
5332
- second.
6626
+ second. To turn off throttling, set it to `-1`.
5333
6627
  """
5334
6628
  if task_id in SKIP_IN_PATH:
5335
6629
  raise ValueError("Empty value passed for parameter 'task_id'")