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 Elasticsearch(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)
@@ -642,41 +644,131 @@ class Elasticsearch(BaseClient):
642
644
  ] = None,
643
645
  ) -> ObjectApiResponse[t.Any]:
644
646
  """
645
- Bulk index or delete documents. Performs multiple indexing or delete operations
646
- in a single API call. This reduces overhead and can greatly increase indexing
647
- speed.
647
+ .. raw:: html
648
+
649
+ <p>Bulk index or delete documents.
650
+ Perform multiple <code>index</code>, <code>create</code>, <code>delete</code>, and <code>update</code> actions in a single request.
651
+ This reduces overhead and can greatly increase indexing speed.</p>
652
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
653
+ <ul>
654
+ <li>To use the <code>create</code> action, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege. Data streams support only the <code>create</code> action.</li>
655
+ <li>To use the <code>index</code> action, you must have the <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
656
+ <li>To use the <code>delete</code> action, you must have the <code>delete</code> or <code>write</code> index privilege.</li>
657
+ <li>To use the <code>update</code> action, you must have the <code>index</code> or <code>write</code> index privilege.</li>
658
+ <li>To automatically create a data stream or index with a bulk API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
659
+ <li>To make the result of a bulk operation visible to search using the <code>refresh</code> parameter, you must have the <code>maintenance</code> or <code>manage</code> index privilege.</li>
660
+ </ul>
661
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
662
+ <p>The actions are specified in the request body using a newline delimited JSON (NDJSON) structure:</p>
663
+ <pre><code>action_and_meta_data\\n
664
+ optional_source\\n
665
+ action_and_meta_data\\n
666
+ optional_source\\n
667
+ ....
668
+ action_and_meta_data\\n
669
+ optional_source\\n
670
+ </code></pre>
671
+ <p>The <code>index</code> and <code>create</code> actions expect a source on the next line and have the same semantics as the <code>op_type</code> parameter in the standard index API.
672
+ A <code>create</code> action fails if a document with the same ID already exists in the target
673
+ An <code>index</code> action adds or replaces a document as necessary.</p>
674
+ <p>NOTE: Data streams support only the <code>create</code> action.
675
+ To update or delete a document in a data stream, you must target the backing index containing the document.</p>
676
+ <p>An <code>update</code> action expects that the partial doc, upsert, and script and its options are specified on the next line.</p>
677
+ <p>A <code>delete</code> action does not expect a source on the next line and has the same semantics as the standard delete API.</p>
678
+ <p>NOTE: The final line of data must end with a newline character (<code>\\n</code>).
679
+ Each newline character may be preceded by a carriage return (<code>\\r</code>).
680
+ When sending NDJSON data to the <code>_bulk</code> endpoint, use a <code>Content-Type</code> header of <code>application/json</code> or <code>application/x-ndjson</code>.
681
+ Because this format uses literal newline characters (<code>\\n</code>) as delimiters, make sure that the JSON actions and sources are not pretty printed.</p>
682
+ <p>If you provide a target in the request path, it is used for any actions that don't explicitly specify an <code>_index</code> argument.</p>
683
+ <p>A note on the format: the idea here is to make processing as fast as possible.
684
+ As some of the actions are redirected to other shards on other nodes, only <code>action_meta_data</code> is parsed on the receiving node side.</p>
685
+ <p>Client libraries using this protocol should try and strive to do something similar on the client side, and reduce buffering as much as possible.</p>
686
+ <p>There is no &quot;correct&quot; number of actions to perform in a single bulk request.
687
+ Experiment with different settings to find the optimal size for your particular workload.
688
+ Note that Elasticsearch limits the maximum size of a HTTP request to 100mb by default so clients must ensure that no request exceeds this size.
689
+ It is not possible to index a single document that exceeds the size limit, so you must pre-process any such documents into smaller pieces before sending them to Elasticsearch.
690
+ For instance, split documents into pages or chapters before indexing them, or store raw binary data in a system outside Elasticsearch and replace the raw data with a link to the external system in the documents that you send to Elasticsearch.</p>
691
+ <p><strong>Client suppport for bulk requests</strong></p>
692
+ <p>Some of the officially supported clients provide helpers to assist with bulk requests and reindexing:</p>
693
+ <ul>
694
+ <li>Go: Check out <code>esutil.BulkIndexer</code></li>
695
+ <li>Perl: Check out <code>Search::Elasticsearch::Client::5_0::Bulk</code> and <code>Search::Elasticsearch::Client::5_0::Scroll</code></li>
696
+ <li>Python: Check out <code>elasticsearch.helpers.*</code></li>
697
+ <li>JavaScript: Check out <code>client.helpers.*</code></li>
698
+ <li>.NET: Check out <code>BulkAllObservable</code></li>
699
+ <li>PHP: Check out bulk indexing.</li>
700
+ </ul>
701
+ <p><strong>Submitting bulk requests with cURL</strong></p>
702
+ <p>If you're providing text file input to <code>curl</code>, you must use the <code>--data-binary</code> flag instead of plain <code>-d</code>.
703
+ The latter doesn't preserve newlines. For example:</p>
704
+ <pre><code>$ cat requests
705
+ { &quot;index&quot; : { &quot;_index&quot; : &quot;test&quot;, &quot;_id&quot; : &quot;1&quot; } }
706
+ { &quot;field1&quot; : &quot;value1&quot; }
707
+ $ curl -s -H &quot;Content-Type: application/x-ndjson&quot; -XPOST localhost:9200/_bulk --data-binary &quot;@requests&quot;; echo
708
+ {&quot;took&quot;:7, &quot;errors&quot;: false, &quot;items&quot;:[{&quot;index&quot;:{&quot;_index&quot;:&quot;test&quot;,&quot;_id&quot;:&quot;1&quot;,&quot;_version&quot;:1,&quot;result&quot;:&quot;created&quot;,&quot;forced_refresh&quot;:false}}]}
709
+ </code></pre>
710
+ <p><strong>Optimistic concurrency control</strong></p>
711
+ <p>Each <code>index</code> and <code>delete</code> action within a bulk API call may include the <code>if_seq_no</code> and <code>if_primary_term</code> parameters in their respective action and meta data lines.
712
+ The <code>if_seq_no</code> and <code>if_primary_term</code> parameters control how operations are run, based on the last modification to existing documents. See Optimistic concurrency control for more details.</p>
713
+ <p><strong>Versioning</strong></p>
714
+ <p>Each bulk item can include the version value using the <code>version</code> field.
715
+ It automatically follows the behavior of the index or delete operation based on the <code>_version</code> mapping.
716
+ It also support the <code>version_type</code>.</p>
717
+ <p><strong>Routing</strong></p>
718
+ <p>Each bulk item can include the routing value using the <code>routing</code> field.
719
+ It automatically follows the behavior of the index or delete operation based on the <code>_routing</code> mapping.</p>
720
+ <p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
721
+ <p><strong>Wait for active shards</strong></p>
722
+ <p>When making bulk calls, you can set the <code>wait_for_active_shards</code> parameter to require a minimum number of shard copies to be active before starting to process the bulk request.</p>
723
+ <p><strong>Refresh</strong></p>
724
+ <p>Control when the changes made by this request are visible to search.</p>
725
+ <p>NOTE: Only the shards that receive the bulk request will be affected by refresh.
726
+ Imagine a <code>_bulk?refresh=wait_for</code> request with three documents in it that happen to be routed to different shards in an index with five shards.
727
+ The request will only wait for those three shards to refresh.
728
+ The other two shards that make up the index do not participate in the <code>_bulk</code> request at all.</p>
729
+
648
730
 
649
731
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-bulk.html>`_
650
732
 
651
733
  :param operations:
652
- :param index: Name of the data stream, index, or index alias to perform bulk
734
+ :param index: The name of the data stream, index, or index alias to perform bulk
653
735
  actions on.
654
736
  :param list_executed_pipelines: If `true`, the response will include the ingest
655
- pipelines that were executed for each index or create.
656
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
657
- If the index has a default ingest pipeline specified, then setting the value
658
- to `_none` disables the default ingest pipeline for this request. If a final
659
- pipeline is configured it will always run, regardless of the value of this
737
+ pipelines that were run for each index or create.
738
+ :param pipeline: The pipeline identifier to use to preprocess incoming documents.
739
+ If the index has a default ingest pipeline specified, setting the value to
740
+ `_none` turns off the default ingest pipeline for this request. If a final
741
+ pipeline is configured, it will always run regardless of the value of this
660
742
  parameter.
661
743
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
662
- this operation visible to search, if `wait_for` then wait for a refresh to
663
- make this operation visible to search, if `false` do nothing with refreshes.
744
+ this operation visible to search. If `wait_for`, wait for a refresh to make
745
+ this operation visible to search. If `false`, do nothing with refreshes.
664
746
  Valid values: `true`, `false`, `wait_for`.
665
- :param require_alias: If `true`, the requests actions must target an index alias.
747
+ :param require_alias: If `true`, the request's actions must target an index alias.
666
748
  :param require_data_stream: If `true`, the request's actions must target a data
667
- stream (existing or to-be-created).
668
- :param routing: Custom value used to route operations to a specific shard.
669
- :param source: `true` or `false` to return the `_source` field or not, or a list
670
- of fields to return.
749
+ stream (existing or to be created).
750
+ :param routing: A custom value that is used to route operations to a specific
751
+ shard.
752
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
753
+ or contains a list of fields to return.
671
754
  :param source_excludes: A comma-separated list of source fields to exclude from
672
- the response.
755
+ the response. You can also use this parameter to exclude fields from the
756
+ subset specified in `_source_includes` query parameter. If the `_source`
757
+ parameter is `false`, this parameter is ignored.
673
758
  :param source_includes: A comma-separated list of source fields to include in
674
- the response.
675
- :param timeout: Period each action waits for the following operations: automatic
676
- index creation, dynamic mapping updates, waiting for active shards.
759
+ the response. If this parameter is specified, only these source fields are
760
+ returned. You can exclude fields from this subset using the `_source_excludes`
761
+ query parameter. If the `_source` parameter is `false`, this parameter is
762
+ ignored.
763
+ :param timeout: The period each action waits for the following operations: automatic
764
+ index creation, dynamic mapping updates, and waiting for active shards. The
765
+ default is `1m` (one minute), which guarantees Elasticsearch waits for at
766
+ least the timeout before failing. The actual wait time could be longer, particularly
767
+ when multiple waits occur.
677
768
  :param wait_for_active_shards: The number of shard copies that must be active
678
- before proceeding with the operation. Set to all or any positive integer
679
- up to the total number of shards in the index (`number_of_replicas+1`).
769
+ before proceeding with the operation. Set to `all` or any positive integer
770
+ up to the total number of shards in the index (`number_of_replicas+1`). The
771
+ default is `1`, which waits for each primary shard to be active.
680
772
  """
681
773
  if operations is None and body is None:
682
774
  raise ValueError(
@@ -751,12 +843,15 @@ class Elasticsearch(BaseClient):
751
843
  body: t.Optional[t.Dict[str, t.Any]] = None,
752
844
  ) -> ObjectApiResponse[t.Any]:
753
845
  """
754
- Clear a scrolling search. Clear the search context and results for a scrolling
755
- search.
846
+ .. raw:: html
847
+
848
+ <p>Clear a scrolling search.
849
+ Clear the search context and results for a scrolling search.</p>
850
+
756
851
 
757
852
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/clear-scroll-api.html>`_
758
853
 
759
- :param scroll_id: Scroll IDs to clear. To clear all scroll IDs, use `_all`.
854
+ :param scroll_id: The scroll IDs to clear. To clear all scroll IDs, use `_all`.
760
855
  """
761
856
  __path_parts: t.Dict[str, str] = {}
762
857
  __path = "/_search/scroll"
@@ -802,11 +897,14 @@ class Elasticsearch(BaseClient):
802
897
  body: t.Optional[t.Dict[str, t.Any]] = None,
803
898
  ) -> ObjectApiResponse[t.Any]:
804
899
  """
805
- Close a point in time. A point in time must be opened explicitly before being
806
- used in search requests. The `keep_alive` parameter tells Elasticsearch how long
807
- it should persist. A point in time is automatically closed when the `keep_alive`
808
- period has elapsed. However, keeping points in time has a cost; close them as
809
- soon as they are no longer required for search requests.
900
+ .. raw:: html
901
+
902
+ <p>Close a point in time.
903
+ A point in time must be opened explicitly before being used in search requests.
904
+ The <code>keep_alive</code> parameter tells Elasticsearch how long it should persist.
905
+ A point in time is automatically closed when the <code>keep_alive</code> period has elapsed.
906
+ However, keeping points in time has a cost; close them as soon as they are no longer required for search requests.</p>
907
+
810
908
 
811
909
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
812
910
 
@@ -880,46 +978,65 @@ class Elasticsearch(BaseClient):
880
978
  body: t.Optional[t.Dict[str, t.Any]] = None,
881
979
  ) -> ObjectApiResponse[t.Any]:
882
980
  """
883
- Count search results. Get the number of documents matching a query.
981
+ .. raw:: html
982
+
983
+ <p>Count search results.
984
+ Get the number of documents matching a query.</p>
985
+ <p>The query can be provided either by using a simple query string as a parameter, or by defining Query DSL within the request body.
986
+ The query is optional. When no query is provided, the API uses <code>match_all</code> to count all the documents.</p>
987
+ <p>The count API supports multi-target syntax. You can run a single count API search across multiple data streams and indices.</p>
988
+ <p>The operation is broadcast across all shards.
989
+ For each shard ID group, a replica is chosen and the search is run against it.
990
+ This means that replicas increase the scalability of the count.</p>
991
+
884
992
 
885
993
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-count.html>`_
886
994
 
887
- :param index: Comma-separated list of data streams, indices, and aliases to search.
888
- Supports wildcards (`*`). To search all data streams and indices, omit this
889
- parameter or use `*` or `_all`.
995
+ :param index: A comma-separated list of data streams, indices, and aliases to
996
+ search. It supports wildcards (`*`). To search all data streams and indices,
997
+ omit this parameter or use `*` or `_all`.
890
998
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
891
999
  expression, index alias, or `_all` value targets only missing or closed indices.
892
- This behavior applies even if the request targets other open indices.
1000
+ This behavior applies even if the request targets other open indices. For
1001
+ example, a request targeting `foo*,bar*` returns an error if an index starts
1002
+ with `foo` but no index starts with `bar`.
893
1003
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
894
- This parameter can only be used when the `q` query string parameter is specified.
895
- :param analyzer: Analyzer to use for the query string. This parameter can only
896
- be used when the `q` query string parameter is specified.
1004
+ This parameter can be used only when the `q` query string parameter is specified.
1005
+ :param analyzer: The analyzer to use for the query string. This parameter can
1006
+ be used only when the `q` query string parameter is specified.
897
1007
  :param default_operator: The default operator for query string query: `AND` or
898
- `OR`. This parameter can only be used when the `q` query string parameter
1008
+ `OR`. This parameter can be used only when the `q` query string parameter
899
1009
  is specified.
900
- :param df: Field to use as default where no field prefix is given in the query
901
- string. This parameter can only be used when the `q` query string parameter
1010
+ :param df: The field to use as a default when no field prefix is given in the
1011
+ query string. This parameter can be used only when the `q` query string parameter
902
1012
  is specified.
903
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
904
- request can target data streams, this argument determines whether wildcard
905
- expressions match hidden data streams. Supports comma-separated values, such
906
- as `open,hidden`.
907
- :param ignore_throttled: If `true`, concrete, expanded or aliased indices are
1013
+ :param expand_wildcards: The type of index that wildcard patterns can match.
1014
+ If the request can target data streams, this argument determines whether
1015
+ wildcard expressions match hidden data streams. It supports comma-separated
1016
+ values, such as `open,hidden`.
1017
+ :param ignore_throttled: If `true`, concrete, expanded, or aliased indices are
908
1018
  ignored when frozen.
909
1019
  :param ignore_unavailable: If `false`, the request returns an error if it targets
910
1020
  a missing or closed index.
911
1021
  :param lenient: If `true`, format-based query failures (such as providing text
912
- to a numeric field) in the query string will be ignored.
913
- :param min_score: Sets the minimum `_score` value that documents must have to
914
- be included in the result.
915
- :param preference: Specifies the node or shard the operation should be performed
916
- on. Random by default.
917
- :param q: Query in the Lucene query string syntax.
918
- :param query: Defines the search definition using the Query DSL.
919
- :param routing: Custom value used to route operations to a specific shard.
920
- :param terminate_after: Maximum number of documents to collect for each shard.
1022
+ to a numeric field) in the query string will be ignored. This parameter can
1023
+ be used only when the `q` query string parameter is specified.
1024
+ :param min_score: The minimum `_score` value that documents must have to be included
1025
+ in the result.
1026
+ :param preference: The node or shard the operation should be performed on. By
1027
+ default, it is random.
1028
+ :param q: The query in Lucene query string syntax. This parameter cannot be used
1029
+ with a request body.
1030
+ :param query: Defines the search query using Query DSL. A request body query
1031
+ cannot be used with the `q` query string parameter.
1032
+ :param routing: A custom value used to route operations to a specific shard.
1033
+ :param terminate_after: The maximum number of documents to collect for each shard.
921
1034
  If a query reaches this limit, Elasticsearch terminates the query early.
922
- Elasticsearch collects documents before sorting.
1035
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
1036
+ Elasticsearch applies this parameter to each shard handling the request.
1037
+ When possible, let Elasticsearch perform early termination automatically.
1038
+ Avoid specifying this parameter for requests that target data streams with
1039
+ backing indices across multiple data tiers.
923
1040
  """
924
1041
  __path_parts: t.Dict[str, str]
925
1042
  if index not in SKIP_IN_PATH:
@@ -1013,38 +1130,100 @@ class Elasticsearch(BaseClient):
1013
1130
  ] = None,
1014
1131
  ) -> ObjectApiResponse[t.Any]:
1015
1132
  """
1016
- Index a document. Adds a JSON document to the specified data stream or index
1017
- and makes it searchable. If the target is an index and the document already exists,
1018
- the request updates the document and increments its version.
1133
+ .. raw:: html
1134
+
1135
+ <p>Create a new document in the index.</p>
1136
+ <p>You can index a new JSON document with the <code>/&lt;target&gt;/_doc/</code> or <code>/&lt;target&gt;/_create/&lt;_id&gt;</code> APIs
1137
+ Using <code>_create</code> guarantees that the document is indexed only if it does not already exist.
1138
+ It returns a 409 response when a document with a same ID already exists in the index.
1139
+ To update an existing document, you must use the <code>/&lt;target&gt;/_doc/</code> API.</p>
1140
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
1141
+ <ul>
1142
+ <li>To add a document using the <code>PUT /&lt;target&gt;/_create/&lt;_id&gt;</code> or <code>POST /&lt;target&gt;/_create/&lt;_id&gt;</code> request formats, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
1143
+ <li>To automatically create a data stream or index with this API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
1144
+ </ul>
1145
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
1146
+ <p><strong>Automatically create data streams and indices</strong></p>
1147
+ <p>If the request's target doesn't exist and matches an index template with a <code>data_stream</code> definition, the index operation automatically creates the data stream.</p>
1148
+ <p>If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates.</p>
1149
+ <p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
1150
+ <p>If no mapping exists, the index operation creates a dynamic mapping.
1151
+ By default, new fields and objects are automatically added to the mapping if needed.</p>
1152
+ <p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
1153
+ If it is <code>true</code>, any index can be created automatically.
1154
+ You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to <code>false</code> to turn off automatic index creation entirely.
1155
+ Specify a comma-separated list of patterns you want to allow or prefix each pattern with <code>+</code> or <code>-</code> to indicate whether it should be allowed or blocked.
1156
+ When a list is specified, the default behaviour is to disallow.</p>
1157
+ <p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
1158
+ It does not affect the creation of data streams.</p>
1159
+ <p><strong>Routing</strong></p>
1160
+ <p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
1161
+ For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the <code>routing</code> parameter.</p>
1162
+ <p>When setting up explicit mapping, you can also use the <code>_routing</code> field to direct the index operation to extract the routing value from the document itself.
1163
+ This does come at the (very minimal) cost of an additional document parsing pass.
1164
+ If the <code>_routing</code> mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted.</p>
1165
+ <p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
1166
+ <p>** Distributed**</p>
1167
+ <p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
1168
+ After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
1169
+ <p><strong>Active shards</strong></p>
1170
+ <p>To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation.
1171
+ If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs.
1172
+ By default, write operations only wait for the primary shards to be active before proceeding (that is to say <code>wait_for_active_shards</code> is <code>1</code>).
1173
+ This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
1174
+ To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
1175
+ <p>Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is <code>number_of_replicas</code>+1).
1176
+ Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
1177
+ <p>For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes).
1178
+ If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
1179
+ This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data.
1180
+ If <code>wait_for_active_shards</code> is set on the request to <code>3</code> (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding.
1181
+ This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
1182
+ However, if you set <code>wait_for_active_shards</code> to <code>all</code> (or to <code>4</code>, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index.
1183
+ The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
1184
+ <p>It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts.
1185
+ After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary.
1186
+ The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
1187
+
1019
1188
 
1020
1189
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
1021
1190
 
1022
- :param index: Name of the data stream or index to target. If the target doesnt
1191
+ :param index: The name of the data stream or index to target. If the target doesn't
1023
1192
  exist and matches the name or wildcard (`*`) pattern of an index template
1024
1193
  with a `data_stream` definition, this request creates the data stream. If
1025
- the target doesnt exist and doesn’t match a data stream template, this request
1194
+ the target doesn't exist and doesn’t match a data stream template, this request
1026
1195
  creates the index.
1027
- :param id: Unique identifier for the document.
1196
+ :param id: A unique identifier for the document. To automatically generate a
1197
+ document ID, use the `POST /<target>/_doc/` request format.
1028
1198
  :param document:
1029
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
1030
- If the index has a default ingest pipeline specified, then setting the value
1031
- to `_none` disables the default ingest pipeline for this request. If a final
1032
- pipeline is configured it will always run, regardless of the value of this
1199
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
1200
+ If the index has a default ingest pipeline specified, setting the value to
1201
+ `_none` turns off the default ingest pipeline for this request. If a final
1202
+ pipeline is configured, it will always run regardless of the value of this
1033
1203
  parameter.
1034
1204
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
1035
- this operation visible to search, if `wait_for` then wait for a refresh to
1036
- make this operation visible to search, if `false` do nothing with refreshes.
1037
- Valid values: `true`, `false`, `wait_for`.
1038
- :param routing: Custom value used to route operations to a specific shard.
1039
- :param timeout: Period the request waits for the following operations: automatic
1040
- index creation, dynamic mapping updates, waiting for active shards.
1041
- :param version: Explicit version number for concurrency control. The specified
1042
- version must match the current version of the document for the request to
1043
- succeed.
1044
- :param version_type: Specific version type: `external`, `external_gte`.
1205
+ this operation visible to search. If `wait_for`, it waits for a refresh to
1206
+ make this operation visible to search. If `false`, it does nothing with refreshes.
1207
+ :param routing: A custom value that is used to route operations to a specific
1208
+ shard.
1209
+ :param timeout: The period the request waits for the following operations: automatic
1210
+ index creation, dynamic mapping updates, waiting for active shards. Elasticsearch
1211
+ waits for at least the specified timeout period before failing. The actual
1212
+ wait time could be longer, particularly when multiple waits occur. This parameter
1213
+ is useful for situations where the primary shard assigned to perform the
1214
+ operation might not be available when the operation runs. Some reasons for
1215
+ this might be that the primary shard is currently recovering from a gateway
1216
+ or undergoing relocation. By default, the operation will wait on the primary
1217
+ shard to become available for at least 1 minute before failing and responding
1218
+ with an error. The actual wait time could be longer, particularly when multiple
1219
+ waits occur.
1220
+ :param version: The explicit version number for concurrency control. It must
1221
+ be a non-negative long number.
1222
+ :param version_type: The version type.
1045
1223
  :param wait_for_active_shards: The number of shard copies that must be active
1046
- before proceeding with the operation. Set to `all` or any positive integer
1047
- up to the total number of shards in the index (`number_of_replicas+1`).
1224
+ before proceeding with the operation. You can set it to `all` or any positive
1225
+ integer up to the total number of shards in the index (`number_of_replicas+1`).
1226
+ The default value of `1` means it waits for each primary shard to be active.
1048
1227
  """
1049
1228
  if index in SKIP_IN_PATH:
1050
1229
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1119,29 +1298,60 @@ class Elasticsearch(BaseClient):
1119
1298
  ] = None,
1120
1299
  ) -> ObjectApiResponse[t.Any]:
1121
1300
  """
1122
- Delete a document. Removes a JSON document from the specified index.
1301
+ .. raw:: html
1302
+
1303
+ <p>Delete a document.</p>
1304
+ <p>Remove a JSON document from the specified index.</p>
1305
+ <p>NOTE: You cannot send deletion requests directly to a data stream.
1306
+ To delete a document in a data stream, you must target the backing index containing the document.</p>
1307
+ <p><strong>Optimistic concurrency control</strong></p>
1308
+ <p>Delete operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the <code>if_seq_no</code> and <code>if_primary_term</code> parameters.
1309
+ If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
1310
+ <p><strong>Versioning</strong></p>
1311
+ <p>Each document indexed is versioned.
1312
+ When deleting a document, the version can be specified to make sure the relevant document you are trying to delete is actually being deleted and it has not changed in the meantime.
1313
+ Every write operation run on a document, deletes included, causes its version to be incremented.
1314
+ The version number of a deleted document remains available for a short time after deletion to allow for control of concurrent operations.
1315
+ The length of time for which a deleted document's version remains available is determined by the <code>index.gc_deletes</code> index setting.</p>
1316
+ <p><strong>Routing</strong></p>
1317
+ <p>If routing is used during indexing, the routing value also needs to be specified to delete a document.</p>
1318
+ <p>If the <code>_routing</code> mapping is set to <code>required</code> and no routing value is specified, the delete API throws a <code>RoutingMissingException</code> and rejects the request.</p>
1319
+ <p>For example:</p>
1320
+ <pre><code>DELETE /my-index-000001/_doc/1?routing=shard-1
1321
+ </code></pre>
1322
+ <p>This request deletes the document with ID 1, but it is routed based on the user.
1323
+ The document is not deleted if the correct routing is not specified.</p>
1324
+ <p><strong>Distributed</strong></p>
1325
+ <p>The delete operation gets hashed into a specific shard ID.
1326
+ It then gets redirected into the primary shard within that ID group and replicated (if needed) to shard replicas within that ID group.</p>
1327
+
1123
1328
 
1124
1329
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete.html>`_
1125
1330
 
1126
- :param index: Name of the target index.
1127
- :param id: Unique identifier for the document.
1331
+ :param index: The name of the target index.
1332
+ :param id: A unique identifier for the document.
1128
1333
  :param if_primary_term: Only perform the operation if the document has this primary
1129
1334
  term.
1130
1335
  :param if_seq_no: Only perform the operation if the document has this sequence
1131
1336
  number.
1132
1337
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
1133
- this operation visible to search, if `wait_for` then wait for a refresh to
1134
- make this operation visible to search, if `false` do nothing with refreshes.
1135
- Valid values: `true`, `false`, `wait_for`.
1136
- :param routing: Custom value used to route operations to a specific shard.
1137
- :param timeout: Period to wait for active shards.
1138
- :param version: Explicit version number for concurrency control. The specified
1139
- version must match the current version of the document for the request to
1140
- succeed.
1141
- :param version_type: Specific version type: `external`, `external_gte`.
1142
- :param wait_for_active_shards: The number of shard copies that must be active
1143
- before proceeding with the operation. Set to `all` or any positive integer
1144
- up to the total number of shards in the index (`number_of_replicas+1`).
1338
+ this operation visible to search. If `wait_for`, it waits for a refresh to
1339
+ make this operation visible to search. If `false`, it does nothing with refreshes.
1340
+ :param routing: A custom value used to route operations to a specific shard.
1341
+ :param timeout: The period to wait for active shards. This parameter is useful
1342
+ for situations where the primary shard assigned to perform the delete operation
1343
+ might not be available when the delete operation runs. Some reasons for this
1344
+ might be that the primary shard is currently recovering from a store or undergoing
1345
+ relocation. By default, the delete operation will wait on the primary shard
1346
+ to become available for up to 1 minute before failing and responding with
1347
+ an error.
1348
+ :param version: An explicit version number for concurrency control. It must match
1349
+ the current version of the document for the request to succeed.
1350
+ :param version_type: The version type.
1351
+ :param wait_for_active_shards: The minimum number of shard copies that must be
1352
+ active before proceeding with the operation. You can set it to `all` or any
1353
+ positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1354
+ The default value of `1` means it waits for each primary shard to be active.
1145
1355
  """
1146
1356
  if index in SKIP_IN_PATH:
1147
1357
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1241,72 +1451,148 @@ class Elasticsearch(BaseClient):
1241
1451
  body: t.Optional[t.Dict[str, t.Any]] = None,
1242
1452
  ) -> ObjectApiResponse[t.Any]:
1243
1453
  """
1244
- Delete documents. Deletes documents that match the specified query.
1454
+ .. raw:: html
1455
+
1456
+ <p>Delete documents.</p>
1457
+ <p>Deletes documents that match the specified query.</p>
1458
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
1459
+ <ul>
1460
+ <li><code>read</code></li>
1461
+ <li><code>delete</code> or <code>write</code></li>
1462
+ </ul>
1463
+ <p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.
1464
+ When you submit a delete by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and deletes matching documents using internal versioning.
1465
+ If a document changes between the time that the snapshot is taken and the delete operation is processed, it results in a version conflict and the delete operation fails.</p>
1466
+ <p>NOTE: Documents with a version equal to 0 cannot be deleted using delete by query because internal versioning does not support 0 as a valid version number.</p>
1467
+ <p>While processing a delete by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents to delete.
1468
+ A bulk delete request is performed for each batch of matching documents.
1469
+ If a search or bulk request is rejected, the requests are retried up to 10 times, with exponential back off.
1470
+ If the maximum retry limit is reached, processing halts and all failed requests are returned in the response.
1471
+ Any delete requests that completed successfully still stick, they are not rolled back.</p>
1472
+ <p>You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
1473
+ Note that if you opt to count version conflicts the operation could attempt to delete more documents from the source than <code>max_docs</code> until it has successfully deleted <code>max_docs documents</code>, or it has gone through every document in the source query.</p>
1474
+ <p><strong>Throttling delete requests</strong></p>
1475
+ <p>To control the rate at which delete by query issues batches of delete operations, you can set <code>requests_per_second</code> to any positive decimal number.
1476
+ This pads each batch with a wait time to throttle the rate.
1477
+ Set <code>requests_per_second</code> to <code>-1</code> to disable throttling.</p>
1478
+ <p>Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
1479
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
1480
+ By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
1481
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
1482
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
1483
+ </code></pre>
1484
+ <p>Since the batch is issued as a single <code>_bulk</code> request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
1485
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
1486
+ <p><strong>Slicing</strong></p>
1487
+ <p>Delete by query supports sliced scroll to parallelize the delete process.
1488
+ This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
1489
+ <p>Setting <code>slices</code> to <code>auto</code> lets Elasticsearch choose the number of slices to use.
1490
+ This setting will use one slice per shard, up to a certain limit.
1491
+ If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.
1492
+ Adding slices to the delete by query operation creates sub-requests which means it has some quirks:</p>
1493
+ <ul>
1494
+ <li>You can see these requests in the tasks APIs. These sub-requests are &quot;child&quot; tasks of the task for the request with slices.</li>
1495
+ <li>Fetching the status of the task for the request with slices only contains the status of completed slices.</li>
1496
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
1497
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
1498
+ <li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
1499
+ <li>Due to the nature of <code>slices</code> each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
1500
+ <li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with <code>slices</code> are distributed proportionally to each sub-request. Combine that with the earlier point about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being deleted.</li>
1501
+ <li>Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.</li>
1502
+ </ul>
1503
+ <p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
1504
+ <ul>
1505
+ <li>Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many <code>slices</code> hurts performance. Setting <code>slices</code> higher than the number of shards generally does not improve efficiency and adds overhead.</li>
1506
+ <li>Delete performance scales linearly across available resources with the number of slices.</li>
1507
+ </ul>
1508
+ <p>Whether query or delete performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
1509
+ <p><strong>Cancel a delete by query operation</strong></p>
1510
+ <p>Any delete by query can be canceled using the task cancel API. For example:</p>
1511
+ <pre><code>POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
1512
+ </code></pre>
1513
+ <p>The task ID can be found by using the get tasks API.</p>
1514
+ <p>Cancellation should happen quickly but might take a few seconds.
1515
+ The get task status API will continue to list the delete by query task until this task checks that it has been cancelled and terminates itself.</p>
1516
+
1245
1517
 
1246
1518
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1247
1519
 
1248
- :param index: Comma-separated list of data streams, indices, and aliases to search.
1249
- Supports wildcards (`*`). To search all data streams or indices, omit this
1250
- parameter or use `*` or `_all`.
1520
+ :param index: A comma-separated list of data streams, indices, and aliases to
1521
+ search. It supports wildcards (`*`). To search all data streams or indices,
1522
+ omit this parameter or use `*` or `_all`.
1251
1523
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
1252
1524
  expression, index alias, or `_all` value targets only missing or closed indices.
1253
1525
  This behavior applies even if the request targets other open indices. For
1254
1526
  example, a request targeting `foo*,bar*` returns an error if an index starts
1255
1527
  with `foo` but no index starts with `bar`.
1256
1528
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1257
- :param analyzer: Analyzer to use for the query string.
1529
+ This parameter can be used only when the `q` query string parameter is specified.
1530
+ :param analyzer: Analyzer to use for the query string. This parameter can be
1531
+ used only when the `q` query string parameter is specified.
1258
1532
  :param conflicts: What to do if delete by query hits version conflicts: `abort`
1259
1533
  or `proceed`.
1260
1534
  :param default_operator: The default operator for query string query: `AND` or
1261
- `OR`.
1262
- :param df: Field to use as default where no field prefix is given in the query
1263
- string.
1264
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
1265
- request can target data streams, this argument determines whether wildcard
1266
- expressions match hidden data streams. Supports comma-separated values, such
1267
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
1535
+ `OR`. This parameter can be used only when the `q` query string parameter
1536
+ is specified.
1537
+ :param df: The field to use as default where no field prefix is given in the
1538
+ query string. This parameter can be used only when the `q` query string parameter
1539
+ is specified.
1540
+ :param expand_wildcards: The type of index that wildcard patterns can match.
1541
+ If the request can target data streams, this argument determines whether
1542
+ wildcard expressions match hidden data streams. It supports comma-separated
1543
+ values, such as `open,hidden`.
1268
1544
  :param from_: Starting offset (default: 0)
1269
1545
  :param ignore_unavailable: If `false`, the request returns an error if it targets
1270
1546
  a missing or closed index.
1271
1547
  :param lenient: If `true`, format-based query failures (such as providing text
1272
- to a numeric field) in the query string will be ignored.
1548
+ to a numeric field) in the query string will be ignored. This parameter can
1549
+ be used only when the `q` query string parameter is specified.
1273
1550
  :param max_docs: The maximum number of documents to delete.
1274
- :param preference: Specifies the node or shard the operation should be performed
1275
- on. Random by default.
1276
- :param q: Query in the Lucene query string syntax.
1277
- :param query: Specifies the documents to delete using the Query DSL.
1551
+ :param preference: The node or shard the operation should be performed on. It
1552
+ is random by default.
1553
+ :param q: A query in the Lucene query string syntax.
1554
+ :param query: The documents to delete specified with Query DSL.
1278
1555
  :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1279
- delete by query after the request completes.
1556
+ delete by query after the request completes. This is different than the delete
1557
+ API's `refresh` parameter, which causes just the shard that received the
1558
+ delete request to be refreshed. Unlike the delete API, it does not support
1559
+ `wait_for`.
1280
1560
  :param request_cache: If `true`, the request cache is used for this request.
1281
1561
  Defaults to the index-level setting.
1282
1562
  :param requests_per_second: The throttle for this request in sub-requests per
1283
1563
  second.
1284
- :param routing: Custom value used to route operations to a specific shard.
1285
- :param scroll: Period to retain the search context for scrolling.
1286
- :param scroll_size: Size of the scroll request that powers the operation.
1287
- :param search_timeout: Explicit timeout for each search request. Defaults to
1288
- no timeout.
1289
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
1290
- `dfs_query_then_fetch`.
1564
+ :param routing: A custom value used to route operations to a specific shard.
1565
+ :param scroll: The period to retain the search context for scrolling.
1566
+ :param scroll_size: The size of the scroll request that powers the operation.
1567
+ :param search_timeout: The explicit timeout for each search request. It defaults
1568
+ to no timeout.
1569
+ :param search_type: The type of the search operation. Available options include
1570
+ `query_then_fetch` and `dfs_query_then_fetch`.
1291
1571
  :param slice: Slice the request manually using the provided slice ID and total
1292
1572
  number of slices.
1293
1573
  :param slices: The number of slices this task should be divided into.
1294
- :param sort: A comma-separated list of <field>:<direction> pairs.
1295
- :param stats: Specific `tag` of the request for logging and statistical purposes.
1296
- :param terminate_after: Maximum number of documents to collect for each shard.
1574
+ :param sort: A comma-separated list of `<field>:<direction>` pairs.
1575
+ :param stats: The specific `tag` of the request for logging and statistical purposes.
1576
+ :param terminate_after: The maximum number of documents to collect for each shard.
1297
1577
  If a query reaches this limit, Elasticsearch terminates the query early.
1298
1578
  Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
1299
1579
  applies this parameter to each shard handling the request. When possible,
1300
1580
  let Elasticsearch perform early termination automatically. Avoid specifying
1301
1581
  this parameter for requests that target data streams with backing indices
1302
1582
  across multiple data tiers.
1303
- :param timeout: Period each deletion request waits for active shards.
1583
+ :param timeout: The period each deletion request waits for active shards.
1304
1584
  :param version: If `true`, returns the document version as part of a hit.
1305
1585
  :param wait_for_active_shards: The number of shard copies that must be active
1306
- before proceeding with the operation. Set to all or any positive integer
1307
- up to the total number of shards in the index (`number_of_replicas+1`).
1586
+ before proceeding with the operation. Set to `all` or any positive integer
1587
+ up to the total number of shards in the index (`number_of_replicas+1`). The
1588
+ `timeout` value controls how long each write request waits for unavailable
1589
+ shards to become available.
1308
1590
  :param wait_for_completion: If `true`, the request blocks until the operation
1309
- is complete.
1591
+ is complete. If `false`, Elasticsearch performs some preflight checks, launches
1592
+ the request, and returns a task you can use to cancel or get the status of
1593
+ the task. Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`.
1594
+ When you are done with a task, you should delete the task document so Elasticsearch
1595
+ can reclaim the space.
1310
1596
  """
1311
1597
  if index in SKIP_IN_PATH:
1312
1598
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1419,16 +1705,18 @@ class Elasticsearch(BaseClient):
1419
1705
  requests_per_second: t.Optional[float] = None,
1420
1706
  ) -> ObjectApiResponse[t.Any]:
1421
1707
  """
1422
- Throttle a delete by query operation. Change the number of requests per second
1423
- for a particular delete by query operation. Rethrottling that speeds up the query
1424
- takes effect immediately but rethrotting that slows down the query takes effect
1425
- after completing the current batch to prevent scroll timeouts.
1708
+ .. raw:: html
1426
1709
 
1427
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html>`_
1710
+ <p>Throttle a delete by query operation.</p>
1711
+ <p>Change the number of requests per second for a particular delete by query operation.
1712
+ Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.</p>
1713
+
1714
+
1715
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-delete-by-query.html#docs-delete-by-query-rethrottle>`_
1428
1716
 
1429
1717
  :param task_id: The ID for the task.
1430
1718
  :param requests_per_second: The throttle for this request in sub-requests per
1431
- second.
1719
+ second. To disable throttling, set it to `-1`.
1432
1720
  """
1433
1721
  if task_id in SKIP_IN_PATH:
1434
1722
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -1468,16 +1756,22 @@ class Elasticsearch(BaseClient):
1468
1756
  timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
1469
1757
  ) -> ObjectApiResponse[t.Any]:
1470
1758
  """
1471
- Delete a script or search template. Deletes a stored script or search template.
1759
+ .. raw:: html
1472
1760
 
1473
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
1761
+ <p>Delete a script or search template.
1762
+ Deletes a stored script or search template.</p>
1474
1763
 
1475
- :param id: Identifier for the stored script or search template.
1476
- :param master_timeout: Period to wait for a connection to the master node. If
1477
- no response is received before the timeout expires, the request fails and
1478
- returns an error.
1479
- :param timeout: Period to wait for a response. If no response is received before
1480
- the timeout expires, the request fails and returns an error.
1764
+
1765
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/delete-stored-script-api.html>`_
1766
+
1767
+ :param id: The identifier for the stored script or search template.
1768
+ :param master_timeout: The period to wait for a connection to the master node.
1769
+ If no response is received before the timeout expires, the request fails
1770
+ and returns an error. It can also be set to `-1` to indicate that the request
1771
+ should never timeout.
1772
+ :param timeout: The period to wait for a response. If no response is received
1773
+ before the timeout expires, the request fails and returns an error. It can
1774
+ also be set to `-1` to indicate that the request should never timeout.
1481
1775
  """
1482
1776
  if id in SKIP_IN_PATH:
1483
1777
  raise ValueError("Empty value passed for parameter 'id'")
@@ -1536,32 +1830,60 @@ class Elasticsearch(BaseClient):
1536
1830
  ] = None,
1537
1831
  ) -> HeadApiResponse:
1538
1832
  """
1539
- Check a document. Checks if a specified document exists.
1833
+ .. raw:: html
1834
+
1835
+ <p>Check a document.</p>
1836
+ <p>Verify that a document exists.
1837
+ For example, check to see if a document with the <code>_id</code> 0 exists:</p>
1838
+ <pre><code>HEAD my-index-000001/_doc/0
1839
+ </code></pre>
1840
+ <p>If the document exists, the API returns a status code of <code>200 - OK</code>.
1841
+ If the document doesn’t exist, the API returns <code>404 - Not Found</code>.</p>
1842
+ <p><strong>Versioning support</strong></p>
1843
+ <p>You can use the <code>version</code> parameter to check the document only if its current version is equal to the specified one.</p>
1844
+ <p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
1845
+ The old version of the document doesn't disappear immediately, although you won't be able to access it.
1846
+ Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
1847
+
1540
1848
 
1541
1849
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1542
1850
 
1543
- :param index: Comma-separated list of data streams, indices, and aliases. Supports
1544
- wildcards (`*`).
1545
- :param id: Identifier of the document.
1546
- :param preference: Specifies the node or shard the operation should be performed
1547
- on. Random by default.
1851
+ :param index: A comma-separated list of data streams, indices, and aliases. It
1852
+ supports wildcards (`*`).
1853
+ :param id: A unique document identifier.
1854
+ :param preference: The node or shard the operation should be performed on. By
1855
+ default, the operation is randomized between the shard replicas. If it is
1856
+ set to `_local`, the operation will prefer to be run on a local allocated
1857
+ shard when possible. If it is set to a custom value, the value is used to
1858
+ guarantee that the same shards will be used for the same custom value. This
1859
+ can help with "jumping values" when hitting different shards in different
1860
+ refresh states. A sample value can be something like the web session ID or
1861
+ the user name.
1548
1862
  :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1549
- :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1550
- delete by query after the request completes.
1551
- :param routing: Target the specified primary shard.
1552
- :param source: `true` or `false` to return the `_source` field or not, or a list
1553
- of fields to return.
1554
- :param source_excludes: A comma-separated list of source fields to exclude in
1555
- the response.
1863
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
1864
+ the document. Setting it to `true` should be done after careful thought and
1865
+ verification that this does not cause a heavy load on the system (and slow
1866
+ down indexing).
1867
+ :param routing: A custom value used to route operations to a specific shard.
1868
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
1869
+ or lists the fields to return.
1870
+ :param source_excludes: A comma-separated list of source fields to exclude from
1871
+ the response. You can also use this parameter to exclude fields from the
1872
+ subset specified in `_source_includes` query parameter. If the `_source`
1873
+ parameter is `false`, this parameter is ignored.
1556
1874
  :param source_includes: A comma-separated list of source fields to include in
1557
- the response.
1558
- :param stored_fields: List of stored fields to return as part of a hit. If no
1559
- fields are specified, no stored fields are included in the response. If this
1560
- field is specified, the `_source` parameter defaults to false.
1875
+ the response. If this parameter is specified, only these source fields are
1876
+ returned. You can exclude fields from this subset using the `_source_excludes`
1877
+ query parameter. If the `_source` parameter is `false`, this parameter is
1878
+ ignored.
1879
+ :param stored_fields: A comma-separated list of stored fields to return as part
1880
+ of a hit. If no fields are specified, no stored fields are included in the
1881
+ response. If this field is specified, the `_source` parameter defaults to
1882
+ `false`.
1561
1883
  :param version: Explicit version number for concurrency control. The specified
1562
1884
  version must match the current version of the document for the request to
1563
1885
  succeed.
1564
- :param version_type: Specific version type: `external`, `external_gte`.
1886
+ :param version_type: The version type.
1565
1887
  """
1566
1888
  if index in SKIP_IN_PATH:
1567
1889
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1637,29 +1959,38 @@ class Elasticsearch(BaseClient):
1637
1959
  ] = None,
1638
1960
  ) -> HeadApiResponse:
1639
1961
  """
1640
- Check for a document source. Checks if a document's `_source` is stored.
1962
+ .. raw:: html
1963
+
1964
+ <p>Check for a document source.</p>
1965
+ <p>Check whether a document source exists in an index.
1966
+ For example:</p>
1967
+ <pre><code>HEAD my-index-000001/_source/1
1968
+ </code></pre>
1969
+ <p>A document's source is not available if it is disabled in the mapping.</p>
1970
+
1641
1971
 
1642
1972
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1643
1973
 
1644
- :param index: Comma-separated list of data streams, indices, and aliases. Supports
1645
- wildcards (`*`).
1646
- :param id: Identifier of the document.
1647
- :param preference: Specifies the node or shard the operation should be performed
1648
- on. Random by default.
1649
- :param realtime: If true, the request is real-time as opposed to near-real-time.
1650
- :param refresh: If `true`, Elasticsearch refreshes all shards involved in the
1651
- delete by query after the request completes.
1652
- :param routing: Target the specified primary shard.
1653
- :param source: `true` or `false` to return the `_source` field or not, or a list
1654
- of fields to return.
1974
+ :param index: A comma-separated list of data streams, indices, and aliases. It
1975
+ supports wildcards (`*`).
1976
+ :param id: A unique identifier for the document.
1977
+ :param preference: The node or shard the operation should be performed on. By
1978
+ default, the operation is randomized between the shard replicas.
1979
+ :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1980
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
1981
+ the document. Setting it to `true` should be done after careful thought and
1982
+ verification that this does not cause a heavy load on the system (and slow
1983
+ down indexing).
1984
+ :param routing: A custom value used to route operations to a specific shard.
1985
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
1986
+ or lists the fields to return.
1655
1987
  :param source_excludes: A comma-separated list of source fields to exclude in
1656
1988
  the response.
1657
1989
  :param source_includes: A comma-separated list of source fields to include in
1658
1990
  the response.
1659
- :param version: Explicit version number for concurrency control. The specified
1660
- version must match the current version of the document for the request to
1661
- succeed.
1662
- :param version_type: Specific version type: `external`, `external_gte`.
1991
+ :param version: The version number for concurrency control. It must match the
1992
+ current version of the document for the request to succeed.
1993
+ :param version_type: The version type.
1663
1994
  """
1664
1995
  if index in SKIP_IN_PATH:
1665
1996
  raise ValueError("Empty value passed for parameter 'index'")
@@ -1737,34 +2068,47 @@ class Elasticsearch(BaseClient):
1737
2068
  body: t.Optional[t.Dict[str, t.Any]] = None,
1738
2069
  ) -> ObjectApiResponse[t.Any]:
1739
2070
  """
1740
- Explain a document match result. Returns information about why a specific document
1741
- matches, or doesn’t match, a query.
2071
+ .. raw:: html
2072
+
2073
+ <p>Explain a document match result.
2074
+ Get information about why a specific document matches, or doesn't match, a query.
2075
+ It computes a score explanation for a query and a specific document.</p>
2076
+
1742
2077
 
1743
2078
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-explain.html>`_
1744
2079
 
1745
- :param index: Index names used to limit the request. Only a single index name
1746
- can be provided to this parameter.
1747
- :param id: Defines the document ID.
2080
+ :param index: Index names that are used to limit the request. Only a single index
2081
+ name can be provided to this parameter.
2082
+ :param id: The document identifier.
1748
2083
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
1749
- :param analyzer: Analyzer to use for the query string. This parameter can only
1750
- be used when the `q` query string parameter is specified.
2084
+ This parameter can be used only when the `q` query string parameter is specified.
2085
+ :param analyzer: The analyzer to use for the query string. This parameter can
2086
+ be used only when the `q` query string parameter is specified.
1751
2087
  :param default_operator: The default operator for query string query: `AND` or
1752
- `OR`.
1753
- :param df: Field to use as default where no field prefix is given in the query
1754
- string.
2088
+ `OR`. This parameter can be used only when the `q` query string parameter
2089
+ is specified.
2090
+ :param df: The field to use as default where no field prefix is given in the
2091
+ query string. This parameter can be used only when the `q` query string parameter
2092
+ is specified.
1755
2093
  :param lenient: If `true`, format-based query failures (such as providing text
1756
- to a numeric field) in the query string will be ignored.
1757
- :param preference: Specifies the node or shard the operation should be performed
1758
- on. Random by default.
1759
- :param q: Query in the Lucene query string syntax.
2094
+ to a numeric field) in the query string will be ignored. This parameter can
2095
+ be used only when the `q` query string parameter is specified.
2096
+ :param preference: The node or shard the operation should be performed on. It
2097
+ is random by default.
2098
+ :param q: The query in the Lucene query string syntax.
1760
2099
  :param query: Defines the search definition using the Query DSL.
1761
- :param routing: Custom value used to route operations to a specific shard.
1762
- :param source: True or false to return the `_source` field or not, or a list
2100
+ :param routing: A custom value used to route operations to a specific shard.
2101
+ :param source: `True` or `false` to return the `_source` field or not or a list
1763
2102
  of fields to return.
1764
2103
  :param source_excludes: A comma-separated list of source fields to exclude from
1765
- the response.
2104
+ the response. You can also use this parameter to exclude fields from the
2105
+ subset specified in `_source_includes` query parameter. If the `_source`
2106
+ parameter is `false`, this parameter is ignored.
1766
2107
  :param source_includes: A comma-separated list of source fields to include in
1767
- the response.
2108
+ the response. If this parameter is specified, only these source fields are
2109
+ returned. You can exclude fields from this subset using the `_source_excludes`
2110
+ query parameter. If the `_source` parameter is `false`, this parameter is
2111
+ ignored.
1768
2112
  :param stored_fields: A comma-separated list of stored fields to return in the
1769
2113
  response.
1770
2114
  """
@@ -1857,15 +2201,18 @@ class Elasticsearch(BaseClient):
1857
2201
  body: t.Optional[t.Dict[str, t.Any]] = None,
1858
2202
  ) -> ObjectApiResponse[t.Any]:
1859
2203
  """
1860
- Get the field capabilities. Get information about the capabilities of fields
1861
- among multiple indices. For data streams, the API returns field capabilities
1862
- among the stream’s backing indices. It returns runtime fields like any other
1863
- field. For example, a runtime field with a type of keyword is returned the same
1864
- as any other field that belongs to the `keyword` family.
2204
+ .. raw:: html
2205
+
2206
+ <p>Get the field capabilities.</p>
2207
+ <p>Get information about the capabilities of fields among multiple indices.</p>
2208
+ <p>For data streams, the API returns field capabilities among the stream’s backing indices.
2209
+ It returns runtime fields like any other field.
2210
+ For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the <code>keyword</code> family.</p>
2211
+
1865
2212
 
1866
2213
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-field-caps.html>`_
1867
2214
 
1868
- :param index: Comma-separated list of data streams, indices, and aliases used
2215
+ :param index: A comma-separated list of data streams, indices, and aliases used
1869
2216
  to limit the request. Supports wildcards (*). To target all data streams
1870
2217
  and indices, omit this parameter or use * or _all.
1871
2218
  :param allow_no_indices: If false, the request returns an error if any wildcard
@@ -1873,25 +2220,32 @@ class Elasticsearch(BaseClient):
1873
2220
  This behavior applies even if the request targets other open indices. For
1874
2221
  example, a request targeting `foo*,bar*` returns an error if an index starts
1875
2222
  with foo but no index starts with bar.
1876
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
1877
- request can target data streams, this argument determines whether wildcard
1878
- expressions match hidden data streams. Supports comma-separated values, such
1879
- as `open,hidden`.
1880
- :param fields: List of fields to retrieve capabilities for. Wildcard (`*`) expressions
1881
- are supported.
1882
- :param filters: An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent
2223
+ :param expand_wildcards: The type of index that wildcard patterns can match.
2224
+ If the request can target data streams, this argument determines whether
2225
+ wildcard expressions match hidden data streams. Supports comma-separated
2226
+ values, such as `open,hidden`.
2227
+ :param fields: A list of fields to retrieve capabilities for. Wildcard (`*`)
2228
+ expressions are supported.
2229
+ :param filters: A comma-separated list of filters to apply to the response.
1883
2230
  :param ignore_unavailable: If `true`, missing or closed indices are not included
1884
2231
  in the response.
1885
2232
  :param include_empty_fields: If false, empty fields are not included in the response.
1886
2233
  :param include_unmapped: If true, unmapped fields are included in the response.
1887
- :param index_filter: Allows to filter indices if the provided query rewrites
1888
- to match_none on every shard.
1889
- :param runtime_mappings: Defines ad-hoc runtime fields in the request similar
2234
+ :param index_filter: Filter indices if the provided query rewrites to `match_none`
2235
+ on every shard. IMPORTANT: The filtering is done on a best-effort basis,
2236
+ it uses index statistics and mappings to rewrite queries to `match_none`
2237
+ instead of fully running the request. For instance a range query over a date
2238
+ field can rewrite to `match_none` if all documents within a shard (including
2239
+ deleted documents) are outside of the provided range. However, not all queries
2240
+ can rewrite to `match_none` so this API may return an index even if the provided
2241
+ filter matches no document.
2242
+ :param runtime_mappings: Define ad-hoc runtime fields in the request similar
1890
2243
  to the way it is done in search requests. These fields exist only as part
1891
2244
  of the query and take precedence over fields defined with the same name in
1892
2245
  the index mappings.
1893
- :param types: Only return results for fields that have one of the types in the
1894
- list
2246
+ :param types: A comma-separated list of field types to include. Any fields that
2247
+ do not match one of these types will be excluded from the results. It defaults
2248
+ to empty, meaning that all field types are returned.
1895
2249
  """
1896
2250
  __path_parts: t.Dict[str, str]
1897
2251
  if index not in SKIP_IN_PATH:
@@ -1977,36 +2331,87 @@ class Elasticsearch(BaseClient):
1977
2331
  ] = None,
1978
2332
  ) -> ObjectApiResponse[t.Any]:
1979
2333
  """
1980
- Get a document by its ID. Retrieves the document with the specified ID from an
1981
- index.
2334
+ .. raw:: html
2335
+
2336
+ <p>Get a document by its ID.</p>
2337
+ <p>Get a document and its source or stored fields from an index.</p>
2338
+ <p>By default, this API is realtime and is not affected by the refresh rate of the index (when data will become visible for search).
2339
+ In the case where stored fields are requested with the <code>stored_fields</code> parameter and the document has been updated but is not yet refreshed, the API will have to parse and analyze the source to extract the stored fields.
2340
+ To turn off realtime behavior, set the <code>realtime</code> parameter to false.</p>
2341
+ <p><strong>Source filtering</strong></p>
2342
+ <p>By default, the API returns the contents of the <code>_source</code> field unless you have used the <code>stored_fields</code> parameter or the <code>_source</code> field is turned off.
2343
+ You can turn off <code>_source</code> retrieval by using the <code>_source</code> parameter:</p>
2344
+ <pre><code>GET my-index-000001/_doc/0?_source=false
2345
+ </code></pre>
2346
+ <p>If you only need one or two fields from the <code>_source</code>, use the <code>_source_includes</code> or <code>_source_excludes</code> parameters to include or filter out particular fields.
2347
+ This can be helpful with large documents where partial retrieval can save on network overhead
2348
+ Both parameters take a comma separated list of fields or wildcard expressions.
2349
+ For example:</p>
2350
+ <pre><code>GET my-index-000001/_doc/0?_source_includes=*.id&amp;_source_excludes=entities
2351
+ </code></pre>
2352
+ <p>If you only want to specify includes, you can use a shorter notation:</p>
2353
+ <pre><code>GET my-index-000001/_doc/0?_source=*.id
2354
+ </code></pre>
2355
+ <p><strong>Routing</strong></p>
2356
+ <p>If routing is used during indexing, the routing value also needs to be specified to retrieve a document.
2357
+ For example:</p>
2358
+ <pre><code>GET my-index-000001/_doc/2?routing=user1
2359
+ </code></pre>
2360
+ <p>This request gets the document with ID 2, but it is routed based on the user.
2361
+ The document is not fetched if the correct routing is not specified.</p>
2362
+ <p><strong>Distributed</strong></p>
2363
+ <p>The GET operation is hashed into a specific shard ID.
2364
+ It is then redirected to one of the replicas within that shard ID and returns the result.
2365
+ The replicas are the primary shard and its replicas within that shard ID group.
2366
+ This means that the more replicas you have, the better your GET scaling will be.</p>
2367
+ <p><strong>Versioning support</strong></p>
2368
+ <p>You can use the <code>version</code> parameter to retrieve the document only if its current version is equal to the specified one.</p>
2369
+ <p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
2370
+ The old version of the document doesn't disappear immediately, although you won't be able to access it.
2371
+ Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
2372
+
1982
2373
 
1983
2374
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
1984
2375
 
1985
- :param index: Name of the index that contains the document.
1986
- :param id: Unique identifier of the document.
1987
- :param force_synthetic_source: Should this request force synthetic _source? Use
1988
- this to test if the mapping supports synthetic _source and to get a sense
1989
- of the worst case performance. Fetches with this enabled will be slower the
1990
- enabling synthetic source natively in the index.
1991
- :param preference: Specifies the node or shard the operation should be performed
1992
- on. Random by default.
2376
+ :param index: The name of the index that contains the document.
2377
+ :param id: A unique document identifier.
2378
+ :param force_synthetic_source: Indicates whether the request forces synthetic
2379
+ `_source`. Use this paramater to test if the mapping supports synthetic `_source`
2380
+ and to get a sense of the worst case performance. Fetches with this parameter
2381
+ enabled will be slower than enabling synthetic source natively in the index.
2382
+ :param preference: The node or shard the operation should be performed on. By
2383
+ default, the operation is randomized between the shard replicas. If it is
2384
+ set to `_local`, the operation will prefer to be run on a local allocated
2385
+ shard when possible. If it is set to a custom value, the value is used to
2386
+ guarantee that the same shards will be used for the same custom value. This
2387
+ can help with "jumping values" when hitting different shards in different
2388
+ refresh states. A sample value can be something like the web session ID or
2389
+ the user name.
1993
2390
  :param realtime: If `true`, the request is real-time as opposed to near-real-time.
1994
- :param refresh: If true, Elasticsearch refreshes the affected shards to make
1995
- this operation visible to search. If false, do nothing with refreshes.
1996
- :param routing: Target the specified primary shard.
1997
- :param source: True or false to return the _source field or not, or a list of
1998
- fields to return.
1999
- :param source_excludes: A comma-separated list of source fields to exclude in
2000
- the response.
2391
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
2392
+ the document. Setting it to `true` should be done after careful thought and
2393
+ verification that this does not cause a heavy load on the system (and slow
2394
+ down indexing).
2395
+ :param routing: A custom value used to route operations to a specific shard.
2396
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
2397
+ or lists the fields to return.
2398
+ :param source_excludes: A comma-separated list of source fields to exclude from
2399
+ the response. You can also use this parameter to exclude fields from the
2400
+ subset specified in `_source_includes` query parameter. If the `_source`
2401
+ parameter is `false`, this parameter is ignored.
2001
2402
  :param source_includes: A comma-separated list of source fields to include in
2002
- the response.
2003
- :param stored_fields: List of stored fields to return as part of a hit. If no
2004
- fields are specified, no stored fields are included in the response. If this
2005
- field is specified, the `_source` parameter defaults to false.
2006
- :param version: Explicit version number for concurrency control. The specified
2007
- version must match the current version of the document for the request to
2008
- succeed.
2009
- :param version_type: Specific version type: internal, external, external_gte.
2403
+ the response. If this parameter is specified, only these source fields are
2404
+ returned. You can exclude fields from this subset using the `_source_excludes`
2405
+ query parameter. If the `_source` parameter is `false`, this parameter is
2406
+ ignored.
2407
+ :param stored_fields: A comma-separated list of stored fields to return as part
2408
+ of a hit. If no fields are specified, no stored fields are included in the
2409
+ response. If this field is specified, the `_source` parameter defaults to
2410
+ `false`. Only leaf fields can be retrieved with the `stored_field` option.
2411
+ Object fields can't be returned;​if specified, the request fails.
2412
+ :param version: The version number for concurrency control. It must match the
2413
+ current version of the document for the request to succeed.
2414
+ :param version_type: The version type.
2010
2415
  """
2011
2416
  if index in SKIP_IN_PATH:
2012
2417
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2067,12 +2472,19 @@ class Elasticsearch(BaseClient):
2067
2472
  pretty: t.Optional[bool] = None,
2068
2473
  ) -> ObjectApiResponse[t.Any]:
2069
2474
  """
2070
- Get a script or search template. Retrieves a stored script or search template.
2475
+ .. raw:: html
2476
+
2477
+ <p>Get a script or search template.
2478
+ Retrieves a stored script or search template.</p>
2479
+
2071
2480
 
2072
2481
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2073
2482
 
2074
- :param id: Identifier for the stored script or search template.
2075
- :param master_timeout: Specify timeout for connection to master
2483
+ :param id: The identifier for the stored script or search template.
2484
+ :param master_timeout: The period to wait for the master node. If the master
2485
+ node is not available before the timeout expires, the request fails and returns
2486
+ an error. It can also be set to `-1` to indicate that the request should
2487
+ never timeout.
2076
2488
  """
2077
2489
  if id in SKIP_IN_PATH:
2078
2490
  raise ValueError("Empty value passed for parameter 'id'")
@@ -2109,9 +2521,13 @@ class Elasticsearch(BaseClient):
2109
2521
  pretty: t.Optional[bool] = None,
2110
2522
  ) -> ObjectApiResponse[t.Any]:
2111
2523
  """
2112
- Get script contexts. Get a list of supported script contexts and their methods.
2524
+ .. raw:: html
2525
+
2526
+ <p>Get script contexts.</p>
2527
+ <p>Get a list of supported script contexts and their methods.</p>
2528
+
2113
2529
 
2114
- `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-contexts.html>`_
2530
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-script-contexts-api.html>`_
2115
2531
  """
2116
2532
  __path_parts: t.Dict[str, str] = {}
2117
2533
  __path = "/_script_context"
@@ -2144,9 +2560,13 @@ class Elasticsearch(BaseClient):
2144
2560
  pretty: t.Optional[bool] = None,
2145
2561
  ) -> ObjectApiResponse[t.Any]:
2146
2562
  """
2147
- Get script languages. Get a list of available script types, languages, and contexts.
2563
+ .. raw:: html
2148
2564
 
2149
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
2565
+ <p>Get script languages.</p>
2566
+ <p>Get a list of available script types, languages, and contexts.</p>
2567
+
2568
+
2569
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-script-languages-api.html>`_
2150
2570
  """
2151
2571
  __path_parts: t.Dict[str, str] = {}
2152
2572
  __path = "/_script_language"
@@ -2199,29 +2619,41 @@ class Elasticsearch(BaseClient):
2199
2619
  ] = None,
2200
2620
  ) -> ObjectApiResponse[t.Any]:
2201
2621
  """
2202
- Get a document's source. Returns the source of a document.
2622
+ .. raw:: html
2623
+
2624
+ <p>Get a document's source.</p>
2625
+ <p>Get the source of a document.
2626
+ For example:</p>
2627
+ <pre><code>GET my-index-000001/_source/1
2628
+ </code></pre>
2629
+ <p>You can use the source filtering parameters to control which parts of the <code>_source</code> are returned:</p>
2630
+ <pre><code>GET my-index-000001/_source/1/?_source_includes=*.id&amp;_source_excludes=entities
2631
+ </code></pre>
2632
+
2203
2633
 
2204
2634
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-get.html>`_
2205
2635
 
2206
- :param index: Name of the index that contains the document.
2207
- :param id: Unique identifier of the document.
2208
- :param preference: Specifies the node or shard the operation should be performed
2209
- on. Random by default.
2210
- :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time.
2211
- :param refresh: If true, Elasticsearch refreshes the affected shards to make
2212
- this operation visible to search. If false, do nothing with refreshes.
2213
- :param routing: Target the specified primary shard.
2214
- :param source: True or false to return the _source field or not, or a list of
2215
- fields to return.
2636
+ :param index: The name of the index that contains the document.
2637
+ :param id: A unique document identifier.
2638
+ :param preference: The node or shard the operation should be performed on. By
2639
+ default, the operation is randomized between the shard replicas.
2640
+ :param realtime: If `true`, the request is real-time as opposed to near-real-time.
2641
+ :param refresh: If `true`, the request refreshes the relevant shards before retrieving
2642
+ the document. Setting it to `true` should be done after careful thought and
2643
+ verification that this does not cause a heavy load on the system (and slow
2644
+ down indexing).
2645
+ :param routing: A custom value used to route operations to a specific shard.
2646
+ :param source: Indicates whether to return the `_source` field (`true` or `false`)
2647
+ or lists the fields to return.
2216
2648
  :param source_excludes: A comma-separated list of source fields to exclude in
2217
2649
  the response.
2218
2650
  :param source_includes: A comma-separated list of source fields to include in
2219
2651
  the response.
2220
- :param stored_fields:
2221
- :param version: Explicit version number for concurrency control. The specified
2222
- version must match the current version of the document for the request to
2223
- succeed.
2224
- :param version_type: Specific version type: internal, external, external_gte.
2652
+ :param stored_fields: A comma-separated list of stored fields to return as part
2653
+ of a hit.
2654
+ :param version: The version number for concurrency control. It must match the
2655
+ current version of the document for the request to succeed.
2656
+ :param version_type: The version type.
2225
2657
  """
2226
2658
  if index in SKIP_IN_PATH:
2227
2659
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2282,26 +2714,22 @@ class Elasticsearch(BaseClient):
2282
2714
  verbose: t.Optional[bool] = None,
2283
2715
  ) -> ObjectApiResponse[t.Any]:
2284
2716
  """
2285
- Get the cluster health. Get a report with the health status of an Elasticsearch
2286
- cluster. The report contains a list of indicators that compose Elasticsearch
2287
- functionality. Each indicator has a health status of: green, unknown, yellow
2288
- or red. The indicator will provide an explanation and metadata describing the
2289
- reason for its current health status. The cluster’s status is controlled by the
2290
- worst indicator status. In the event that an indicator’s status is non-green,
2291
- a list of impacts may be present in the indicator result which detail the functionalities
2292
- that are negatively affected by the health issue. Each impact carries with it
2293
- a severity level, an area of the system that is affected, and a simple description
2294
- of the impact on the system. Some health indicators can determine the root cause
2295
- of a health problem and prescribe a set of steps that can be performed in order
2296
- to improve the health of the system. The root cause and remediation steps are
2297
- encapsulated in a diagnosis. A diagnosis contains a cause detailing a root cause
2298
- analysis, an action containing a brief description of the steps to take to fix
2299
- the problem, the list of affected resources (if applicable), and a detailed step-by-step
2300
- troubleshooting guide to fix the diagnosed problem. NOTE: The health indicators
2301
- perform root cause analysis of non-green health statuses. This can be computationally
2302
- expensive when called frequently. When setting up automated polling of the API
2303
- for health status, set verbose to false to disable the more expensive analysis
2304
- logic.
2717
+ .. raw:: html
2718
+
2719
+ <p>Get the cluster health.
2720
+ Get a report with the health status of an Elasticsearch cluster.
2721
+ The report contains a list of indicators that compose Elasticsearch functionality.</p>
2722
+ <p>Each indicator has a health status of: green, unknown, yellow or red.
2723
+ The indicator will provide an explanation and metadata describing the reason for its current health status.</p>
2724
+ <p>The cluster’s status is controlled by the worst indicator status.</p>
2725
+ <p>In the event that an indicator’s status is non-green, a list of impacts may be present in the indicator result which detail the functionalities that are negatively affected by the health issue.
2726
+ Each impact carries with it a severity level, an area of the system that is affected, and a simple description of the impact on the system.</p>
2727
+ <p>Some health indicators can determine the root cause of a health problem and prescribe a set of steps that can be performed in order to improve the health of the system.
2728
+ The root cause and remediation steps are encapsulated in a diagnosis.
2729
+ A diagnosis contains a cause detailing a root cause analysis, an action containing a brief description of the steps to take to fix the problem, the list of affected resources (if applicable), and a detailed step-by-step troubleshooting guide to fix the diagnosed problem.</p>
2730
+ <p>NOTE: The health indicators perform root cause analysis of non-green health statuses. This can be computationally expensive when called frequently.
2731
+ When setting up automated polling of the API for health status, set verbose to false to disable the more expensive analysis logic.</p>
2732
+
2305
2733
 
2306
2734
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/health-api.html>`_
2307
2735
 
@@ -2376,44 +2804,148 @@ class Elasticsearch(BaseClient):
2376
2804
  ] = None,
2377
2805
  ) -> ObjectApiResponse[t.Any]:
2378
2806
  """
2379
- Index a document. Adds a JSON document to the specified data stream or index
2380
- and makes it searchable. If the target is an index and the document already exists,
2381
- the request updates the document and increments its version.
2807
+ .. raw:: html
2808
+
2809
+ <p>Create or update a document in an index.</p>
2810
+ <p>Add a JSON document to the specified data stream or index and make it searchable.
2811
+ If the target is an index and the document already exists, the request updates the document and increments its version.</p>
2812
+ <p>NOTE: You cannot use this API to send update requests for existing documents in a data stream.</p>
2813
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
2814
+ <ul>
2815
+ <li>To add or overwrite a document using the <code>PUT /&lt;target&gt;/_doc/&lt;_id&gt;</code> request format, you must have the <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
2816
+ <li>To add a document using the <code>POST /&lt;target&gt;/_doc/</code> request format, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
2817
+ <li>To automatically create a data stream or index with this API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
2818
+ </ul>
2819
+ <p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
2820
+ <p>NOTE: Replica shards might not all be started when an indexing operation returns successfully.
2821
+ By default, only the primary is required. Set <code>wait_for_active_shards</code> to change this default behavior.</p>
2822
+ <p><strong>Automatically create data streams and indices</strong></p>
2823
+ <p>If the request's target doesn't exist and matches an index template with a <code>data_stream</code> definition, the index operation automatically creates the data stream.</p>
2824
+ <p>If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates.</p>
2825
+ <p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
2826
+ <p>If no mapping exists, the index operation creates a dynamic mapping.
2827
+ By default, new fields and objects are automatically added to the mapping if needed.</p>
2828
+ <p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
2829
+ If it is <code>true</code>, any index can be created automatically.
2830
+ You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to <code>false</code> to turn off automatic index creation entirely.
2831
+ Specify a comma-separated list of patterns you want to allow or prefix each pattern with <code>+</code> or <code>-</code> to indicate whether it should be allowed or blocked.
2832
+ When a list is specified, the default behaviour is to disallow.</p>
2833
+ <p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
2834
+ It does not affect the creation of data streams.</p>
2835
+ <p><strong>Optimistic concurrency control</strong></p>
2836
+ <p>Index operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the <code>if_seq_no</code> and <code>if_primary_term</code> parameters.
2837
+ If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
2838
+ <p><strong>Routing</strong></p>
2839
+ <p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
2840
+ For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the <code>routing</code> parameter.</p>
2841
+ <p>When setting up explicit mapping, you can also use the <code>_routing</code> field to direct the index operation to extract the routing value from the document itself.
2842
+ This does come at the (very minimal) cost of an additional document parsing pass.
2843
+ If the <code>_routing</code> mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted.</p>
2844
+ <p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
2845
+ <ul>
2846
+ <li>** Distributed**</li>
2847
+ </ul>
2848
+ <p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
2849
+ After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
2850
+ <p><strong>Active shards</strong></p>
2851
+ <p>To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation.
2852
+ If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs.
2853
+ By default, write operations only wait for the primary shards to be active before proceeding (that is to say <code>wait_for_active_shards</code> is <code>1</code>).
2854
+ This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
2855
+ To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
2856
+ <p>Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is <code>number_of_replicas</code>+1).
2857
+ Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
2858
+ <p>For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes).
2859
+ If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
2860
+ This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data.
2861
+ If <code>wait_for_active_shards</code> is set on the request to <code>3</code> (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding.
2862
+ This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
2863
+ However, if you set <code>wait_for_active_shards</code> to <code>all</code> (or to <code>4</code>, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index.
2864
+ The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
2865
+ <p>It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts.
2866
+ After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary.
2867
+ The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
2868
+ <p><strong>No operation (noop) updates</strong></p>
2869
+ <p>When updating a document by using this API, a new version of the document is always created even if the document hasn't changed.
2870
+ If this isn't acceptable use the <code>_update</code> API with <code>detect_noop</code> set to <code>true</code>.
2871
+ The <code>detect_noop</code> option isn't available on this API because it doesn’t fetch the old source and isn't able to compare it against the new source.</p>
2872
+ <p>There isn't a definitive rule for when noop updates aren't acceptable.
2873
+ It's a combination of lots of factors like how frequently your data source sends updates that are actually noops and how many queries per second Elasticsearch runs on the shard receiving the updates.</p>
2874
+ <p><strong>Versioning</strong></p>
2875
+ <p>Each indexed document is given a version number.
2876
+ By default, internal versioning is used that starts at 1 and increments with each update, deletes included.
2877
+ Optionally, the version number can be set to an external value (for example, if maintained in a database).
2878
+ To enable this functionality, <code>version_type</code> should be set to <code>external</code>.
2879
+ The value provided must be a numeric, long value greater than or equal to 0, and less than around <code>9.2e+18</code>.</p>
2880
+ <p>NOTE: Versioning is completely real time, and is not affected by the near real time aspects of search operations.
2881
+ If no version is provided, the operation runs without any version checks.</p>
2882
+ <p>When using the external version type, the system checks to see if the version number passed to the index request is greater than the version of the currently stored document.
2883
+ If true, the document will be indexed and the new version number used.
2884
+ If the value provided is less than or equal to the stored document's version number, a version conflict will occur and the index operation will fail. For example:</p>
2885
+ <pre><code>PUT my-index-000001/_doc/1?version=2&amp;version_type=external
2886
+ {
2887
+ &quot;user&quot;: {
2888
+ &quot;id&quot;: &quot;elkbee&quot;
2889
+ }
2890
+ }
2891
+
2892
+ In this example, the operation will succeed since the supplied version of 2 is higher than the current document version of 1.
2893
+ If the document was already updated and its version was set to 2 or higher, the indexing command will fail and result in a conflict (409 HTTP status code).
2894
+
2895
+ A nice side effect is that there is no need to maintain strict ordering of async indexing operations run as a result of changes to a source database, as long as version numbers from the source database are used.
2896
+ Even the simple case of updating the Elasticsearch index using data from a database is simplified if external versioning is used, as only the latest version will be used if the index operations arrive out of order.
2897
+ </code></pre>
2898
+
2382
2899
 
2383
2900
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-index_.html>`_
2384
2901
 
2385
- :param index: Name of the data stream or index to target.
2902
+ :param index: The name of the data stream or index to target. If the target doesn't
2903
+ exist and matches the name or wildcard (`*`) pattern of an index template
2904
+ with a `data_stream` definition, this request creates the data stream. If
2905
+ the target doesn't exist and doesn't match a data stream template, this request
2906
+ creates the index. You can check for existing targets with the resolve index
2907
+ API.
2386
2908
  :param document:
2387
- :param id: Unique identifier for the document.
2909
+ :param id: A unique identifier for the document. To automatically generate a
2910
+ document ID, use the `POST /<target>/_doc/` request format and omit this
2911
+ parameter.
2388
2912
  :param if_primary_term: Only perform the operation if the document has this primary
2389
2913
  term.
2390
2914
  :param if_seq_no: Only perform the operation if the document has this sequence
2391
2915
  number.
2392
- :param op_type: Set to create to only index the document if it does not already
2916
+ :param op_type: Set to `create` to only index the document if it does not already
2393
2917
  exist (put if absent). If a document with the specified `_id` already exists,
2394
- the indexing operation will fail. Same as using the `<index>/_create` endpoint.
2395
- Valid values: `index`, `create`. If document id is specified, it defaults
2396
- to `index`. Otherwise, it defaults to `create`.
2397
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
2918
+ the indexing operation will fail. The behavior is the same as using the `<index>/_create`
2919
+ endpoint. If a document ID is specified, this paramater defaults to `index`.
2920
+ Otherwise, it defaults to `create`. If the request targets a data stream,
2921
+ an `op_type` of `create` is required.
2922
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
2398
2923
  If the index has a default ingest pipeline specified, then setting the value
2399
2924
  to `_none` disables the default ingest pipeline for this request. If a final
2400
2925
  pipeline is configured it will always run, regardless of the value of this
2401
2926
  parameter.
2402
2927
  :param refresh: If `true`, Elasticsearch refreshes the affected shards to make
2403
- this operation visible to search, if `wait_for` then wait for a refresh to
2404
- make this operation visible to search, if `false` do nothing with refreshes.
2405
- Valid values: `true`, `false`, `wait_for`.
2928
+ this operation visible to search. If `wait_for`, it waits for a refresh to
2929
+ make this operation visible to search. If `false`, it does nothing with refreshes.
2406
2930
  :param require_alias: If `true`, the destination must be an index alias.
2407
- :param routing: Custom value used to route operations to a specific shard.
2408
- :param timeout: Period the request waits for the following operations: automatic
2409
- index creation, dynamic mapping updates, waiting for active shards.
2410
- :param version: Explicit version number for concurrency control. The specified
2411
- version must match the current version of the document for the request to
2412
- succeed.
2413
- :param version_type: Specific version type: `external`, `external_gte`.
2931
+ :param routing: A custom value that is used to route operations to a specific
2932
+ shard.
2933
+ :param timeout: The period the request waits for the following operations: automatic
2934
+ index creation, dynamic mapping updates, waiting for active shards. This
2935
+ parameter is useful for situations where the primary shard assigned to perform
2936
+ the operation might not be available when the operation runs. Some reasons
2937
+ for this might be that the primary shard is currently recovering from a gateway
2938
+ or undergoing relocation. By default, the operation will wait on the primary
2939
+ shard to become available for at least 1 minute before failing and responding
2940
+ with an error. The actual wait time could be longer, particularly when multiple
2941
+ waits occur.
2942
+ :param version: An explicit version number for concurrency control. It must be
2943
+ a non-negative long number.
2944
+ :param version_type: The version type.
2414
2945
  :param wait_for_active_shards: The number of shard copies that must be active
2415
- before proceeding with the operation. Set to all or any positive integer
2416
- up to the total number of shards in the index (`number_of_replicas+1`).
2946
+ before proceeding with the operation. You can set it to `all` or any positive
2947
+ integer up to the total number of shards in the index (`number_of_replicas+1`).
2948
+ The default value of `1` means it waits for each primary shard to be active.
2417
2949
  """
2418
2950
  if index in SKIP_IN_PATH:
2419
2951
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2487,9 +3019,13 @@ class Elasticsearch(BaseClient):
2487
3019
  pretty: t.Optional[bool] = None,
2488
3020
  ) -> ObjectApiResponse[t.Any]:
2489
3021
  """
2490
- Get cluster info. Returns basic information about the cluster.
3022
+ .. raw:: html
3023
+
3024
+ <p>Get cluster info.
3025
+ Get basic build, version, and cluster information.</p>
3026
+
2491
3027
 
2492
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/index.html>`_
3028
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/rest-api-root.html>`_
2493
3029
  """
2494
3030
  __path_parts: t.Dict[str, str] = {}
2495
3031
  __path = "/"
@@ -2544,38 +3080,48 @@ class Elasticsearch(BaseClient):
2544
3080
  body: t.Optional[t.Dict[str, t.Any]] = None,
2545
3081
  ) -> ObjectApiResponse[t.Any]:
2546
3082
  """
2547
- Run a knn search. NOTE: The kNN search API has been replaced by the `knn` option
2548
- in the search API. Perform a k-nearest neighbor (kNN) search on a dense_vector
2549
- field and return the matching documents. Given a query vector, the API finds
2550
- the k closest vectors and returns those documents as search hits. Elasticsearch
2551
- uses the HNSW algorithm to support efficient kNN search. Like most kNN algorithms,
2552
- HNSW is an approximate method that sacrifices result accuracy for improved search
2553
- speed. This means the results returned are not always the true k closest neighbors.
2554
- The kNN search API supports restricting the search using a filter. The search
2555
- will return the top k documents that also match the filter query.
2556
-
2557
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
3083
+ .. raw:: html
3084
+
3085
+ <p>Run a knn search.</p>
3086
+ <p>NOTE: The kNN search API has been replaced by the <code>knn</code> option in the search API.</p>
3087
+ <p>Perform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents.
3088
+ Given a query vector, the API finds the k closest vectors and returns those documents as search hits.</p>
3089
+ <p>Elasticsearch uses the HNSW algorithm to support efficient kNN search.
3090
+ Like most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed.
3091
+ This means the results returned are not always the true k closest neighbors.</p>
3092
+ <p>The kNN search API supports restricting the search using a filter.
3093
+ The search will return the top k documents that also match the filter query.</p>
3094
+ <p>A kNN search response has the exact same structure as a search API response.
3095
+ However, certain sections have a meaning specific to kNN search:</p>
3096
+ <ul>
3097
+ <li>The document <code>_score</code> is determined by the similarity between the query and document vector.</li>
3098
+ <li>The <code>hits.total</code> object contains the total number of nearest neighbor candidates considered, which is <code>num_candidates * num_shards</code>. The <code>hits.total.relation</code> will always be <code>eq</code>, indicating an exact value.</li>
3099
+ </ul>
3100
+
3101
+
3102
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/knn-search-api.html>`_
2558
3103
 
2559
3104
  :param index: A comma-separated list of index names to search; use `_all` or
2560
- to perform the operation on all indices
2561
- :param knn: kNN query to execute
3105
+ to perform the operation on all indices.
3106
+ :param knn: The kNN query to run.
2562
3107
  :param docvalue_fields: The request returns doc values for field names matching
2563
- these patterns in the hits.fields property of the response. Accepts wildcard
2564
- (*) patterns.
3108
+ these patterns in the `hits.fields` property of the response. It accepts
3109
+ wildcard (`*`) patterns.
2565
3110
  :param fields: The request returns values for field names matching these patterns
2566
- in the hits.fields property of the response. Accepts wildcard (*) patterns.
2567
- :param filter: Query to filter the documents that can match. The kNN search will
2568
- return the top `k` documents that also match this filter. The value can be
2569
- a single query or a list of queries. If `filter` isn't provided, all documents
2570
- are allowed to match.
2571
- :param routing: A comma-separated list of specific routing values
3111
+ in the `hits.fields` property of the response. It accepts wildcard (`*`)
3112
+ patterns.
3113
+ :param filter: A query to filter the documents that can match. The kNN search
3114
+ will return the top `k` documents that also match this filter. The value
3115
+ can be a single query or a list of queries. If `filter` isn't provided, all
3116
+ documents are allowed to match.
3117
+ :param routing: A comma-separated list of specific routing values.
2572
3118
  :param source: Indicates which source fields are returned for matching documents.
2573
- These fields are returned in the hits._source property of the search response.
2574
- :param stored_fields: List of stored fields to return as part of a hit. If no
2575
- fields are specified, no stored fields are included in the response. If this
2576
- field is specified, the _source parameter defaults to false. You can pass
2577
- _source: true to return both source fields and stored fields in the search
2578
- response.
3119
+ These fields are returned in the `hits._source` property of the search response.
3120
+ :param stored_fields: A list of stored fields to return as part of a hit. If
3121
+ no fields are specified, no stored fields are included in the response. If
3122
+ this field is specified, the `_source` parameter defaults to `false`. You
3123
+ can pass `_source: true` to return both source fields and stored fields in
3124
+ the search response.
2579
3125
  """
2580
3126
  if index in SKIP_IN_PATH:
2581
3127
  raise ValueError("Empty value passed for parameter 'index'")
@@ -2653,10 +3199,21 @@ class Elasticsearch(BaseClient):
2653
3199
  body: t.Optional[t.Dict[str, t.Any]] = None,
2654
3200
  ) -> ObjectApiResponse[t.Any]:
2655
3201
  """
2656
- Get multiple documents. Get multiple JSON documents by ID from one or more indices.
2657
- If you specify an index in the request URI, you only need to specify the document
2658
- IDs in the request body. To ensure fast responses, this multi get (mget) API
2659
- responds with partial results if one or more shards fail.
3202
+ .. raw:: html
3203
+
3204
+ <p>Get multiple documents.</p>
3205
+ <p>Get multiple JSON documents by ID from one or more indices.
3206
+ If you specify an index in the request URI, you only need to specify the document IDs in the request body.
3207
+ To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail.</p>
3208
+ <p><strong>Filter source fields</strong></p>
3209
+ <p>By default, the <code>_source</code> field is returned for every document (if stored).
3210
+ Use the <code>_source</code> and <code>_source_include</code> or <code>source_exclude</code> attributes to filter what fields are returned for a particular document.
3211
+ You can include the <code>_source</code>, <code>_source_includes</code>, and <code>_source_excludes</code> query parameters in the request URI to specify the defaults to use when there are no per-document instructions.</p>
3212
+ <p><strong>Get stored fields</strong></p>
3213
+ <p>Use the <code>stored_fields</code> attribute to specify the set of stored fields you want to retrieve.
3214
+ Any requested fields that are not stored are ignored.
3215
+ You can include the <code>stored_fields</code> query parameter in the request URI to specify the defaults to use when there are no per-document instructions.</p>
3216
+
2660
3217
 
2661
3218
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-get.html>`_
2662
3219
 
@@ -2777,13 +3334,21 @@ class Elasticsearch(BaseClient):
2777
3334
  typed_keys: t.Optional[bool] = None,
2778
3335
  ) -> ObjectApiResponse[t.Any]:
2779
3336
  """
2780
- Run multiple searches. The format of the request is similar to the bulk API format
2781
- and makes use of the newline delimited JSON (NDJSON) format. The structure is
2782
- as follows: ``` header\\n body\\n header\\n body\\n ``` This structure is specifically
2783
- optimized to reduce parsing if a specific search ends up redirected to another
2784
- node. IMPORTANT: The final line of data must end with a newline character `\\n`.
2785
- Each newline character may be preceded by a carriage return `\\r`. When sending
2786
- requests to this endpoint the `Content-Type` header should be set to `application/x-ndjson`.
3337
+ .. raw:: html
3338
+
3339
+ <p>Run multiple searches.</p>
3340
+ <p>The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format.
3341
+ The structure is as follows:</p>
3342
+ <pre><code>header\\n
3343
+ body\\n
3344
+ header\\n
3345
+ body\\n
3346
+ </code></pre>
3347
+ <p>This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node.</p>
3348
+ <p>IMPORTANT: The final line of data must end with a newline character <code>\\n</code>.
3349
+ Each newline character may be preceded by a carriage return <code>\\r</code>.
3350
+ When sending requests to this endpoint the <code>Content-Type</code> header should be set to <code>application/x-ndjson</code>.</p>
3351
+
2787
3352
 
2788
3353
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
2789
3354
 
@@ -2915,22 +3480,35 @@ class Elasticsearch(BaseClient):
2915
3480
  typed_keys: t.Optional[bool] = None,
2916
3481
  ) -> ObjectApiResponse[t.Any]:
2917
3482
  """
2918
- Run multiple templated searches.
3483
+ .. raw:: html
3484
+
3485
+ <p>Run multiple templated searches.</p>
3486
+ <p>Run multiple templated searches with a single request.
3487
+ If you are providing a text file or text input to <code>curl</code>, use the <code>--data-binary</code> flag instead of <code>-d</code> to preserve newlines.
3488
+ For example:</p>
3489
+ <pre><code>$ cat requests
3490
+ { &quot;index&quot;: &quot;my-index&quot; }
3491
+ { &quot;id&quot;: &quot;my-search-template&quot;, &quot;params&quot;: { &quot;query_string&quot;: &quot;hello world&quot;, &quot;from&quot;: 0, &quot;size&quot;: 10 }}
3492
+ { &quot;index&quot;: &quot;my-other-index&quot; }
3493
+ { &quot;id&quot;: &quot;my-other-search-template&quot;, &quot;params&quot;: { &quot;query_type&quot;: &quot;match_all&quot; }}
3494
+
3495
+ $ curl -H &quot;Content-Type: application/x-ndjson&quot; -XGET localhost:9200/_msearch/template --data-binary &quot;@requests&quot;; echo
3496
+ </code></pre>
2919
3497
 
2920
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-multi-search.html>`_
3498
+
3499
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/multi-search-template.html>`_
2921
3500
 
2922
3501
  :param search_templates:
2923
- :param index: Comma-separated list of data streams, indices, and aliases to search.
2924
- Supports wildcards (`*`). To search all data streams and indices, omit this
2925
- parameter or use `*`.
3502
+ :param index: A comma-separated list of data streams, indices, and aliases to
3503
+ search. It supports wildcards (`*`). To search all data streams and indices,
3504
+ omit this parameter or use `*`.
2926
3505
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
2927
3506
  for cross-cluster search requests.
2928
- :param max_concurrent_searches: Maximum number of concurrent searches the API
2929
- can run.
3507
+ :param max_concurrent_searches: The maximum number of concurrent searches the
3508
+ API can run.
2930
3509
  :param rest_total_hits_as_int: If `true`, the response returns `hits.total` as
2931
3510
  an integer. If `false`, it returns `hits.total` as an object.
2932
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
2933
- `dfs_query_then_fetch`.
3511
+ :param search_type: The type of the search operation.
2934
3512
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
2935
3513
  names with their respective types.
2936
3514
  """
@@ -3010,34 +3588,41 @@ class Elasticsearch(BaseClient):
3010
3588
  body: t.Optional[t.Dict[str, t.Any]] = None,
3011
3589
  ) -> ObjectApiResponse[t.Any]:
3012
3590
  """
3013
- Get multiple term vectors. You can specify existing documents by index and ID
3014
- or provide artificial documents in the body of the request. You can specify the
3015
- index in the request body or request URI. The response contains a `docs` array
3016
- with all the fetched termvectors. Each element has the structure provided by
3017
- the termvectors API.
3591
+ .. raw:: html
3592
+
3593
+ <p>Get multiple term vectors.</p>
3594
+ <p>Get multiple term vectors with a single request.
3595
+ You can specify existing documents by index and ID or provide artificial documents in the body of the request.
3596
+ You can specify the index in the request body or request URI.
3597
+ The response contains a <code>docs</code> array with all the fetched termvectors.
3598
+ Each element has the structure provided by the termvectors API.</p>
3599
+ <p><strong>Artificial documents</strong></p>
3600
+ <p>You can also use <code>mtermvectors</code> to generate term vectors for artificial documents provided in the body of the request.
3601
+ The mapping used is determined by the specified <code>_index</code>.</p>
3602
+
3018
3603
 
3019
3604
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-termvectors.html>`_
3020
3605
 
3021
- :param index: Name of the index that contains the documents.
3022
- :param docs: Array of existing or artificial documents.
3606
+ :param index: The name of the index that contains the documents.
3607
+ :param docs: An array of existing or artificial documents.
3023
3608
  :param field_statistics: If `true`, the response includes the document count,
3024
3609
  sum of document frequencies, and sum of total term frequencies.
3025
- :param fields: Comma-separated list or wildcard expressions of fields to include
3026
- in the statistics. Used as the default list unless a specific field list
3027
- is provided in the `completion_fields` or `fielddata_fields` parameters.
3028
- :param ids: Simplified syntax to specify documents by their ID if they're in
3610
+ :param fields: A comma-separated list or wildcard expressions of fields to include
3611
+ in the statistics. It is used as the default list unless a specific field
3612
+ list is provided in the `completion_fields` or `fielddata_fields` parameters.
3613
+ :param ids: A simplified syntax to specify documents by their ID if they're in
3029
3614
  the same index.
3030
3615
  :param offsets: If `true`, the response includes term offsets.
3031
3616
  :param payloads: If `true`, the response includes term payloads.
3032
3617
  :param positions: If `true`, the response includes term positions.
3033
- :param preference: Specifies the node or shard the operation should be performed
3034
- on. Random by default.
3618
+ :param preference: The node or shard the operation should be performed on. It
3619
+ is random by default.
3035
3620
  :param realtime: If true, the request is real-time as opposed to near-real-time.
3036
- :param routing: Custom value used to route operations to a specific shard.
3621
+ :param routing: A custom value used to route operations to a specific shard.
3037
3622
  :param term_statistics: If true, the response includes term frequency and document
3038
3623
  frequency.
3039
3624
  :param version: If `true`, returns the document version as part of a hit.
3040
- :param version_type: Specific version type.
3625
+ :param version_type: The version type.
3041
3626
  """
3042
3627
  __path_parts: t.Dict[str, str]
3043
3628
  if index not in SKIP_IN_PATH:
@@ -3126,36 +3711,59 @@ class Elasticsearch(BaseClient):
3126
3711
  body: t.Optional[t.Dict[str, t.Any]] = None,
3127
3712
  ) -> ObjectApiResponse[t.Any]:
3128
3713
  """
3129
- Open a point in time. A search request by default runs against the most recent
3130
- visible data of the target indices, which is called point in time. Elasticsearch
3131
- pit (point in time) is a lightweight view into the state of the data as it existed
3132
- when initiated. In some cases, it’s preferred to perform multiple search requests
3133
- using the same point in time. For example, if refreshes happen between `search_after`
3134
- requests, then the results of those requests might not be consistent as changes
3135
- happening between searches are only visible to the more recent point in time.
3136
- A point in time must be opened explicitly before being used in search requests.
3137
- The `keep_alive` parameter tells Elasticsearch how long it should persist.
3714
+ .. raw:: html
3715
+
3716
+ <p>Open a point in time.</p>
3717
+ <p>A search request by default runs against the most recent visible data of the target indices,
3718
+ which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the
3719
+ state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple
3720
+ search requests using the same point in time. For example, if refreshes happen between
3721
+ <code>search_after</code> requests, then the results of those requests might not be consistent as changes happening
3722
+ between searches are only visible to the more recent point in time.</p>
3723
+ <p>A point in time must be opened explicitly before being used in search requests.</p>
3724
+ <p>A subsequent search request with the <code>pit</code> parameter must not specify <code>index</code>, <code>routing</code>, or <code>preference</code> values as these parameters are copied from the point in time.</p>
3725
+ <p>Just like regular searches, you can use <code>from</code> and <code>size</code> to page through point in time search results, up to the first 10,000 hits.
3726
+ If you want to retrieve more hits, use PIT with <code>search_after</code>.</p>
3727
+ <p>IMPORTANT: The open point in time request and each subsequent search request can return different identifiers; always use the most recently received ID for the next search request.</p>
3728
+ <p>When a PIT that contains shard failures is used in a search request, the missing are always reported in the search response as a <code>NoShardAvailableActionException</code> exception.
3729
+ To get rid of these exceptions, a new PIT needs to be created so that shards missing from the previous PIT can be handled, assuming they become available in the meantime.</p>
3730
+ <p><strong>Keeping point in time alive</strong></p>
3731
+ <p>The <code>keep_alive</code> parameter, which is passed to a open point in time request and search request, extends the time to live of the corresponding point in time.
3732
+ The value does not need to be long enough to process all data — it just needs to be long enough for the next request.</p>
3733
+ <p>Normally, the background merge process optimizes the index by merging together smaller segments to create new, bigger segments.
3734
+ Once the smaller segments are no longer needed they are deleted.
3735
+ However, open point-in-times prevent the old segments from being deleted since they are still in use.</p>
3736
+ <p>TIP: Keeping older segments alive means that more disk space and file handles are needed.
3737
+ Ensure that you have configured your nodes to have ample free file handles.</p>
3738
+ <p>Additionally, if a segment contains deleted or updated documents then the point in time must keep track of whether each document in the segment was live at the time of the initial search request.
3739
+ Ensure that your nodes have sufficient heap space if you have many open point-in-times on an index that is subject to ongoing deletes or updates.
3740
+ Note that a point-in-time doesn't prevent its associated indices from being deleted.
3741
+ You can check how many point-in-times (that is, search contexts) are open with the nodes stats API.</p>
3742
+
3138
3743
 
3139
3744
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point-in-time-api.html>`_
3140
3745
 
3141
3746
  :param index: A comma-separated list of index names to open point in time; use
3142
3747
  `_all` or empty string to perform the operation on all indices
3143
- :param keep_alive: Extends the time to live of the corresponding point in time.
3144
- :param allow_partial_search_results: If `false`, creating a point in time request
3145
- when a shard is missing or unavailable will throw an exception. If `true`,
3146
- the point in time will contain all the shards that are available at the time
3147
- of the request.
3148
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
3149
- request can target data streams, this argument determines whether wildcard
3150
- expressions match hidden data streams. Supports comma-separated values, such
3151
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
3748
+ :param keep_alive: Extend the length of time that the point in time persists.
3749
+ :param allow_partial_search_results: Indicates whether the point in time tolerates
3750
+ unavailable shards or shard failures when initially creating the PIT. If
3751
+ `false`, creating a point in time request when a shard is missing or unavailable
3752
+ will throw an exception. If `true`, the point in time will contain all the
3753
+ shards that are available at the time of the request.
3754
+ :param expand_wildcards: The type of index that wildcard patterns can match.
3755
+ If the request can target data streams, this argument determines whether
3756
+ wildcard expressions match hidden data streams. It supports comma-separated
3757
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
3758
+ `hidden`, `none`.
3152
3759
  :param ignore_unavailable: If `false`, the request returns an error if it targets
3153
3760
  a missing or closed index.
3154
- :param index_filter: Allows to filter indices if the provided query rewrites
3155
- to `match_none` on every shard.
3156
- :param preference: Specifies the node or shard the operation should be performed
3157
- on. Random by default.
3158
- :param routing: Custom value used to route operations to a specific shard.
3761
+ :param index_filter: Filter indices if the provided query rewrites to `match_none`
3762
+ on every shard.
3763
+ :param preference: The node or shard the operation should be performed on. By
3764
+ default, it is random.
3765
+ :param routing: A custom value that is used to route operations to a specific
3766
+ shard.
3159
3767
  """
3160
3768
  if index in SKIP_IN_PATH:
3161
3769
  raise ValueError("Empty value passed for parameter 'index'")
@@ -3221,23 +3829,27 @@ class Elasticsearch(BaseClient):
3221
3829
  body: t.Optional[t.Dict[str, t.Any]] = None,
3222
3830
  ) -> ObjectApiResponse[t.Any]:
3223
3831
  """
3224
- Create or update a script or search template. Creates or updates a stored script
3225
- or search template.
3226
-
3227
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
3228
-
3229
- :param id: Identifier for the stored script or search template. Must be unique
3230
- within the cluster.
3231
- :param script: Contains the script or search template, its parameters, and its
3232
- language.
3233
- :param context: Context in which the script or search template should run. To
3234
- prevent errors, the API immediately compiles the script or template in this
3235
- context.
3236
- :param master_timeout: Period to wait for a connection to the master node. If
3237
- no response is received before the timeout expires, the request fails and
3238
- returns an error.
3239
- :param timeout: Period to wait for a response. If no response is received before
3240
- the timeout expires, the request fails and returns an error.
3832
+ .. raw:: html
3833
+
3834
+ <p>Create or update a script or search template.
3835
+ Creates or updates a stored script or search template.</p>
3836
+
3837
+
3838
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/create-stored-script-api.html>`_
3839
+
3840
+ :param id: The identifier for the stored script or search template. It must be
3841
+ unique within the cluster.
3842
+ :param script: The script or search template, its parameters, and its language.
3843
+ :param context: The context in which the script or search template should run.
3844
+ To prevent errors, the API immediately compiles the script or template in
3845
+ this context.
3846
+ :param master_timeout: The period to wait for a connection to the master node.
3847
+ If no response is received before the timeout expires, the request fails
3848
+ and returns an error. It can also be set to `-1` to indicate that the request
3849
+ should never timeout.
3850
+ :param timeout: The period to wait for a response. If no response is received
3851
+ before the timeout expires, the request fails and returns an error. It can
3852
+ also be set to `-1` to indicate that the request should never timeout.
3241
3853
  """
3242
3854
  if id in SKIP_IN_PATH:
3243
3855
  raise ValueError("Empty value passed for parameter 'id'")
@@ -3307,14 +3919,17 @@ class Elasticsearch(BaseClient):
3307
3919
  body: t.Optional[t.Dict[str, t.Any]] = None,
3308
3920
  ) -> ObjectApiResponse[t.Any]:
3309
3921
  """
3310
- Evaluate ranked search results. Evaluate the quality of ranked search results
3311
- over a set of typical search queries.
3922
+ .. raw:: html
3923
+
3924
+ <p>Evaluate ranked search results.</p>
3925
+ <p>Evaluate the quality of ranked search results over a set of typical search queries.</p>
3926
+
3312
3927
 
3313
3928
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-rank-eval.html>`_
3314
3929
 
3315
3930
  :param requests: A set of typical search requests, together with their provided
3316
3931
  ratings.
3317
- :param index: Comma-separated list of data streams, indices, and index aliases
3932
+ :param index: A comma-separated list of data streams, indices, and index aliases
3318
3933
  used to limit the request. Wildcard (`*`) expressions are supported. To target
3319
3934
  all data streams and indices in a cluster, omit this parameter or use `_all`
3320
3935
  or `*`.
@@ -3402,33 +4017,187 @@ class Elasticsearch(BaseClient):
3402
4017
  body: t.Optional[t.Dict[str, t.Any]] = None,
3403
4018
  ) -> ObjectApiResponse[t.Any]:
3404
4019
  """
3405
- Reindex documents. Copies documents from a source to a destination. The source
3406
- can be any existing index, alias, or data stream. The destination must differ
3407
- from the source. For example, you cannot reindex a data stream into itself.
4020
+ .. raw:: html
4021
+
4022
+ <p>Reindex documents.</p>
4023
+ <p>Copy documents from a source to a destination.
4024
+ You can copy all documents to the destination index or reindex a subset of the documents.
4025
+ The source can be any existing index, alias, or data stream.
4026
+ The destination must differ from the source.
4027
+ For example, you cannot reindex a data stream into itself.</p>
4028
+ <p>IMPORTANT: Reindex requires <code>_source</code> to be enabled for all documents in the source.
4029
+ The destination should be configured as wanted before calling the reindex API.
4030
+ Reindex does not copy the settings from the source or its associated template.
4031
+ Mappings, shard counts, and replicas, for example, must be configured ahead of time.</p>
4032
+ <p>If the Elasticsearch security features are enabled, you must have the following security privileges:</p>
4033
+ <ul>
4034
+ <li>The <code>read</code> index privilege for the source data stream, index, or alias.</li>
4035
+ <li>The <code>write</code> index privilege for the destination data stream, index, or index alias.</li>
4036
+ <li>To automatically create a data stream or index with a reindex API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege for the destination data stream, index, or alias.</li>
4037
+ <li>If reindexing from a remote cluster, the <code>source.remote.user</code> must have the <code>monitor</code> cluster privilege and the <code>read</code> index privilege for the source data stream, index, or alias.</li>
4038
+ </ul>
4039
+ <p>If reindexing from a remote cluster, you must explicitly allow the remote host in the <code>reindex.remote.whitelist</code> setting.
4040
+ Automatic data stream creation requires a matching index template with data stream enabled.</p>
4041
+ <p>The <code>dest</code> element can be configured like the index API to control optimistic concurrency control.
4042
+ Omitting <code>version_type</code> or setting it to <code>internal</code> causes Elasticsearch to blindly dump documents into the destination, overwriting any that happen to have the same ID.</p>
4043
+ <p>Setting <code>version_type</code> to <code>external</code> causes Elasticsearch to preserve the <code>version</code> from the source, create any documents that are missing, and update any documents that have an older version in the destination than they do in the source.</p>
4044
+ <p>Setting <code>op_type</code> to <code>create</code> causes the reindex API to create only missing documents in the destination.
4045
+ All existing documents will cause a version conflict.</p>
4046
+ <p>IMPORTANT: Because data streams are append-only, any reindex request to a destination data stream must have an <code>op_type</code> of <code>create</code>.
4047
+ A reindex can only add new documents to a destination data stream.
4048
+ It cannot update existing documents in a destination data stream.</p>
4049
+ <p>By default, version conflicts abort the reindex process.
4050
+ To continue reindexing if there are conflicts, set the <code>conflicts</code> request body property to <code>proceed</code>.
4051
+ In this case, the response includes a count of the version conflicts that were encountered.
4052
+ Note that the handling of other error types is unaffected by the <code>conflicts</code> property.
4053
+ Additionally, if you opt to count version conflicts, the operation could attempt to reindex more documents from the source than <code>max_docs</code> until it has successfully indexed <code>max_docs</code> documents into the target or it has gone through every document in the source query.</p>
4054
+ <p>NOTE: The reindex API makes no effort to handle ID collisions.
4055
+ The last document written will &quot;win&quot; but the order isn't usually predictable so it is not a good idea to rely on this behavior.
4056
+ Instead, make sure that IDs are unique by using a script.</p>
4057
+ <p><strong>Running reindex asynchronously</strong></p>
4058
+ <p>If the request contains <code>wait_for_completion=false</code>, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task.
4059
+ Elasticsearch creates a record of this task as a document at <code>_tasks/&lt;task_id&gt;</code>.</p>
4060
+ <p><strong>Reindex from multiple sources</strong></p>
4061
+ <p>If you have many sources to reindex it is generally better to reindex them one at a time rather than using a glob pattern to pick up multiple sources.
4062
+ That way you can resume the process if there are any errors by removing the partially completed source and starting over.
4063
+ It also makes parallelizing the process fairly simple: split the list of sources to reindex and run each list in parallel.</p>
4064
+ <p>For example, you can use a bash script like this:</p>
4065
+ <pre><code>for index in i1 i2 i3 i4 i5; do
4066
+ curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{
4067
+ &quot;source&quot;: {
4068
+ &quot;index&quot;: &quot;'$index'&quot;
4069
+ },
4070
+ &quot;dest&quot;: {
4071
+ &quot;index&quot;: &quot;'$index'-reindexed&quot;
4072
+ }
4073
+ }'
4074
+ done
4075
+ </code></pre>
4076
+ <p>** Throttling**</p>
4077
+ <p>Set <code>requests_per_second</code> to any positive decimal number (<code>1.4</code>, <code>6</code>, <code>1000</code>, for example) to throttle the rate at which reindex issues batches of index operations.
4078
+ Requests are throttled by padding each batch with a wait time.
4079
+ To turn off throttling, set <code>requests_per_second</code> to <code>-1</code>.</p>
4080
+ <p>The throttling is done by waiting between batches so that the scroll that reindex uses internally can be given a timeout that takes into account the padding.
4081
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
4082
+ By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
4083
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
4084
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
4085
+ </code></pre>
4086
+ <p>Since the batch is issued as a single bulk request, large batch sizes cause Elasticsearch to create many requests and then wait for a while before starting the next set.
4087
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
4088
+ <p><strong>Slicing</strong></p>
4089
+ <p>Reindex supports sliced scroll to parallelize the reindexing process.
4090
+ This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
4091
+ <p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
4092
+ <p>You can slice a reindex request manually by providing a slice ID and total number of slices to each request.
4093
+ You can also let reindex automatically parallelize by using sliced scroll to slice on <code>_id</code>.
4094
+ The <code>slices</code> parameter specifies the number of slices to use.</p>
4095
+ <p>Adding <code>slices</code> to the reindex request just automates the manual process, creating sub-requests which means it has some quirks:</p>
4096
+ <ul>
4097
+ <li>You can see these requests in the tasks API. These sub-requests are &quot;child&quot; tasks of the task for the request with slices.</li>
4098
+ <li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
4099
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
4100
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
4101
+ <li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
4102
+ <li>Due to the nature of <code>slices</code>, each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
4103
+ <li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with <code>slices</code> are distributed proportionally to each sub-request. Combine that with the previous point about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being reindexed.</li>
4104
+ <li>Each sub-request gets a slightly different snapshot of the source, though these are all taken at approximately the same time.</li>
4105
+ </ul>
4106
+ <p>If slicing automatically, setting <code>slices</code> to <code>auto</code> will choose a reasonable number for most indices.
4107
+ If slicing manually or otherwise tuning automatic slicing, use the following guidelines.</p>
4108
+ <p>Query performance is most efficient when the number of slices is equal to the number of shards in the index.
4109
+ If that number is large (for example, <code>500</code>), choose a lower number as too many slices will hurt performance.
4110
+ Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</p>
4111
+ <p>Indexing performance scales linearly across available resources with the number of slices.</p>
4112
+ <p>Whether query or indexing performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
4113
+ <p><strong>Modify documents during reindexing</strong></p>
4114
+ <p>Like <code>_update_by_query</code>, reindex operations support a script that modifies the document.
4115
+ Unlike <code>_update_by_query</code>, the script is allowed to modify the document's metadata.</p>
4116
+ <p>Just as in <code>_update_by_query</code>, you can set <code>ctx.op</code> to change the operation that is run on the destination.
4117
+ For example, set <code>ctx.op</code> to <code>noop</code> if your script decides that the document doesn’t have to be indexed in the destination. This &quot;no operation&quot; will be reported in the <code>noop</code> counter in the response body.
4118
+ Set <code>ctx.op</code> to <code>delete</code> if your script decides that the document must be deleted from the destination.
4119
+ The deletion will be reported in the <code>deleted</code> counter in the response body.
4120
+ Setting <code>ctx.op</code> to anything else will return an error, as will setting any other field in <code>ctx</code>.</p>
4121
+ <p>Think of the possibilities! Just be careful; you are able to change:</p>
4122
+ <ul>
4123
+ <li><code>_id</code></li>
4124
+ <li><code>_index</code></li>
4125
+ <li><code>_version</code></li>
4126
+ <li><code>_routing</code></li>
4127
+ </ul>
4128
+ <p>Setting <code>_version</code> to <code>null</code> or clearing it from the <code>ctx</code> map is just like not sending the version in an indexing request.
4129
+ It will cause the document to be overwritten in the destination regardless of the version on the target or the version type you use in the reindex API.</p>
4130
+ <p><strong>Reindex from remote</strong></p>
4131
+ <p>Reindex supports reindexing from a remote Elasticsearch cluster.
4132
+ The <code>host</code> parameter must contain a scheme, host, port, and optional path.
4133
+ The <code>username</code> and <code>password</code> parameters are optional and when they are present the reindex operation will connect to the remote Elasticsearch node using basic authentication.
4134
+ Be sure to use HTTPS when using basic authentication or the password will be sent in plain text.
4135
+ There are a range of settings available to configure the behavior of the HTTPS connection.</p>
4136
+ <p>When using Elastic Cloud, it is also possible to authenticate against the remote cluster through the use of a valid API key.
4137
+ Remote hosts must be explicitly allowed with the <code>reindex.remote.whitelist</code> setting.
4138
+ It can be set to a comma delimited list of allowed remote host and port combinations.
4139
+ Scheme is ignored; only the host and port are used.
4140
+ For example:</p>
4141
+ <pre><code>reindex.remote.whitelist: [otherhost:9200, another:9200, 127.0.10.*:9200, localhost:*&quot;]
4142
+ </code></pre>
4143
+ <p>The list of allowed hosts must be configured on any nodes that will coordinate the reindex.
4144
+ This feature should work with remote clusters of any version of Elasticsearch.
4145
+ This should enable you to upgrade from any version of Elasticsearch to the current version by reindexing from a cluster of the old version.</p>
4146
+ <p>WARNING: Elasticsearch does not support forward compatibility across major versions.
4147
+ For example, you cannot reindex from a 7.x cluster into a 6.x cluster.</p>
4148
+ <p>To enable queries sent to older versions of Elasticsearch, the <code>query</code> parameter is sent directly to the remote host without validation or modification.</p>
4149
+ <p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
4150
+ <p>Reindexing from a remote server uses an on-heap buffer that defaults to a maximum size of 100mb.
4151
+ If the remote index includes very large documents you'll need to use a smaller batch size.
4152
+ It is also possible to set the socket read timeout on the remote connection with the <code>socket_timeout</code> field and the connection timeout with the <code>connect_timeout</code> field.
4153
+ Both default to 30 seconds.</p>
4154
+ <p><strong>Configuring SSL parameters</strong></p>
4155
+ <p>Reindex from remote supports configurable SSL settings.
4156
+ These must be specified in the <code>elasticsearch.yml</code> file, with the exception of the secure settings, which you add in the Elasticsearch keystore.
4157
+ It is not possible to configure SSL in the body of the reindex request.</p>
4158
+
3408
4159
 
3409
4160
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3410
4161
 
3411
4162
  :param dest: The destination you are copying to.
3412
4163
  :param source: The source you are copying from.
3413
- :param conflicts: Set to proceed to continue reindexing even if there are conflicts.
3414
- :param max_docs: The maximum number of documents to reindex.
4164
+ :param conflicts: Indicates whether to continue reindexing even when there are
4165
+ conflicts.
4166
+ :param max_docs: The maximum number of documents to reindex. By default, all
4167
+ documents are reindexed. If it is a value less then or equal to `scroll_size`,
4168
+ a scroll will not be used to retrieve the results for the operation. If `conflicts`
4169
+ is set to `proceed`, the reindex operation could attempt to reindex more
4170
+ documents from the source than `max_docs` until it has successfully indexed
4171
+ `max_docs` documents into the target or it has gone through every document
4172
+ in the source query.
3415
4173
  :param refresh: If `true`, the request refreshes affected shards to make this
3416
4174
  operation visible to search.
3417
4175
  :param requests_per_second: The throttle for this request in sub-requests per
3418
- second. Defaults to no throttle.
4176
+ second. By default, there is no throttle.
3419
4177
  :param require_alias: If `true`, the destination must be an index alias.
3420
4178
  :param script: The script to run to update the document source or metadata when
3421
4179
  reindexing.
3422
- :param scroll: Specifies how long a consistent view of the index should be maintained
3423
- for scrolled search.
4180
+ :param scroll: The period of time that a consistent view of the index should
4181
+ be maintained for scrolled search.
3424
4182
  :param size:
3425
- :param slices: The number of slices this task should be divided into. Defaults
3426
- to 1 slice, meaning the task isnt sliced into subtasks.
3427
- :param timeout: Period each indexing waits for automatic index creation, dynamic
3428
- mapping updates, and waiting for active shards.
4183
+ :param slices: The number of slices this task should be divided into. It defaults
4184
+ to one slice, which means the task isn't sliced into subtasks. Reindex supports
4185
+ sliced scroll to parallelize the reindexing process. This parallelization
4186
+ can improve efficiency and provide a convenient way to break the request
4187
+ down into smaller parts. NOTE: Reindexing from remote clusters does not support
4188
+ manual or automatic slicing. If set to `auto`, Elasticsearch chooses the
4189
+ number of slices to use. This setting will use one slice per shard, up to
4190
+ a certain limit. If there are multiple sources, it will choose the number
4191
+ of slices based on the index or backing index with the smallest number of
4192
+ shards.
4193
+ :param timeout: The period each indexing waits for automatic index creation,
4194
+ dynamic mapping updates, and waiting for active shards. By default, Elasticsearch
4195
+ waits for at least one minute before failing. The actual wait time could
4196
+ be longer, particularly when multiple waits occur.
3429
4197
  :param wait_for_active_shards: The number of shard copies that must be active
3430
- before proceeding with the operation. Set to `all` or any positive integer
3431
- up to the total number of shards in the index (`number_of_replicas+1`).
4198
+ before proceeding with the operation. Set it to `all` or any positive integer
4199
+ up to the total number of shards in the index (`number_of_replicas+1`). The
4200
+ default value is one, which means it waits for each primary shard to be active.
3432
4201
  :param wait_for_completion: If `true`, the request blocks until the operation
3433
4202
  is complete.
3434
4203
  """
@@ -3500,14 +4269,24 @@ class Elasticsearch(BaseClient):
3500
4269
  requests_per_second: t.Optional[float] = None,
3501
4270
  ) -> ObjectApiResponse[t.Any]:
3502
4271
  """
3503
- Throttle a reindex operation. Change the number of requests per second for a
3504
- particular reindex operation.
4272
+ .. raw:: html
4273
+
4274
+ <p>Throttle a reindex operation.</p>
4275
+ <p>Change the number of requests per second for a particular reindex operation.
4276
+ For example:</p>
4277
+ <pre><code>POST _reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
4278
+ </code></pre>
4279
+ <p>Rethrottling that speeds up the query takes effect immediately.
4280
+ Rethrottling that slows down the query will take effect after completing the current batch.
4281
+ This behavior prevents scroll timeouts.</p>
4282
+
3505
4283
 
3506
4284
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
3507
4285
 
3508
- :param task_id: Identifier for the task.
4286
+ :param task_id: The task identifier, which can be found by using the tasks API.
3509
4287
  :param requests_per_second: The throttle for this request in sub-requests per
3510
- second.
4288
+ second. It can be either `-1` to turn off throttling or any decimal number
4289
+ like `1.7` or `12` to throttle to that level.
3511
4290
  """
3512
4291
  if task_id in SKIP_IN_PATH:
3513
4292
  raise ValueError("Empty value passed for parameter 'task_id'")
@@ -3552,17 +4331,21 @@ class Elasticsearch(BaseClient):
3552
4331
  body: t.Optional[t.Dict[str, t.Any]] = None,
3553
4332
  ) -> ObjectApiResponse[t.Any]:
3554
4333
  """
3555
- Render a search template. Render a search template as a search request body.
4334
+ .. raw:: html
4335
+
4336
+ <p>Render a search template.</p>
4337
+ <p>Render a search template as a search request body.</p>
4338
+
3556
4339
 
3557
4340
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/render-search-template-api.html>`_
3558
4341
 
3559
- :param id: ID of the search template to render. If no `source` is specified,
4342
+ :param id: The ID of the search template to render. If no `source` is specified,
3560
4343
  this or the `id` request body parameter is required.
3561
4344
  :param file:
3562
4345
  :param params: Key-value pairs used to replace Mustache variables in the template.
3563
4346
  The key is the variable name. The value is the variable value.
3564
- :param source: An inline search template. Supports the same parameters as the
3565
- search API's request body. These parameters also support Mustache variables.
4347
+ :param source: An inline search template. It supports the same parameters as
4348
+ the search API's request body. These parameters also support Mustache variables.
3566
4349
  If no `id` or `<templated-id>` is specified, this parameter is required.
3567
4350
  """
3568
4351
  __path_parts: t.Dict[str, str]
@@ -3621,7 +4404,11 @@ class Elasticsearch(BaseClient):
3621
4404
  body: t.Optional[t.Dict[str, t.Any]] = None,
3622
4405
  ) -> ObjectApiResponse[t.Any]:
3623
4406
  """
3624
- Run a script. Runs a script and returns a result.
4407
+ .. raw:: html
4408
+
4409
+ <p>Run a script.
4410
+ Runs a script and returns a result.</p>
4411
+
3625
4412
 
3626
4413
  `<https://www.elastic.co/guide/en/elasticsearch/painless/8.17/painless-execute-api.html>`_
3627
4414
 
@@ -3679,30 +4466,27 @@ class Elasticsearch(BaseClient):
3679
4466
  body: t.Optional[t.Dict[str, t.Any]] = None,
3680
4467
  ) -> ObjectApiResponse[t.Any]:
3681
4468
  """
3682
- Run a scrolling search. IMPORTANT: The scroll API is no longer recommend for
3683
- deep pagination. If you need to preserve the index state while paging through
3684
- more than 10,000 hits, use the `search_after` parameter with a point in time
3685
- (PIT). The scroll API gets large sets of results from a single scrolling search
3686
- request. To get the necessary scroll ID, submit a search API request that includes
3687
- an argument for the `scroll` query parameter. The `scroll` parameter indicates
3688
- how long Elasticsearch should retain the search context for the request. The
3689
- search response returns a scroll ID in the `_scroll_id` response body parameter.
3690
- You can then use the scroll ID with the scroll API to retrieve the next batch
3691
- of results for the request. If the Elasticsearch security features are enabled,
3692
- the access to the results of a specific scroll ID is restricted to the user or
3693
- API key that submitted the search. You can also use the scroll API to specify
3694
- a new scroll parameter that extends or shortens the retention period for the
3695
- search context. IMPORTANT: Results from a scrolling search reflect the state
3696
- of the index at the time of the initial search request. Subsequent indexing or
3697
- document changes only affect later search and scroll requests.
3698
-
3699
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-request-body.html#request-body-search-scroll>`_
3700
-
3701
- :param scroll_id: Scroll ID of the search.
4469
+ .. raw:: html
4470
+
4471
+ <p>Run a scrolling search.</p>
4472
+ <p>IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the <code>search_after</code> parameter with a point in time (PIT).</p>
4473
+ <p>The scroll API gets large sets of results from a single scrolling search request.
4474
+ To get the necessary scroll ID, submit a search API request that includes an argument for the <code>scroll</code> query parameter.
4475
+ The <code>scroll</code> parameter indicates how long Elasticsearch should retain the search context for the request.
4476
+ The search response returns a scroll ID in the <code>_scroll_id</code> response body parameter.
4477
+ You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request.
4478
+ If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.</p>
4479
+ <p>You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.</p>
4480
+ <p>IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.</p>
4481
+
4482
+
4483
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/scroll-api.html>`_
4484
+
4485
+ :param scroll_id: The scroll ID of the search.
3702
4486
  :param rest_total_hits_as_int: If true, the API response’s hit.total property
3703
4487
  is returned as an integer. If false, the API response’s hit.total property
3704
4488
  is returned as an object.
3705
- :param scroll: Period to retain the search context for scrolling.
4489
+ :param scroll: The period to retain the search context for scrolling.
3706
4490
  """
3707
4491
  if scroll_id is None and body is None:
3708
4492
  raise ValueError("Empty value passed for parameter 'scroll_id'")
@@ -3884,15 +4668,29 @@ class Elasticsearch(BaseClient):
3884
4668
  body: t.Optional[t.Dict[str, t.Any]] = None,
3885
4669
  ) -> ObjectApiResponse[t.Any]:
3886
4670
  """
3887
- Run a search. Get search hits that match the query defined in the request. You
3888
- can provide search queries using the `q` query string parameter or the request
3889
- body. If both are specified, only the query parameter is used.
4671
+ .. raw:: html
4672
+
4673
+ <p>Run a search.</p>
4674
+ <p>Get search hits that match the query defined in the request.
4675
+ You can provide search queries using the <code>q</code> query string parameter or the request body.
4676
+ If both are specified, only the query parameter is used.</p>
4677
+ <p>If the Elasticsearch security features are enabled, you must have the read index privilege for the target data stream, index, or alias. For cross-cluster search, refer to the documentation about configuring CCS privileges.
4678
+ To search a point in time (PIT) for an alias, you must have the <code>read</code> index privilege for the alias's data streams or indices.</p>
4679
+ <p><strong>Search slicing</strong></p>
4680
+ <p>When paging through a large number of documents, it can be helpful to split the search into multiple slices to consume them independently with the <code>slice</code> and <code>pit</code> properties.
4681
+ By default the splitting is done first on the shards, then locally on each shard.
4682
+ The local splitting partitions the shard into contiguous ranges based on Lucene document IDs.</p>
4683
+ <p>For instance if the number of shards is equal to 2 and you request 4 slices, the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.</p>
4684
+ <p>IMPORTANT: The same point-in-time ID should be used for all slices.
4685
+ If different PIT IDs are used, slices can overlap and miss documents.
4686
+ This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index.</p>
4687
+
3890
4688
 
3891
4689
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
3892
4690
 
3893
- :param index: Comma-separated list of data streams, indices, and aliases to search.
3894
- Supports wildcards (`*`). To search all data streams and indices, omit this
3895
- parameter or use `*` or `_all`.
4691
+ :param index: A comma-separated list of data streams, indices, and aliases to
4692
+ search. It supports wildcards (`*`). To search all data streams and indices,
4693
+ omit this parameter or use `*` or `_all`.
3896
4694
  :param aggregations: Defines the aggregations that are run as part of the search
3897
4695
  request.
3898
4696
  :param aggs: Defines the aggregations that are run as part of the search request.
@@ -3901,45 +4699,46 @@ class Elasticsearch(BaseClient):
3901
4699
  This behavior applies even if the request targets other open indices. For
3902
4700
  example, a request targeting `foo*,bar*` returns an error if an index starts
3903
4701
  with `foo` but no index starts with `bar`.
3904
- :param allow_partial_search_results: If true, returns partial results if there
3905
- are shard request timeouts or shard failures. If false, returns an error
3906
- with no partial results.
3907
- :param analyze_wildcard: If true, wildcard and prefix queries are analyzed. This
3908
- parameter can only be used when the q query string parameter is specified.
3909
- :param analyzer: Analyzer to use for the query string. This parameter can only
3910
- be used when the q query string parameter is specified.
4702
+ :param allow_partial_search_results: If `true` and there are shard request timeouts
4703
+ or shard failures, the request returns partial results. If `false`, it returns
4704
+ an error with no partial results. To override the default behavior, you can
4705
+ set the `search.default_allow_partial_results` cluster setting to `false`.
4706
+ :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
4707
+ This parameter can be used only when the `q` query string parameter is specified.
4708
+ :param analyzer: The analyzer to use for the query string. This parameter can
4709
+ be used only when the `q` query string parameter is specified.
3911
4710
  :param batched_reduce_size: The number of shard results that should be reduced
3912
- at once on the coordinating node. This value should be used as a protection
3913
- mechanism to reduce the memory overhead per search request if the potential
3914
- number of shards in the request can be large.
3915
- :param ccs_minimize_roundtrips: If true, network round-trips between the coordinating
3916
- node and the remote clusters are minimized when executing cross-cluster search
4711
+ at once on the coordinating node. If the potential number of shards in the
4712
+ request can be large, this value should be used as a protection mechanism
4713
+ to reduce the memory overhead per search request.
4714
+ :param ccs_minimize_roundtrips: If `true`, network round-trips between the coordinating
4715
+ node and the remote clusters are minimized when running cross-cluster search
3917
4716
  (CCS) requests.
3918
4717
  :param collapse: Collapses search results the values of the specified field.
3919
- :param default_operator: The default operator for query string query: AND or
3920
- OR. This parameter can only be used when the `q` query string parameter is
3921
- specified.
3922
- :param df: Field to use as default where no field prefix is given in the query
3923
- string. This parameter can only be used when the q query string parameter
4718
+ :param default_operator: The default operator for the query string query: `AND`
4719
+ or `OR`. This parameter can be used only when the `q` query string parameter
3924
4720
  is specified.
3925
- :param docvalue_fields: Array of wildcard (`*`) patterns. The request returns
3926
- doc values for field names matching these patterns in the `hits.fields` property
3927
- of the response.
3928
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
3929
- request can target data streams, this argument determines whether wildcard
3930
- expressions match hidden data streams. Supports comma-separated values, such
3931
- as `open,hidden`.
3932
- :param explain: If true, returns detailed information about score computation
3933
- as part of a hit.
4721
+ :param df: The field to use as a default when no field prefix is given in the
4722
+ query string. This parameter can be used only when the `q` query string parameter
4723
+ is specified.
4724
+ :param docvalue_fields: An array of wildcard (`*`) field patterns. The request
4725
+ returns doc values for field names matching these patterns in the `hits.fields`
4726
+ property of the response.
4727
+ :param expand_wildcards: The type of index that wildcard patterns can match.
4728
+ If the request can target data streams, this argument determines whether
4729
+ wildcard expressions match hidden data streams. It supports comma-separated
4730
+ values such as `open,hidden`.
4731
+ :param explain: If `true`, the request returns detailed information about score
4732
+ computation as part of a hit.
3934
4733
  :param ext: Configuration of search extensions defined by Elasticsearch plugins.
3935
- :param fields: Array of wildcard (`*`) patterns. The request returns values for
3936
- field names matching these patterns in the `hits.fields` property of the
3937
- response.
4734
+ :param fields: An array of wildcard (`*`) field patterns. The request returns
4735
+ values for field names matching these patterns in the `hits.fields` property
4736
+ of the response.
3938
4737
  :param force_synthetic_source: Should this request force synthetic _source? Use
3939
4738
  this to test if the mapping supports synthetic _source and to get a sense
3940
4739
  of the worst case performance. Fetches with this enabled will be slower the
3941
4740
  enabling synthetic source natively in the index.
3942
- :param from_: Starting document offset. Needs to be non-negative. By default,
4741
+ :param from_: The starting document offset, which must be non-negative. By default,
3943
4742
  you cannot page through more than 10,000 hits using the `from` and `size`
3944
4743
  parameters. To page through more hits, use the `search_after` parameter.
3945
4744
  :param highlight: Specifies the highlighter to use for retrieving highlighted
@@ -3948,95 +4747,101 @@ class Elasticsearch(BaseClient):
3948
4747
  be ignored when frozen.
3949
4748
  :param ignore_unavailable: If `false`, the request returns an error if it targets
3950
4749
  a missing or closed index.
3951
- :param include_named_queries_score: Indicates whether hit.matched_queries should
3952
- be rendered as a map that includes the name of the matched query associated
3953
- with its score (true) or as an array containing the name of the matched queries
3954
- (false) This functionality reruns each named query on every hit in a search
3955
- response. Typically, this adds a small overhead to a request. However, using
3956
- computationally expensive named queries on a large number of hits may add
3957
- significant overhead.
3958
- :param indices_boost: Boosts the _score of documents from specified indices.
3959
- :param knn: Defines the approximate kNN search to run.
4750
+ :param include_named_queries_score: If `true`, the response includes the score
4751
+ contribution from any named queries. This functionality reruns each named
4752
+ query on every hit in a search response. Typically, this adds a small overhead
4753
+ to a request. However, using computationally expensive named queries on a
4754
+ large number of hits may add significant overhead.
4755
+ :param indices_boost: Boost the `_score` of documents from specified indices.
4756
+ The boost value is the factor by which scores are multiplied. A boost value
4757
+ greater than `1.0` increases the score. A boost value between `0` and `1.0`
4758
+ decreases the score.
4759
+ :param knn: The approximate kNN search to run.
3960
4760
  :param lenient: If `true`, format-based query failures (such as providing text
3961
4761
  to a numeric field) in the query string will be ignored. This parameter can
3962
- only be used when the `q` query string parameter is specified.
3963
- :param max_concurrent_shard_requests: Defines the number of concurrent shard
3964
- requests per node this search executes concurrently. This value should be
3965
- used to limit the impact of the search on the cluster in order to limit the
3966
- number of concurrent shard requests.
4762
+ be used only when the `q` query string parameter is specified.
4763
+ :param max_concurrent_shard_requests: The number of concurrent shard requests
4764
+ per node that the search runs concurrently. This value should be used to
4765
+ limit the impact of the search on the cluster in order to limit the number
4766
+ of concurrent shard requests.
3967
4767
  :param min_compatible_shard_node: The minimum version of the node that can handle
3968
- the request Any handling node with a lower version will fail the request.
3969
- :param min_score: Minimum `_score` for matching documents. Documents with a lower
3970
- `_score` are not included in the search results.
3971
- :param pit: Limits the search to a point in time (PIT). If you provide a PIT,
4768
+ the request. Any handling node with a lower version will fail the request.
4769
+ :param min_score: The minimum `_score` for matching documents. Documents with
4770
+ a lower `_score` are not included in the search results.
4771
+ :param pit: Limit the search to a point in time (PIT). If you provide a PIT,
3972
4772
  you cannot specify an `<index>` in the request path.
3973
4773
  :param post_filter: Use the `post_filter` parameter to filter search results.
3974
4774
  The search hits are filtered after the aggregations are calculated. A post
3975
4775
  filter has no impact on the aggregation results.
3976
- :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
3977
- roundtrip to prefilter search shards based on query rewriting if the number
3978
- of shards the search request expands to exceeds the threshold. This filter
3979
- roundtrip can limit the number of shards significantly if for instance a
3980
- shard can not match any documents based on its rewrite method (if date filters
3981
- are mandatory to match but the shard bounds and the query are disjoint).
3982
- When unspecified, the pre-filter phase is executed if any of these conditions
3983
- is met: the request targets more than 128 shards; the request targets one
3984
- or more read-only index; the primary sort of the query targets an indexed
4776
+ :param pre_filter_shard_size: A threshold that enforces a pre-filter roundtrip
4777
+ to prefilter search shards based on query rewriting if the number of shards
4778
+ the search request expands to exceeds the threshold. This filter roundtrip
4779
+ can limit the number of shards significantly if for instance a shard can
4780
+ not match any documents based on its rewrite method (if date filters are
4781
+ mandatory to match but the shard bounds and the query are disjoint). When
4782
+ unspecified, the pre-filter phase is executed if any of these conditions
4783
+ is met: * The request targets more than 128 shards. * The request targets
4784
+ one or more read-only index. * The primary sort of the query targets an indexed
3985
4785
  field.
3986
- :param preference: Nodes and shards used for the search. By default, Elasticsearch
4786
+ :param preference: The nodes and shards used for the search. By default, Elasticsearch
3987
4787
  selects from eligible nodes and shards using adaptive replica selection,
3988
- accounting for allocation awareness. Valid values are: `_only_local` to run
3989
- the search only on shards on the local node; `_local` to, if possible, run
3990
- the search on shards on the local node, or if not, select shards using the
3991
- default method; `_only_nodes:<node-id>,<node-id>` to run the search on only
3992
- the specified nodes IDs, where, if suitable shards exist on more than one
3993
- selected node, use shards on those nodes using the default method, or if
3994
- none of the specified nodes are available, select shards from any available
3995
- node using the default method; `_prefer_nodes:<node-id>,<node-id>` to if
4788
+ accounting for allocation awareness. Valid values are: * `_only_local` to
4789
+ run the search only on shards on the local node; * `_local` to, if possible,
4790
+ run the search on shards on the local node, or if not, select shards using
4791
+ the default method; * `_only_nodes:<node-id>,<node-id>` to run the search
4792
+ on only the specified nodes IDs, where, if suitable shards exist on more
4793
+ than one selected node, use shards on those nodes using the default method,
4794
+ or if none of the specified nodes are available, select shards from any available
4795
+ node using the default method; * `_prefer_nodes:<node-id>,<node-id>` to if
3996
4796
  possible, run the search on the specified nodes IDs, or if not, select shards
3997
- using the default method; `_shards:<shard>,<shard>` to run the search only
3998
- on the specified shards; `<custom-string>` (any string that does not start
4797
+ using the default method; * `_shards:<shard>,<shard>` to run the search only
4798
+ on the specified shards; * `<custom-string>` (any string that does not start
3999
4799
  with `_`) to route searches with the same `<custom-string>` to the same shards
4000
4800
  in the same order.
4001
4801
  :param profile: Set to `true` to return detailed timing information about the
4002
4802
  execution of individual components in a search request. NOTE: This is a debugging
4003
4803
  tool and adds significant overhead to search execution.
4004
- :param q: Query in the Lucene query string syntax using query parameter search.
4005
- Query parameter searches do not support the full Elasticsearch Query DSL
4006
- but are handy for testing.
4007
- :param query: Defines the search definition using the Query DSL.
4008
- :param rank: Defines the Reciprocal Rank Fusion (RRF) to use.
4804
+ :param q: A query in the Lucene query string syntax. Query parameter searches
4805
+ do not support the full Elasticsearch Query DSL but are handy for testing.
4806
+ IMPORTANT: This parameter overrides the query parameter in the request body.
4807
+ If both parameters are specified, documents matching the query request body
4808
+ parameter are not returned.
4809
+ :param query: The search definition using the Query DSL.
4810
+ :param rank: The Reciprocal Rank Fusion (RRF) to use.
4009
4811
  :param request_cache: If `true`, the caching of search results is enabled for
4010
- requests where `size` is `0`. Defaults to index level settings.
4812
+ requests where `size` is `0`. It defaults to index level settings.
4011
4813
  :param rescore: Can be used to improve precision by reordering just the top (for
4012
4814
  example 100 - 500) documents returned by the `query` and `post_filter` phases.
4013
4815
  :param rest_total_hits_as_int: Indicates whether `hits.total` should be rendered
4014
4816
  as an integer or an object in the rest search response.
4015
4817
  :param retriever: A retriever is a specification to describe top documents returned
4016
4818
  from a search. A retriever replaces other elements of the search API that
4017
- also return top documents such as query and knn.
4018
- :param routing: Custom value used to route operations to a specific shard.
4019
- :param runtime_mappings: Defines one or more runtime fields in the search request.
4020
- These fields take precedence over mapped fields with the same name.
4819
+ also return top documents such as `query` and `knn`.
4820
+ :param routing: A custom value that is used to route operations to a specific
4821
+ shard.
4822
+ :param runtime_mappings: One or more runtime fields in the search request. These
4823
+ fields take precedence over mapped fields with the same name.
4021
4824
  :param script_fields: Retrieve a script evaluation (based on different fields)
4022
4825
  for each hit.
4023
- :param scroll: Period to retain the search context for scrolling. See Scroll
4024
- search results. By default, this value cannot exceed `1d` (24 hours). You
4025
- can change this limit using the `search.max_keep_alive` cluster-level setting.
4826
+ :param scroll: The period to retain the search context for scrolling. By default,
4827
+ this value cannot exceed `1d` (24 hours). You can change this limit by using
4828
+ the `search.max_keep_alive` cluster-level setting.
4026
4829
  :param search_after: Used to retrieve the next page of hits using a set of sort
4027
4830
  values from the previous page.
4028
- :param search_type: How distributed term frequencies are calculated for relevance
4029
- scoring.
4030
- :param seq_no_primary_term: If `true`, returns sequence number and primary term
4031
- of the last modification of each hit.
4032
- :param size: The number of hits to return. By default, you cannot page through
4033
- more than 10,000 hits using the `from` and `size` parameters. To page through
4034
- more hits, use the `search_after` parameter.
4035
- :param slice: Can be used to split a scrolled search into multiple slices that
4036
- can be consumed independently.
4831
+ :param search_type: Indicates how distributed term frequencies are calculated
4832
+ for relevance scoring.
4833
+ :param seq_no_primary_term: If `true`, the request returns sequence number and
4834
+ primary term of the last modification of each hit.
4835
+ :param size: The number of hits to return, which must not be negative. By default,
4836
+ you cannot page through more than 10,000 hits using the `from` and `size`
4837
+ parameters. To page through more hits, use the `search_after` property.
4838
+ :param slice: Split a scrolled search into multiple slices that can be consumed
4839
+ independently.
4037
4840
  :param sort: A comma-separated list of <field>:<direction> pairs.
4038
- :param source: Indicates which source fields are returned for matching documents.
4039
- These fields are returned in the hits._source property of the search response.
4841
+ :param source: The source fields that are returned for matching documents. These
4842
+ fields are returned in the `hits._source` property of the search response.
4843
+ If the `stored_fields` property is specified, the `_source` property defaults
4844
+ to `false`. Otherwise, it defaults to `true`.
4040
4845
  :param source_excludes: A comma-separated list of source fields to exclude from
4041
4846
  the response. You can also use this parameter to exclude fields from the
4042
4847
  subset specified in `_source_includes` query parameter. If the `_source`
@@ -4046,45 +4851,46 @@ class Elasticsearch(BaseClient):
4046
4851
  returned. You can exclude fields from this subset using the `_source_excludes`
4047
4852
  query parameter. If the `_source` parameter is `false`, this parameter is
4048
4853
  ignored.
4049
- :param stats: Stats groups to associate with the search. Each group maintains
4854
+ :param stats: The stats groups to associate with the search. Each group maintains
4050
4855
  a statistics aggregation for its associated searches. You can retrieve these
4051
4856
  stats using the indices stats API.
4052
- :param stored_fields: List of stored fields to return as part of a hit. If no
4053
- fields are specified, no stored fields are included in the response. If this
4054
- field is specified, the `_source` parameter defaults to `false`. You can
4055
- pass `_source: true` to return both source fields and stored fields in the
4056
- search response.
4857
+ :param stored_fields: A comma-separated list of stored fields to return as part
4858
+ of a hit. If no fields are specified, no stored fields are included in the
4859
+ response. If this field is specified, the `_source` property defaults to
4860
+ `false`. You can pass `_source: true` to return both source fields and stored
4861
+ fields in the search response.
4057
4862
  :param suggest: Defines a suggester that provides similar looking terms based
4058
4863
  on a provided text.
4059
- :param suggest_field: Specifies which field to use for suggestions.
4060
- :param suggest_mode: Specifies the suggest mode. This parameter can only be used
4061
- when the `suggest_field` and `suggest_text` query string parameters are specified.
4062
- :param suggest_size: Number of suggestions to return. This parameter can only
4063
- be used when the `suggest_field` and `suggest_text` query string parameters
4864
+ :param suggest_field: The field to use for suggestions.
4865
+ :param suggest_mode: The suggest mode. This parameter can be used only when the
4866
+ `suggest_field` and `suggest_text` query string parameters are specified.
4867
+ :param suggest_size: The number of suggestions to return. This parameter can
4868
+ be used only when the `suggest_field` and `suggest_text` query string parameters
4064
4869
  are specified.
4065
4870
  :param suggest_text: The source text for which the suggestions should be returned.
4066
- This parameter can only be used when the `suggest_field` and `suggest_text`
4871
+ This parameter can be used only when the `suggest_field` and `suggest_text`
4067
4872
  query string parameters are specified.
4068
- :param terminate_after: Maximum number of documents to collect for each shard.
4873
+ :param terminate_after: The maximum number of documents to collect for each shard.
4069
4874
  If a query reaches this limit, Elasticsearch terminates the query early.
4070
- Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
4071
- applies this parameter to each shard handling the request. When possible,
4072
- let Elasticsearch perform early termination automatically. Avoid specifying
4073
- this parameter for requests that target data streams with backing indices
4074
- across multiple data tiers. If set to `0` (default), the query does not terminate
4075
- early.
4076
- :param timeout: Specifies the period of time to wait for a response from each
4077
- shard. If no response is received before the timeout expires, the request
4078
- fails and returns an error. Defaults to no timeout.
4079
- :param track_scores: If true, calculate and return document scores, even if the
4080
- scores are not used for sorting.
4875
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
4876
+ Elasticsearch applies this property to each shard handling the request. When
4877
+ possible, let Elasticsearch perform early termination automatically. Avoid
4878
+ specifying this property for requests that target data streams with backing
4879
+ indices across multiple data tiers. If set to `0` (default), the query does
4880
+ not terminate early.
4881
+ :param timeout: The period of time to wait for a response from each shard. If
4882
+ no response is received before the timeout expires, the request fails and
4883
+ returns an error. Defaults to no timeout.
4884
+ :param track_scores: If `true`, calculate and return document scores, even if
4885
+ the scores are not used for sorting.
4081
4886
  :param track_total_hits: Number of hits matching the query to count accurately.
4082
4887
  If `true`, the exact number of hits is returned at the cost of some performance.
4083
4888
  If `false`, the response does not include the total number of hits matching
4084
4889
  the query.
4085
4890
  :param typed_keys: If `true`, aggregation and suggester names are be prefixed
4086
4891
  by their respective types in the response.
4087
- :param version: If true, returns document version as part of a hit.
4892
+ :param version: If `true`, the request returns the document version as part of
4893
+ a hit.
4088
4894
  """
4089
4895
  __path_parts: t.Dict[str, str]
4090
4896
  if index not in SKIP_IN_PATH:
@@ -4316,7 +5122,319 @@ class Elasticsearch(BaseClient):
4316
5122
  body: t.Optional[t.Dict[str, t.Any]] = None,
4317
5123
  ) -> BinaryApiResponse:
4318
5124
  """
4319
- Search a vector tile. Search a vector tile for geospatial values.
5125
+ .. raw:: html
5126
+
5127
+ <p>Search a vector tile.</p>
5128
+ <p>Search a vector tile for geospatial values.
5129
+ Before using this API, you should be familiar with the Mapbox vector tile specification.
5130
+ The API returns results as a binary mapbox vector tile.</p>
5131
+ <p>Internally, Elasticsearch translates a vector tile search API request into a search containing:</p>
5132
+ <ul>
5133
+ <li>A <code>geo_bounding_box</code> query on the <code>&lt;field&gt;</code>. The query uses the <code>&lt;zoom&gt;/&lt;x&gt;/&lt;y&gt;</code> tile as a bounding box.</li>
5134
+ <li>A <code>geotile_grid</code> or <code>geohex_grid</code> aggregation on the <code>&lt;field&gt;</code>. The <code>grid_agg</code> parameter determines the aggregation type. The aggregation uses the <code>&lt;zoom&gt;/&lt;x&gt;/&lt;y&gt;</code> tile as a bounding box.</li>
5135
+ <li>Optionally, a <code>geo_bounds</code> aggregation on the <code>&lt;field&gt;</code>. The search only includes this aggregation if the <code>exact_bounds</code> parameter is <code>true</code>.</li>
5136
+ <li>If the optional parameter <code>with_labels</code> is <code>true</code>, the internal search will include a dynamic runtime field that calls the <code>getLabelPosition</code> function of the geometry doc value. This enables the generation of new point features containing suggested geometry labels, so that, for example, multi-polygons will have only one label.</li>
5137
+ </ul>
5138
+ <p>For example, Elasticsearch may translate a vector tile search API request with a <code>grid_agg</code> argument of <code>geotile</code> and an <code>exact_bounds</code> argument of <code>true</code> into the following search</p>
5139
+ <pre><code>GET my-index/_search
5140
+ {
5141
+ &quot;size&quot;: 10000,
5142
+ &quot;query&quot;: {
5143
+ &quot;geo_bounding_box&quot;: {
5144
+ &quot;my-geo-field&quot;: {
5145
+ &quot;top_left&quot;: {
5146
+ &quot;lat&quot;: -40.979898069620134,
5147
+ &quot;lon&quot;: -45
5148
+ },
5149
+ &quot;bottom_right&quot;: {
5150
+ &quot;lat&quot;: -66.51326044311186,
5151
+ &quot;lon&quot;: 0
5152
+ }
5153
+ }
5154
+ }
5155
+ },
5156
+ &quot;aggregations&quot;: {
5157
+ &quot;grid&quot;: {
5158
+ &quot;geotile_grid&quot;: {
5159
+ &quot;field&quot;: &quot;my-geo-field&quot;,
5160
+ &quot;precision&quot;: 11,
5161
+ &quot;size&quot;: 65536,
5162
+ &quot;bounds&quot;: {
5163
+ &quot;top_left&quot;: {
5164
+ &quot;lat&quot;: -40.979898069620134,
5165
+ &quot;lon&quot;: -45
5166
+ },
5167
+ &quot;bottom_right&quot;: {
5168
+ &quot;lat&quot;: -66.51326044311186,
5169
+ &quot;lon&quot;: 0
5170
+ }
5171
+ }
5172
+ }
5173
+ },
5174
+ &quot;bounds&quot;: {
5175
+ &quot;geo_bounds&quot;: {
5176
+ &quot;field&quot;: &quot;my-geo-field&quot;,
5177
+ &quot;wrap_longitude&quot;: false
5178
+ }
5179
+ }
5180
+ }
5181
+ }
5182
+ </code></pre>
5183
+ <p>The API returns results as a binary Mapbox vector tile.
5184
+ Mapbox vector tiles are encoded as Google Protobufs (PBF). By default, the tile contains three layers:</p>
5185
+ <ul>
5186
+ <li>A <code>hits</code> layer containing a feature for each <code>&lt;field&gt;</code> value matching the <code>geo_bounding_box</code> query.</li>
5187
+ <li>An <code>aggs</code> layer containing a feature for each cell of the <code>geotile_grid</code> or <code>geohex_grid</code>. The layer only contains features for cells with matching data.</li>
5188
+ <li>A meta layer containing:
5189
+ <ul>
5190
+ <li>A feature containing a bounding box. By default, this is the bounding box of the tile.</li>
5191
+ <li>Value ranges for any sub-aggregations on the <code>geotile_grid</code> or <code>geohex_grid</code>.</li>
5192
+ <li>Metadata for the search.</li>
5193
+ </ul>
5194
+ </li>
5195
+ </ul>
5196
+ <p>The API only returns features that can display at its zoom level.
5197
+ For example, if a polygon feature has no area at its zoom level, the API omits it.
5198
+ The API returns errors as UTF-8 encoded JSON.</p>
5199
+ <p>IMPORTANT: You can specify several options for this API as either a query parameter or request body parameter.
5200
+ If you specify both parameters, the query parameter takes precedence.</p>
5201
+ <p><strong>Grid precision for geotile</strong></p>
5202
+ <p>For a <code>grid_agg</code> of <code>geotile</code>, you can use cells in the <code>aggs</code> layer as tiles for lower zoom levels.
5203
+ <code>grid_precision</code> represents the additional zoom levels available through these cells. The final precision is computed by as follows: <code>&lt;zoom&gt; + grid_precision</code>.
5204
+ For example, if <code>&lt;zoom&gt;</code> is 7 and <code>grid_precision</code> is 8, then the <code>geotile_grid</code> aggregation will use a precision of 15.
5205
+ The maximum final precision is 29.
5206
+ The <code>grid_precision</code> also determines the number of cells for the grid as follows: <code>(2^grid_precision) x (2^grid_precision)</code>.
5207
+ For example, a value of 8 divides the tile into a grid of 256 x 256 cells.
5208
+ The <code>aggs</code> layer only contains features for cells with matching data.</p>
5209
+ <p><strong>Grid precision for geohex</strong></p>
5210
+ <p>For a <code>grid_agg</code> of <code>geohex</code>, Elasticsearch uses <code>&lt;zoom&gt;</code> and <code>grid_precision</code> to calculate a final precision as follows: <code>&lt;zoom&gt; + grid_precision</code>.</p>
5211
+ <p>This precision determines the H3 resolution of the hexagonal cells produced by the <code>geohex</code> aggregation.
5212
+ The following table maps the H3 resolution for each precision.
5213
+ For example, if <code>&lt;zoom&gt;</code> is 3 and <code>grid_precision</code> is 3, the precision is 6.
5214
+ At a precision of 6, hexagonal cells have an H3 resolution of 2.
5215
+ If <code>&lt;zoom&gt;</code> is 3 and <code>grid_precision</code> is 4, the precision is 7.
5216
+ At a precision of 7, hexagonal cells have an H3 resolution of 3.</p>
5217
+ <table>
5218
+ <thead>
5219
+ <tr>
5220
+ <th>Precision</th>
5221
+ <th>Unique tile bins</th>
5222
+ <th>H3 resolution</th>
5223
+ <th>Unique hex bins</th>
5224
+ <th>Ratio</th>
5225
+ </tr>
5226
+ </thead>
5227
+ <tbody>
5228
+ <tr>
5229
+ <td>1</td>
5230
+ <td>4</td>
5231
+ <td>0</td>
5232
+ <td>122</td>
5233
+ <td>30.5</td>
5234
+ </tr>
5235
+ <tr>
5236
+ <td>2</td>
5237
+ <td>16</td>
5238
+ <td>0</td>
5239
+ <td>122</td>
5240
+ <td>7.625</td>
5241
+ </tr>
5242
+ <tr>
5243
+ <td>3</td>
5244
+ <td>64</td>
5245
+ <td>1</td>
5246
+ <td>842</td>
5247
+ <td>13.15625</td>
5248
+ </tr>
5249
+ <tr>
5250
+ <td>4</td>
5251
+ <td>256</td>
5252
+ <td>1</td>
5253
+ <td>842</td>
5254
+ <td>3.2890625</td>
5255
+ </tr>
5256
+ <tr>
5257
+ <td>5</td>
5258
+ <td>1024</td>
5259
+ <td>2</td>
5260
+ <td>5882</td>
5261
+ <td>5.744140625</td>
5262
+ </tr>
5263
+ <tr>
5264
+ <td>6</td>
5265
+ <td>4096</td>
5266
+ <td>2</td>
5267
+ <td>5882</td>
5268
+ <td>1.436035156</td>
5269
+ </tr>
5270
+ <tr>
5271
+ <td>7</td>
5272
+ <td>16384</td>
5273
+ <td>3</td>
5274
+ <td>41162</td>
5275
+ <td>2.512329102</td>
5276
+ </tr>
5277
+ <tr>
5278
+ <td>8</td>
5279
+ <td>65536</td>
5280
+ <td>3</td>
5281
+ <td>41162</td>
5282
+ <td>0.6280822754</td>
5283
+ </tr>
5284
+ <tr>
5285
+ <td>9</td>
5286
+ <td>262144</td>
5287
+ <td>4</td>
5288
+ <td>288122</td>
5289
+ <td>1.099098206</td>
5290
+ </tr>
5291
+ <tr>
5292
+ <td>10</td>
5293
+ <td>1048576</td>
5294
+ <td>4</td>
5295
+ <td>288122</td>
5296
+ <td>0.2747745514</td>
5297
+ </tr>
5298
+ <tr>
5299
+ <td>11</td>
5300
+ <td>4194304</td>
5301
+ <td>5</td>
5302
+ <td>2016842</td>
5303
+ <td>0.4808526039</td>
5304
+ </tr>
5305
+ <tr>
5306
+ <td>12</td>
5307
+ <td>16777216</td>
5308
+ <td>6</td>
5309
+ <td>14117882</td>
5310
+ <td>0.8414913416</td>
5311
+ </tr>
5312
+ <tr>
5313
+ <td>13</td>
5314
+ <td>67108864</td>
5315
+ <td>6</td>
5316
+ <td>14117882</td>
5317
+ <td>0.2103728354</td>
5318
+ </tr>
5319
+ <tr>
5320
+ <td>14</td>
5321
+ <td>268435456</td>
5322
+ <td>7</td>
5323
+ <td>98825162</td>
5324
+ <td>0.3681524172</td>
5325
+ </tr>
5326
+ <tr>
5327
+ <td>15</td>
5328
+ <td>1073741824</td>
5329
+ <td>8</td>
5330
+ <td>691776122</td>
5331
+ <td>0.644266719</td>
5332
+ </tr>
5333
+ <tr>
5334
+ <td>16</td>
5335
+ <td>4294967296</td>
5336
+ <td>8</td>
5337
+ <td>691776122</td>
5338
+ <td>0.1610666797</td>
5339
+ </tr>
5340
+ <tr>
5341
+ <td>17</td>
5342
+ <td>17179869184</td>
5343
+ <td>9</td>
5344
+ <td>4842432842</td>
5345
+ <td>0.2818666889</td>
5346
+ </tr>
5347
+ <tr>
5348
+ <td>18</td>
5349
+ <td>68719476736</td>
5350
+ <td>10</td>
5351
+ <td>33897029882</td>
5352
+ <td>0.4932667053</td>
5353
+ </tr>
5354
+ <tr>
5355
+ <td>19</td>
5356
+ <td>274877906944</td>
5357
+ <td>11</td>
5358
+ <td>237279209162</td>
5359
+ <td>0.8632167343</td>
5360
+ </tr>
5361
+ <tr>
5362
+ <td>20</td>
5363
+ <td>1099511627776</td>
5364
+ <td>11</td>
5365
+ <td>237279209162</td>
5366
+ <td>0.2158041836</td>
5367
+ </tr>
5368
+ <tr>
5369
+ <td>21</td>
5370
+ <td>4398046511104</td>
5371
+ <td>12</td>
5372
+ <td>1660954464122</td>
5373
+ <td>0.3776573213</td>
5374
+ </tr>
5375
+ <tr>
5376
+ <td>22</td>
5377
+ <td>17592186044416</td>
5378
+ <td>13</td>
5379
+ <td>11626681248842</td>
5380
+ <td>0.6609003122</td>
5381
+ </tr>
5382
+ <tr>
5383
+ <td>23</td>
5384
+ <td>70368744177664</td>
5385
+ <td>13</td>
5386
+ <td>11626681248842</td>
5387
+ <td>0.165225078</td>
5388
+ </tr>
5389
+ <tr>
5390
+ <td>24</td>
5391
+ <td>281474976710656</td>
5392
+ <td>14</td>
5393
+ <td>81386768741882</td>
5394
+ <td>0.2891438866</td>
5395
+ </tr>
5396
+ <tr>
5397
+ <td>25</td>
5398
+ <td>1125899906842620</td>
5399
+ <td>15</td>
5400
+ <td>569707381193162</td>
5401
+ <td>0.5060018015</td>
5402
+ </tr>
5403
+ <tr>
5404
+ <td>26</td>
5405
+ <td>4503599627370500</td>
5406
+ <td>15</td>
5407
+ <td>569707381193162</td>
5408
+ <td>0.1265004504</td>
5409
+ </tr>
5410
+ <tr>
5411
+ <td>27</td>
5412
+ <td>18014398509482000</td>
5413
+ <td>15</td>
5414
+ <td>569707381193162</td>
5415
+ <td>0.03162511259</td>
5416
+ </tr>
5417
+ <tr>
5418
+ <td>28</td>
5419
+ <td>72057594037927900</td>
5420
+ <td>15</td>
5421
+ <td>569707381193162</td>
5422
+ <td>0.007906278149</td>
5423
+ </tr>
5424
+ <tr>
5425
+ <td>29</td>
5426
+ <td>288230376151712000</td>
5427
+ <td>15</td>
5428
+ <td>569707381193162</td>
5429
+ <td>0.001976569537</td>
5430
+ </tr>
5431
+ </tbody>
5432
+ </table>
5433
+ <p>Hexagonal cells don't align perfectly on a vector tile.
5434
+ Some cells may intersect more than one vector tile.
5435
+ To compute the H3 resolution for each precision, Elasticsearch compares the average density of hexagonal bins at each resolution with the average density of tile bins at each zoom level.
5436
+ Elasticsearch uses the H3 resolution that is closest to the corresponding geotile density.</p>
5437
+
4320
5438
 
4321
5439
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-vector-tile-api.html>`_
4322
5440
 
@@ -4325,43 +5443,55 @@ class Elasticsearch(BaseClient):
4325
5443
  :param zoom: Zoom level for the vector tile to search
4326
5444
  :param x: X coordinate for the vector tile to search
4327
5445
  :param y: Y coordinate for the vector tile to search
4328
- :param aggs: Sub-aggregations for the geotile_grid. Supports the following aggregation
4329
- types: - avg - cardinality - max - min - sum
4330
- :param buffer: Size, in pixels, of a clipping buffer outside the tile. This allows
4331
- renderers to avoid outline artifacts from geometries that extend past the
4332
- extent of the tile.
4333
- :param exact_bounds: If false, the meta layer’s feature is the bounding box of
4334
- the tile. If true, the meta layer’s feature is a bounding box resulting from
4335
- a geo_bounds aggregation. The aggregation runs on <field> values that intersect
4336
- the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting bounding
4337
- box may be larger than the vector tile.
4338
- :param extent: Size, in pixels, of a side of the tile. Vector tiles are square
5446
+ :param aggs: Sub-aggregations for the geotile_grid. It supports the following
5447
+ aggregation types: - `avg` - `boxplot` - `cardinality` - `extended stats`
5448
+ - `max` - `median absolute deviation` - `min` - `percentile` - `percentile-rank`
5449
+ - `stats` - `sum` - `value count` The aggregation names can't start with
5450
+ `_mvt_`. The `_mvt_` prefix is reserved for internal aggregations.
5451
+ :param buffer: The size, in pixels, of a clipping buffer outside the tile. This
5452
+ allows renderers to avoid outline artifacts from geometries that extend past
5453
+ the extent of the tile.
5454
+ :param exact_bounds: If `false`, the meta layer's feature is the bounding box
5455
+ of the tile. If `true`, the meta layer's feature is a bounding box resulting
5456
+ from a `geo_bounds` aggregation. The aggregation runs on <field> values that
5457
+ intersect the `<zoom>/<x>/<y>` tile with `wrap_longitude` set to `false`.
5458
+ The resulting bounding box may be larger than the vector tile.
5459
+ :param extent: The size, in pixels, of a side of the tile. Vector tiles are square
4339
5460
  with equal sides.
4340
- :param fields: Fields to return in the `hits` layer. Supports wildcards (`*`).
4341
- This parameter does not support fields with array values. Fields with array
4342
- values may return inconsistent results.
4343
- :param grid_agg: Aggregation used to create a grid for the `field`.
5461
+ :param fields: The fields to return in the `hits` layer. It supports wildcards
5462
+ (`*`). This parameter does not support fields with array values. Fields with
5463
+ array values may return inconsistent results.
5464
+ :param grid_agg: The aggregation used to create a grid for the `field`.
4344
5465
  :param grid_precision: Additional zoom levels available through the aggs layer.
4345
- For example, if <zoom> is 7 and grid_precision is 8, you can zoom in up to
4346
- level 15. Accepts 0-8. If 0, results dont include the aggs layer.
5466
+ For example, if `<zoom>` is `7` and `grid_precision` is `8`, you can zoom
5467
+ in up to level 15. Accepts 0-8. If 0, results don't include the aggs layer.
4347
5468
  :param grid_type: Determines the geometry type for features in the aggs layer.
4348
- In the aggs layer, each feature represents a geotile_grid cell. If 'grid'
4349
- each feature is a Polygon of the cells bounding box. If 'point' each feature
5469
+ In the aggs layer, each feature represents a `geotile_grid` cell. If `grid,
5470
+ each feature is a polygon of the cells bounding box. If `point`, each feature
4350
5471
  is a Point that is the centroid of the cell.
4351
- :param query: Query DSL used to filter documents for the search.
5472
+ :param query: The query DSL used to filter documents for the search.
4352
5473
  :param runtime_mappings: Defines one or more runtime fields in the search request.
4353
5474
  These fields take precedence over mapped fields with the same name.
4354
- :param size: Maximum number of features to return in the hits layer. Accepts
4355
- 0-10000. If 0, results dont include the hits layer.
4356
- :param sort: Sorts features in the hits layer. By default, the API calculates
4357
- a bounding box for each feature. It sorts features based on this boxs diagonal
5475
+ :param size: The maximum number of features to return in the hits layer. Accepts
5476
+ 0-10000. If 0, results don't include the hits layer.
5477
+ :param sort: Sort the features in the hits layer. By default, the API calculates
5478
+ a bounding box for each feature. It sorts features based on this box's diagonal
4358
5479
  length, from longest to shortest.
4359
- :param track_total_hits: Number of hits matching the query to count accurately.
5480
+ :param track_total_hits: The number of hits matching the query to count accurately.
4360
5481
  If `true`, the exact number of hits is returned at the cost of some performance.
4361
5482
  If `false`, the response does not include the total number of hits matching
4362
5483
  the query.
4363
5484
  :param with_labels: If `true`, the hits and aggs layers will contain additional
4364
5485
  point features representing suggested label positions for the original features.
5486
+ * `Point` and `MultiPoint` features will have one of the points selected.
5487
+ * `Polygon` and `MultiPolygon` features will have a single point generated,
5488
+ either the centroid, if it is within the polygon, or another point within
5489
+ the polygon selected from the sorted triangle-tree. * `LineString` features
5490
+ will likewise provide a roughly central point selected from the triangle-tree.
5491
+ * The aggregation results will provide one central point for each aggregation
5492
+ bucket. All attributes from the original features will also be copied to
5493
+ the new label features. In addition, the new features will be distinguishable
5494
+ using the tag `_mvt_label_position`.
4365
5495
  """
4366
5496
  if index in SKIP_IN_PATH:
4367
5497
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4470,15 +5600,20 @@ class Elasticsearch(BaseClient):
4470
5600
  routing: t.Optional[str] = None,
4471
5601
  ) -> ObjectApiResponse[t.Any]:
4472
5602
  """
4473
- Get the search shards. Get the indices and shards that a search request would
4474
- be run against. This information can be useful for working out issues or planning
4475
- optimizations with routing and shard preferences. When filtered aliases are used,
4476
- the filter is returned as part of the indices section.
5603
+ .. raw:: html
5604
+
5605
+ <p>Get the search shards.</p>
5606
+ <p>Get the indices and shards that a search request would be run against.
5607
+ This information can be useful for working out issues or planning optimizations with routing and shard preferences.
5608
+ When filtered aliases are used, the filter is returned as part of the <code>indices</code> section.</p>
5609
+ <p>If the Elasticsearch security features are enabled, you must have the <code>view_index_metadata</code> or <code>manage</code> index privilege for the target data stream, index, or alias.</p>
5610
+
4477
5611
 
4478
5612
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-shards.html>`_
4479
5613
 
4480
- :param index: Returns the indices and shards that a search request would be executed
4481
- against.
5614
+ :param index: A comma-separated list of data streams, indices, and aliases to
5615
+ search. It supports wildcards (`*`). To search all data streams and indices,
5616
+ omit this parameter or use `*` or `_all`.
4482
5617
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4483
5618
  expression, index alias, or `_all` value targets only missing or closed indices.
4484
5619
  This behavior applies even if the request targets other open indices. For
@@ -4492,9 +5627,9 @@ class Elasticsearch(BaseClient):
4492
5627
  a missing or closed index.
4493
5628
  :param local: If `true`, the request retrieves information from the local node
4494
5629
  only.
4495
- :param preference: Specifies the node or shard the operation should be performed
4496
- on. Random by default.
4497
- :param routing: Custom value used to route operations to a specific shard.
5630
+ :param preference: The node or shard the operation should be performed on. It
5631
+ is random by default.
5632
+ :param routing: A custom value used to route operations to a specific shard.
4498
5633
  """
4499
5634
  __path_parts: t.Dict[str, str]
4500
5635
  if index not in SKIP_IN_PATH:
@@ -4574,12 +5709,15 @@ class Elasticsearch(BaseClient):
4574
5709
  body: t.Optional[t.Dict[str, t.Any]] = None,
4575
5710
  ) -> ObjectApiResponse[t.Any]:
4576
5711
  """
4577
- Run a search with a search template.
5712
+ .. raw:: html
5713
+
5714
+ <p>Run a search with a search template.</p>
4578
5715
 
4579
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-template.html>`_
4580
5716
 
4581
- :param index: Comma-separated list of data streams, indices, and aliases to search.
4582
- Supports wildcards (*).
5717
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-template-api.html>`_
5718
+
5719
+ :param index: A comma-separated list of data streams, indices, and aliases to
5720
+ search. It supports wildcards (`*`).
4583
5721
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
4584
5722
  expression, index alias, or `_all` value targets only missing or closed indices.
4585
5723
  This behavior applies even if the request targets other open indices. For
@@ -4587,32 +5725,34 @@ class Elasticsearch(BaseClient):
4587
5725
  with `foo` but no index starts with `bar`.
4588
5726
  :param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
4589
5727
  for cross-cluster search requests.
4590
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
4591
- request can target data streams, this argument determines whether wildcard
4592
- expressions match hidden data streams. Supports comma-separated values, such
4593
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
5728
+ :param expand_wildcards: The type of index that wildcard patterns can match.
5729
+ If the request can target data streams, this argument determines whether
5730
+ wildcard expressions match hidden data streams. Supports comma-separated
5731
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
5732
+ `hidden`, `none`.
4594
5733
  :param explain: If `true`, returns detailed information about score calculation
4595
- as part of each hit.
4596
- :param id: ID of the search template to use. If no source is specified, this
4597
- parameter is required.
5734
+ as part of each hit. If you specify both this and the `explain` query parameter,
5735
+ the API uses only the query parameter.
5736
+ :param id: The ID of the search template to use. If no `source` is specified,
5737
+ this parameter is required.
4598
5738
  :param ignore_throttled: If `true`, specified concrete, expanded, or aliased
4599
5739
  indices are not included in the response when throttled.
4600
5740
  :param ignore_unavailable: If `false`, the request returns an error if it targets
4601
5741
  a missing or closed index.
4602
5742
  :param params: Key-value pairs used to replace Mustache variables in the template.
4603
5743
  The key is the variable name. The value is the variable value.
4604
- :param preference: Specifies the node or shard the operation should be performed
4605
- on. Random by default.
5744
+ :param preference: The node or shard the operation should be performed on. It
5745
+ is random by default.
4606
5746
  :param profile: If `true`, the query execution is profiled.
4607
- :param rest_total_hits_as_int: If true, hits.total are rendered as an integer
4608
- in the response.
4609
- :param routing: Custom value used to route operations to a specific shard.
5747
+ :param rest_total_hits_as_int: If `true`, `hits.total` is rendered as an integer
5748
+ in the response. If `false`, it is rendered as an object.
5749
+ :param routing: A custom value used to route operations to a specific shard.
4610
5750
  :param scroll: Specifies how long a consistent view of the index should be maintained
4611
5751
  for scrolled search.
4612
5752
  :param search_type: The type of the search operation.
4613
5753
  :param source: An inline search template. Supports the same parameters as the
4614
- search API's request body. Also supports Mustache variables. If no id is
4615
- specified, this parameter is required.
5754
+ search API's request body. It also supports Mustache variables. If no `id`
5755
+ is specified, this parameter is required.
4616
5756
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
4617
5757
  names with their respective types.
4618
5758
  """
@@ -4706,34 +5846,39 @@ class Elasticsearch(BaseClient):
4706
5846
  body: t.Optional[t.Dict[str, t.Any]] = None,
4707
5847
  ) -> ObjectApiResponse[t.Any]:
4708
5848
  """
4709
- Get terms in an index. Discover terms that match a partial string in an index.
4710
- This "terms enum" API is designed for low-latency look-ups used in auto-complete
4711
- scenarios. If the `complete` property in the response is false, the returned
4712
- terms set may be incomplete and should be treated as approximate. This can occur
4713
- due to a few reasons, such as a request timeout or a node error. NOTE: The terms
4714
- enum API may return terms from deleted documents. Deleted documents are initially
4715
- only marked as deleted. It is not until their segments are merged that documents
4716
- are actually deleted. Until that happens, the terms enum API will return terms
4717
- from these documents.
5849
+ .. raw:: html
5850
+
5851
+ <p>Get terms in an index.</p>
5852
+ <p>Discover terms that match a partial string in an index.
5853
+ This API is designed for low-latency look-ups used in auto-complete scenarios.</p>
5854
+ <blockquote>
5855
+ <p>info
5856
+ The terms enum API may return terms from deleted documents. Deleted documents are initially only marked as deleted. It is not until their segments are merged that documents are actually deleted. Until that happens, the terms enum API will return terms from these documents.</p>
5857
+ </blockquote>
5858
+
4718
5859
 
4719
5860
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-terms-enum.html>`_
4720
5861
 
4721
- :param index: Comma-separated list of data streams, indices, and index aliases
4722
- to search. Wildcard (*) expressions are supported.
5862
+ :param index: A comma-separated list of data streams, indices, and index aliases
5863
+ to search. Wildcard (`*`) expressions are supported. To search all data streams
5864
+ or indices, omit this parameter or use `*` or `_all`.
4723
5865
  :param field: The string to match at the start of indexed terms. If not provided,
4724
5866
  all terms in the field are considered.
4725
- :param case_insensitive: When true the provided search string is matched against
5867
+ :param case_insensitive: When `true`, the provided search string is matched against
4726
5868
  index terms without case sensitivity.
4727
- :param index_filter: Allows to filter an index shard if the provided query rewrites
4728
- to match_none.
4729
- :param search_after:
4730
- :param size: How many matching terms to return.
4731
- :param string: The string after which terms in the index should be returned.
4732
- Allows for a form of pagination if the last result from one request is passed
4733
- as the search_after parameter for a subsequent request.
4734
- :param timeout: The maximum length of time to spend collecting results. Defaults
4735
- to "1s" (one second). If the timeout is exceeded the complete flag set to
4736
- false in the response and the results may be partial or empty.
5869
+ :param index_filter: Filter an index shard if the provided query rewrites to
5870
+ `match_none`.
5871
+ :param search_after: The string after which terms in the index should be returned.
5872
+ It allows for a form of pagination if the last result from one request is
5873
+ passed as the `search_after` parameter for a subsequent request.
5874
+ :param size: The number of matching terms to return.
5875
+ :param string: The string to match at the start of indexed terms. If it is not
5876
+ provided, all terms in the field are considered. > info > The prefix string
5877
+ cannot be larger than the largest possible keyword value, which is Lucene's
5878
+ term byte-length limit of 32766.
5879
+ :param timeout: The maximum length of time to spend collecting results. If the
5880
+ timeout is exceeded the `complete` flag set to `false` in the response and
5881
+ the results may be partial or empty.
4737
5882
  """
4738
5883
  if index in SKIP_IN_PATH:
4739
5884
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4812,33 +5957,77 @@ class Elasticsearch(BaseClient):
4812
5957
  body: t.Optional[t.Dict[str, t.Any]] = None,
4813
5958
  ) -> ObjectApiResponse[t.Any]:
4814
5959
  """
4815
- Get term vector information. Get information and statistics about terms in the
4816
- fields of a particular document.
5960
+ .. raw:: html
5961
+
5962
+ <p>Get term vector information.</p>
5963
+ <p>Get information and statistics about terms in the fields of a particular document.</p>
5964
+ <p>You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request.
5965
+ You can specify the fields you are interested in through the <code>fields</code> parameter or by adding the fields to the request body.
5966
+ For example:</p>
5967
+ <pre><code>GET /my-index-000001/_termvectors/1?fields=message
5968
+ </code></pre>
5969
+ <p>Fields can be specified using wildcards, similar to the multi match query.</p>
5970
+ <p>Term vectors are real-time by default, not near real-time.
5971
+ This can be changed by setting <code>realtime</code> parameter to <code>false</code>.</p>
5972
+ <p>You can request three types of values: <em>term information</em>, <em>term statistics</em>, and <em>field statistics</em>.
5973
+ By default, all term information and field statistics are returned for all fields but term statistics are excluded.</p>
5974
+ <p><strong>Term information</strong></p>
5975
+ <ul>
5976
+ <li>term frequency in the field (always returned)</li>
5977
+ <li>term positions (<code>positions: true</code>)</li>
5978
+ <li>start and end offsets (<code>offsets: true</code>)</li>
5979
+ <li>term payloads (<code>payloads: true</code>), as base64 encoded bytes</li>
5980
+ </ul>
5981
+ <p>If the requested information wasn't stored in the index, it will be computed on the fly if possible.
5982
+ Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.</p>
5983
+ <blockquote>
5984
+ <p>warn
5985
+ Start and end offsets assume UTF-16 encoding is being used. If you want to use these offsets in order to get the original text that produced this token, you should make sure that the string you are taking a sub-string of is also encoded using UTF-16.</p>
5986
+ </blockquote>
5987
+ <p><strong>Behaviour</strong></p>
5988
+ <p>The term and field statistics are not accurate.
5989
+ Deleted documents are not taken into account.
5990
+ The information is only retrieved for the shard the requested document resides in.
5991
+ The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
5992
+ By default, when requesting term vectors of artificial documents, a shard to get the statistics from is randomly selected.
5993
+ Use <code>routing</code> only to hit a particular shard.</p>
5994
+
4817
5995
 
4818
5996
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-termvectors.html>`_
4819
5997
 
4820
- :param index: Name of the index that contains the document.
4821
- :param id: Unique identifier of the document.
5998
+ :param index: The name of the index that contains the document.
5999
+ :param id: A unique identifier for the document.
4822
6000
  :param doc: An artificial document (a document not present in the index) for
4823
6001
  which you want to retrieve term vectors.
4824
- :param field_statistics: If `true`, the response includes the document count,
4825
- sum of document frequencies, and sum of total term frequencies.
4826
- :param fields: Comma-separated list or wildcard expressions of fields to include
4827
- in the statistics. Used as the default list unless a specific field list
4828
- is provided in the `completion_fields` or `fielddata_fields` parameters.
4829
- :param filter: Filter terms based on their tf-idf scores.
6002
+ :param field_statistics: If `true`, the response includes: * The document count
6003
+ (how many documents contain this field). * The sum of document frequencies
6004
+ (the sum of document frequencies for all terms in this field). * The sum
6005
+ of total term frequencies (the sum of total term frequencies of each term
6006
+ in this field).
6007
+ :param fields: A comma-separated list or wildcard expressions of fields to include
6008
+ in the statistics. It is used as the default list unless a specific field
6009
+ list is provided in the `completion_fields` or `fielddata_fields` parameters.
6010
+ :param filter: Filter terms based on their tf-idf scores. This could be useful
6011
+ in order find out a good characteristic vector of a document. This feature
6012
+ works in a similar manner to the second phase of the More Like This Query.
4830
6013
  :param offsets: If `true`, the response includes term offsets.
4831
6014
  :param payloads: If `true`, the response includes term payloads.
4832
- :param per_field_analyzer: Overrides the default per-field analyzer.
6015
+ :param per_field_analyzer: Override the default per-field analyzer. This is useful
6016
+ in order to generate term vectors in any fashion, especially when using artificial
6017
+ documents. When providing an analyzer for a field that already stores term
6018
+ vectors, the term vectors will be regenerated.
4833
6019
  :param positions: If `true`, the response includes term positions.
4834
- :param preference: Specifies the node or shard the operation should be performed
4835
- on. Random by default.
6020
+ :param preference: The node or shard the operation should be performed on. It
6021
+ is random by default.
4836
6022
  :param realtime: If true, the request is real-time as opposed to near-real-time.
4837
- :param routing: Custom value used to route operations to a specific shard.
4838
- :param term_statistics: If `true`, the response includes term frequency and document
4839
- frequency.
6023
+ :param routing: A custom value that is used to route operations to a specific
6024
+ shard.
6025
+ :param term_statistics: If `true`, the response includes: * The total term frequency
6026
+ (how often a term occurs in all documents). * The document frequency (the
6027
+ number of documents containing the current term). By default these values
6028
+ are not returned since term statistics can have a serious performance impact.
4840
6029
  :param version: If `true`, returns the document version as part of a hit.
4841
- :param version_type: Specific version type.
6030
+ :param version_type: The version type.
4842
6031
  """
4843
6032
  if index in SKIP_IN_PATH:
4844
6033
  raise ValueError("Empty value passed for parameter 'index'")
@@ -4955,46 +6144,65 @@ class Elasticsearch(BaseClient):
4955
6144
  body: t.Optional[t.Dict[str, t.Any]] = None,
4956
6145
  ) -> ObjectApiResponse[t.Any]:
4957
6146
  """
4958
- Update a document. Updates a document by running a script or passing a partial
4959
- document.
6147
+ .. raw:: html
6148
+
6149
+ <p>Update a document.</p>
6150
+ <p>Update a document by running a script or passing a partial document.</p>
6151
+ <p>If the Elasticsearch security features are enabled, you must have the <code>index</code> or <code>write</code> index privilege for the target index or index alias.</p>
6152
+ <p>The script can update, delete, or skip modifying the document.
6153
+ The API also supports passing a partial document, which is merged into the existing document.
6154
+ To fully replace an existing document, use the index API.
6155
+ This operation:</p>
6156
+ <ul>
6157
+ <li>Gets the document (collocated with the shard) from the index.</li>
6158
+ <li>Runs the specified script.</li>
6159
+ <li>Indexes the result.</li>
6160
+ </ul>
6161
+ <p>The document must still be reindexed, but using this API removes some network roundtrips and reduces chances of version conflicts between the GET and the index operation.</p>
6162
+ <p>The <code>_source</code> field must be enabled to use this API.
6163
+ In addition to <code>_source</code>, you can access the following variables through the <code>ctx</code> map: <code>_index</code>, <code>_type</code>, <code>_id</code>, <code>_version</code>, <code>_routing</code>, and <code>_now</code> (the current timestamp).</p>
6164
+
4960
6165
 
4961
6166
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update.html>`_
4962
6167
 
4963
- :param index: The name of the index
4964
- :param id: Document ID
4965
- :param detect_noop: Set to false to disable setting 'result' in the response
4966
- to 'noop' if no change to the document occurred.
4967
- :param doc: A partial update to an existing document.
4968
- :param doc_as_upsert: Set to true to use the contents of 'doc' as the value of
4969
- 'upsert'
6168
+ :param index: The name of the target index. By default, the index is created
6169
+ automatically if it doesn't exist.
6170
+ :param id: A unique identifier for the document to be updated.
6171
+ :param detect_noop: If `true`, the `result` in the response is set to `noop`
6172
+ (no operation) when there are no changes to the document.
6173
+ :param doc: A partial update to an existing document. If both `doc` and `script`
6174
+ are specified, `doc` is ignored.
6175
+ :param doc_as_upsert: If `true`, use the contents of 'doc' as the value of 'upsert'.
6176
+ NOTE: Using ingest pipelines with `doc_as_upsert` is not supported.
4970
6177
  :param if_primary_term: Only perform the operation if the document has this primary
4971
6178
  term.
4972
6179
  :param if_seq_no: Only perform the operation if the document has this sequence
4973
6180
  number.
4974
6181
  :param lang: The script language.
4975
6182
  :param refresh: If 'true', Elasticsearch refreshes the affected shards to make
4976
- this operation visible to search, if 'wait_for' then wait for a refresh to
4977
- make this operation visible to search, if 'false' do nothing with refreshes.
4978
- :param require_alias: If true, the destination must be an index alias.
4979
- :param retry_on_conflict: Specify how many times should the operation be retried
6183
+ this operation visible to search. If 'wait_for', it waits for a refresh to
6184
+ make this operation visible to search. If 'false', it does nothing with refreshes.
6185
+ :param require_alias: If `true`, the destination must be an index alias.
6186
+ :param retry_on_conflict: The number of times the operation should be retried
4980
6187
  when a conflict occurs.
4981
- :param routing: Custom value used to route operations to a specific shard.
4982
- :param script: Script to execute to update the document.
4983
- :param scripted_upsert: Set to true to execute the script whether or not the
4984
- document exists.
4985
- :param source: Set to false to disable source retrieval. You can also specify
4986
- a comma-separated list of the fields you want to retrieve.
4987
- :param source_excludes: Specify the source fields you want to exclude.
4988
- :param source_includes: Specify the source fields you want to retrieve.
4989
- :param timeout: Period to wait for dynamic mapping updates and active shards.
4990
- This guarantees Elasticsearch waits for at least the timeout before failing.
4991
- The actual wait time could be longer, particularly when multiple waits occur.
6188
+ :param routing: A custom value used to route operations to a specific shard.
6189
+ :param script: The script to run to update the document.
6190
+ :param scripted_upsert: If `true`, run the script whether or not the document
6191
+ exists.
6192
+ :param source: If `false`, turn off source retrieval. You can also specify a
6193
+ comma-separated list of the fields you want to retrieve.
6194
+ :param source_excludes: The source fields you want to exclude.
6195
+ :param source_includes: The source fields you want to retrieve.
6196
+ :param timeout: The period to wait for the following operations: dynamic mapping
6197
+ updates and waiting for active shards. Elasticsearch waits for at least the
6198
+ timeout period before failing. The actual wait time could be longer, particularly
6199
+ when multiple waits occur.
4992
6200
  :param upsert: If the document does not already exist, the contents of 'upsert'
4993
- are inserted as a new document. If the document exists, the 'script' is executed.
4994
- :param wait_for_active_shards: The number of shard copies that must be active
4995
- before proceeding with the operations. Set to 'all' or any positive integer
4996
- up to the total number of shards in the index (number_of_replicas+1). Defaults
4997
- to 1 meaning the primary shard.
6201
+ are inserted as a new document. If the document exists, the 'script' is run.
6202
+ :param wait_for_active_shards: The number of copies of each shard that must be
6203
+ active before proceeding with the operation. Set to 'all' or any positive
6204
+ integer up to the total number of shards in the index (`number_of_replicas`+1).
6205
+ The default value of `1` means it waits for each primary shard to be active.
4998
6206
  """
4999
6207
  if index in SKIP_IN_PATH:
5000
6208
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5120,82 +6328,166 @@ class Elasticsearch(BaseClient):
5120
6328
  body: t.Optional[t.Dict[str, t.Any]] = None,
5121
6329
  ) -> ObjectApiResponse[t.Any]:
5122
6330
  """
5123
- Update documents. Updates documents that match the specified query. If no query
5124
- is specified, performs an update on every document in the data stream or index
5125
- without modifying the source, which is useful for picking up mapping changes.
6331
+ .. raw:: html
6332
+
6333
+ <p>Update documents.
6334
+ Updates documents that match the specified query.
6335
+ If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.</p>
6336
+ <p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
6337
+ <ul>
6338
+ <li><code>read</code></li>
6339
+ <li><code>index</code> or <code>write</code></li>
6340
+ </ul>
6341
+ <p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.</p>
6342
+ <p>When you submit an update by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and updates matching documents using internal versioning.
6343
+ When the versions match, the document is updated and the version number is incremented.
6344
+ If a document changes between the time that the snapshot is taken and the update operation is processed, it results in a version conflict and the operation fails.
6345
+ You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
6346
+ Note that if you opt to count version conflicts, the operation could attempt to update more documents from the source than <code>max_docs</code> until it has successfully updated <code>max_docs</code> documents or it has gone through every document in the source query.</p>
6347
+ <p>NOTE: Documents with a version equal to 0 cannot be updated using update by query because internal versioning does not support 0 as a valid version number.</p>
6348
+ <p>While processing an update by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents.
6349
+ A bulk update request is performed for each batch of matching documents.
6350
+ Any query or update failures cause the update by query request to fail and the failures are shown in the response.
6351
+ Any update requests that completed successfully still stick, they are not rolled back.</p>
6352
+ <p><strong>Throttling update requests</strong></p>
6353
+ <p>To control the rate at which update by query issues batches of update operations, you can set <code>requests_per_second</code> to any positive decimal number.
6354
+ This pads each batch with a wait time to throttle the rate.
6355
+ Set <code>requests_per_second</code> to <code>-1</code> to turn off throttling.</p>
6356
+ <p>Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
6357
+ The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
6358
+ By default the batch size is 1000, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
6359
+ <pre><code>target_time = 1000 / 500 per second = 2 seconds
6360
+ wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
6361
+ </code></pre>
6362
+ <p>Since the batch is issued as a single _bulk request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
6363
+ This is &quot;bursty&quot; instead of &quot;smooth&quot;.</p>
6364
+ <p><strong>Slicing</strong></p>
6365
+ <p>Update by query supports sliced scroll to parallelize the update process.
6366
+ This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
6367
+ <p>Setting <code>slices</code> to <code>auto</code> chooses a reasonable number for most data streams and indices.
6368
+ This setting will use one slice per shard, up to a certain limit.
6369
+ If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.</p>
6370
+ <p>Adding <code>slices</code> to <code>_update_by_query</code> just automates the manual process of creating sub-requests, which means it has some quirks:</p>
6371
+ <ul>
6372
+ <li>You can see these requests in the tasks APIs. These sub-requests are &quot;child&quot; tasks of the task for the request with slices.</li>
6373
+ <li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
6374
+ <li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
6375
+ <li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
6376
+ <li>Canceling the request with slices will cancel each sub-request.</li>
6377
+ <li>Due to the nature of slices each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
6378
+ <li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with slices are distributed proportionally to each sub-request. Combine that with the point above about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being updated.</li>
6379
+ <li>Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.</li>
6380
+ </ul>
6381
+ <p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
6382
+ <ul>
6383
+ <li>Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many slices hurts performance. Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</li>
6384
+ <li>Update performance scales linearly across available resources with the number of slices.</li>
6385
+ </ul>
6386
+ <p>Whether query or update performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
6387
+ <p><strong>Update the document source</strong></p>
6388
+ <p>Update by query supports scripts to update the document source.
6389
+ As with the update API, you can set <code>ctx.op</code> to change the operation that is performed.</p>
6390
+ <p>Set <code>ctx.op = &quot;noop&quot;</code> if your script decides that it doesn't have to make any changes.
6391
+ The update by query operation skips updating the document and increments the <code>noop</code> counter.</p>
6392
+ <p>Set <code>ctx.op = &quot;delete&quot;</code> if your script decides that the document should be deleted.
6393
+ The update by query operation deletes the document and increments the <code>deleted</code> counter.</p>
6394
+ <p>Update by query supports only <code>index</code>, <code>noop</code>, and <code>delete</code>.
6395
+ Setting <code>ctx.op</code> to anything else is an error.
6396
+ Setting any other field in <code>ctx</code> is an error.
6397
+ This API enables you to only modify the source of matching documents; you cannot move them.</p>
6398
+
5126
6399
 
5127
6400
  `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
5128
6401
 
5129
- :param index: Comma-separated list of data streams, indices, and aliases to search.
5130
- Supports wildcards (`*`). To search all data streams or indices, omit this
5131
- parameter or use `*` or `_all`.
6402
+ :param index: A comma-separated list of data streams, indices, and aliases to
6403
+ search. It supports wildcards (`*`). To search all data streams or indices,
6404
+ omit this parameter or use `*` or `_all`.
5132
6405
  :param allow_no_indices: If `false`, the request returns an error if any wildcard
5133
6406
  expression, index alias, or `_all` value targets only missing or closed indices.
5134
6407
  This behavior applies even if the request targets other open indices. For
5135
6408
  example, a request targeting `foo*,bar*` returns an error if an index starts
5136
6409
  with `foo` but no index starts with `bar`.
5137
6410
  :param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
5138
- :param analyzer: Analyzer to use for the query string.
5139
- :param conflicts: What to do if update by query hits version conflicts: `abort`
5140
- or `proceed`.
6411
+ This parameter can be used only when the `q` query string parameter is specified.
6412
+ :param analyzer: The analyzer to use for the query string. This parameter can
6413
+ be used only when the `q` query string parameter is specified.
6414
+ :param conflicts: The preferred behavior when update by query hits version conflicts:
6415
+ `abort` or `proceed`.
5141
6416
  :param default_operator: The default operator for query string query: `AND` or
5142
- `OR`.
5143
- :param df: Field to use as default where no field prefix is given in the query
5144
- string.
5145
- :param expand_wildcards: Type of index that wildcard patterns can match. If the
5146
- request can target data streams, this argument determines whether wildcard
5147
- expressions match hidden data streams. Supports comma-separated values, such
5148
- as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
6417
+ `OR`. This parameter can be used only when the `q` query string parameter
6418
+ is specified.
6419
+ :param df: The field to use as default where no field prefix is given in the
6420
+ query string. This parameter can be used only when the `q` query string parameter
6421
+ is specified.
6422
+ :param expand_wildcards: The type of index that wildcard patterns can match.
6423
+ If the request can target data streams, this argument determines whether
6424
+ wildcard expressions match hidden data streams. It supports comma-separated
6425
+ values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
6426
+ `hidden`, `none`.
5149
6427
  :param from_: Starting offset (default: 0)
5150
6428
  :param ignore_unavailable: If `false`, the request returns an error if it targets
5151
6429
  a missing or closed index.
5152
6430
  :param lenient: If `true`, format-based query failures (such as providing text
5153
- to a numeric field) in the query string will be ignored.
6431
+ to a numeric field) in the query string will be ignored. This parameter can
6432
+ be used only when the `q` query string parameter is specified.
5154
6433
  :param max_docs: The maximum number of documents to update.
5155
- :param pipeline: ID of the pipeline to use to preprocess incoming documents.
6434
+ :param pipeline: The ID of the pipeline to use to preprocess incoming documents.
5156
6435
  If the index has a default ingest pipeline specified, then setting the value
5157
6436
  to `_none` disables the default ingest pipeline for this request. If a final
5158
6437
  pipeline is configured it will always run, regardless of the value of this
5159
6438
  parameter.
5160
- :param preference: Specifies the node or shard the operation should be performed
5161
- on. Random by default.
5162
- :param q: Query in the Lucene query string syntax.
5163
- :param query: Specifies the documents to update using the Query DSL.
6439
+ :param preference: The node or shard the operation should be performed on. It
6440
+ is random by default.
6441
+ :param q: A query in the Lucene query string syntax.
6442
+ :param query: The documents to update using the Query DSL.
5164
6443
  :param refresh: If `true`, Elasticsearch refreshes affected shards to make the
5165
- operation visible to search.
6444
+ operation visible to search after the request completes. This is different
6445
+ than the update API's `refresh` parameter, which causes just the shard that
6446
+ received the request to be refreshed.
5166
6447
  :param request_cache: If `true`, the request cache is used for this request.
6448
+ It defaults to the index-level setting.
5167
6449
  :param requests_per_second: The throttle for this request in sub-requests per
5168
6450
  second.
5169
- :param routing: Custom value used to route operations to a specific shard.
6451
+ :param routing: A custom value used to route operations to a specific shard.
5170
6452
  :param script: The script to run to update the document source or metadata when
5171
6453
  updating.
5172
- :param scroll: Period to retain the search context for scrolling.
5173
- :param scroll_size: Size of the scroll request that powers the operation.
5174
- :param search_timeout: Explicit timeout for each search request.
5175
- :param search_type: The type of the search operation. Available options: `query_then_fetch`,
5176
- `dfs_query_then_fetch`.
6454
+ :param scroll: The period to retain the search context for scrolling.
6455
+ :param scroll_size: The size of the scroll request that powers the operation.
6456
+ :param search_timeout: An explicit timeout for each search request. By default,
6457
+ there is no timeout.
6458
+ :param search_type: The type of the search operation. Available options include
6459
+ `query_then_fetch` and `dfs_query_then_fetch`.
5177
6460
  :param slice: Slice the request manually using the provided slice ID and total
5178
6461
  number of slices.
5179
6462
  :param slices: The number of slices this task should be divided into.
5180
6463
  :param sort: A comma-separated list of <field>:<direction> pairs.
5181
- :param stats: Specific `tag` of the request for logging and statistical purposes.
5182
- :param terminate_after: Maximum number of documents to collect for each shard.
6464
+ :param stats: The specific `tag` of the request for logging and statistical purposes.
6465
+ :param terminate_after: The maximum number of documents to collect for each shard.
5183
6466
  If a query reaches this limit, Elasticsearch terminates the query early.
5184
- Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
5185
- applies this parameter to each shard handling the request. When possible,
5186
- let Elasticsearch perform early termination automatically. Avoid specifying
5187
- this parameter for requests that target data streams with backing indices
5188
- across multiple data tiers.
5189
- :param timeout: Period each update request waits for the following operations:
5190
- dynamic mapping updates, waiting for active shards.
6467
+ Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
6468
+ Elasticsearch applies this parameter to each shard handling the request.
6469
+ When possible, let Elasticsearch perform early termination automatically.
6470
+ Avoid specifying this parameter for requests that target data streams with
6471
+ backing indices across multiple data tiers.
6472
+ :param timeout: The period each update request waits for the following operations:
6473
+ dynamic mapping updates, waiting for active shards. By default, it is one
6474
+ minute. This guarantees Elasticsearch waits for at least the timeout before
6475
+ failing. The actual wait time could be longer, particularly when multiple
6476
+ waits occur.
5191
6477
  :param version: If `true`, returns the document version as part of a hit.
5192
6478
  :param version_type: Should the document increment the version number (internal)
5193
6479
  on hit or not (reindex)
5194
6480
  :param wait_for_active_shards: The number of shard copies that must be active
5195
6481
  before proceeding with the operation. Set to `all` or any positive integer
5196
- up to the total number of shards in the index (`number_of_replicas+1`).
6482
+ up to the total number of shards in the index (`number_of_replicas+1`). The
6483
+ `timeout` parameter controls how long each write request waits for unavailable
6484
+ shards to become available. Both work exactly the way they work in the bulk
6485
+ API.
5197
6486
  :param wait_for_completion: If `true`, the request blocks until the operation
5198
- is complete.
6487
+ is complete. If `false`, Elasticsearch performs some preflight checks, launches
6488
+ the request, and returns a task ID that you can use to cancel or get the
6489
+ status of the task. Elasticsearch creates a record of this task as a document
6490
+ at `.tasks/task/${taskId}`.
5199
6491
  """
5200
6492
  if index in SKIP_IN_PATH:
5201
6493
  raise ValueError("Empty value passed for parameter 'index'")
@@ -5318,16 +6610,18 @@ class Elasticsearch(BaseClient):
5318
6610
  requests_per_second: t.Optional[float] = None,
5319
6611
  ) -> ObjectApiResponse[t.Any]:
5320
6612
  """
5321
- Throttle an update by query operation. Change the number of requests per second
5322
- for a particular update by query operation. Rethrottling that speeds up the query
5323
- takes effect immediately but rethrotting that slows down the query takes effect
5324
- after completing the current batch to prevent scroll timeouts.
6613
+ .. raw:: html
6614
+
6615
+ <p>Throttle an update by query operation.</p>
6616
+ <p>Change the number of requests per second for a particular update by query operation.
6617
+ Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.</p>
5325
6618
 
5326
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html>`_
6619
+
6620
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-update-by-query.html#docs-update-by-query-rethrottle>`_
5327
6621
 
5328
6622
  :param task_id: The ID for the task.
5329
6623
  :param requests_per_second: The throttle for this request in sub-requests per
5330
- second.
6624
+ second. To turn off throttling, set it to `-1`.
5331
6625
  """
5332
6626
  if task_id in SKIP_IN_PATH:
5333
6627
  raise ValueError("Empty value passed for parameter 'task_id'")