elasticsearch 8.11.1__py3-none-any.whl → 8.12.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. elasticsearch/_async/client/__init__.py +493 -347
  2. elasticsearch/_async/client/async_search.py +108 -72
  3. elasticsearch/_async/client/autoscaling.py +13 -8
  4. elasticsearch/_async/client/cat.py +26 -26
  5. elasticsearch/_async/client/ccr.py +178 -117
  6. elasticsearch/_async/client/cluster.py +56 -48
  7. elasticsearch/_async/client/dangling_indices.py +3 -3
  8. elasticsearch/_async/client/enrich.py +15 -13
  9. elasticsearch/_async/client/eql.py +53 -36
  10. elasticsearch/_async/client/esql.py +99 -0
  11. elasticsearch/_async/client/features.py +2 -2
  12. elasticsearch/_async/client/fleet.py +111 -71
  13. elasticsearch/_async/client/graph.py +13 -11
  14. elasticsearch/_async/client/ilm.py +33 -27
  15. elasticsearch/_async/client/indices.py +326 -227
  16. elasticsearch/_async/client/inference.py +212 -0
  17. elasticsearch/_async/client/ingest.py +28 -24
  18. elasticsearch/_async/client/license.py +15 -13
  19. elasticsearch/_async/client/logstash.py +13 -10
  20. elasticsearch/_async/client/migration.py +3 -3
  21. elasticsearch/_async/client/ml.py +758 -538
  22. elasticsearch/_async/client/monitoring.py +10 -5
  23. elasticsearch/_async/client/nodes.py +13 -11
  24. elasticsearch/_async/client/query_ruleset.py +12 -10
  25. elasticsearch/_async/client/rollup.py +59 -46
  26. elasticsearch/_async/client/search_application.py +23 -16
  27. elasticsearch/_async/client/searchable_snapshots.py +23 -16
  28. elasticsearch/_async/client/security.py +391 -289
  29. elasticsearch/_async/client/shutdown.py +18 -14
  30. elasticsearch/_async/client/slm.py +23 -21
  31. elasticsearch/_async/client/snapshot.py +91 -65
  32. elasticsearch/_async/client/sql.py +81 -58
  33. elasticsearch/_async/client/ssl.py +1 -1
  34. elasticsearch/_async/client/synonyms.py +23 -19
  35. elasticsearch/_async/client/tasks.py +3 -3
  36. elasticsearch/_async/client/text_structure.py +10 -5
  37. elasticsearch/_async/client/transform.py +111 -75
  38. elasticsearch/_async/client/watcher.py +77 -55
  39. elasticsearch/_async/client/xpack.py +2 -2
  40. elasticsearch/_async/helpers.py +1 -1
  41. elasticsearch/_sync/client/__init__.py +493 -347
  42. elasticsearch/_sync/client/async_search.py +108 -72
  43. elasticsearch/_sync/client/autoscaling.py +13 -8
  44. elasticsearch/_sync/client/cat.py +26 -26
  45. elasticsearch/_sync/client/ccr.py +178 -117
  46. elasticsearch/_sync/client/cluster.py +56 -48
  47. elasticsearch/_sync/client/dangling_indices.py +3 -3
  48. elasticsearch/_sync/client/enrich.py +15 -13
  49. elasticsearch/_sync/client/eql.py +53 -36
  50. elasticsearch/_sync/client/esql.py +99 -0
  51. elasticsearch/_sync/client/features.py +2 -2
  52. elasticsearch/_sync/client/fleet.py +111 -71
  53. elasticsearch/_sync/client/graph.py +13 -11
  54. elasticsearch/_sync/client/ilm.py +33 -27
  55. elasticsearch/_sync/client/indices.py +326 -227
  56. elasticsearch/_sync/client/inference.py +212 -0
  57. elasticsearch/_sync/client/ingest.py +28 -24
  58. elasticsearch/_sync/client/license.py +15 -13
  59. elasticsearch/_sync/client/logstash.py +13 -10
  60. elasticsearch/_sync/client/migration.py +3 -3
  61. elasticsearch/_sync/client/ml.py +758 -538
  62. elasticsearch/_sync/client/monitoring.py +10 -5
  63. elasticsearch/_sync/client/nodes.py +13 -11
  64. elasticsearch/_sync/client/query_ruleset.py +12 -10
  65. elasticsearch/_sync/client/rollup.py +59 -46
  66. elasticsearch/_sync/client/search_application.py +23 -16
  67. elasticsearch/_sync/client/searchable_snapshots.py +23 -16
  68. elasticsearch/_sync/client/security.py +391 -289
  69. elasticsearch/_sync/client/shutdown.py +18 -14
  70. elasticsearch/_sync/client/slm.py +23 -21
  71. elasticsearch/_sync/client/snapshot.py +91 -65
  72. elasticsearch/_sync/client/sql.py +81 -58
  73. elasticsearch/_sync/client/ssl.py +1 -1
  74. elasticsearch/_sync/client/synonyms.py +23 -19
  75. elasticsearch/_sync/client/tasks.py +3 -3
  76. elasticsearch/_sync/client/text_structure.py +10 -5
  77. elasticsearch/_sync/client/transform.py +111 -75
  78. elasticsearch/_sync/client/utils.py +34 -10
  79. elasticsearch/_sync/client/watcher.py +77 -55
  80. elasticsearch/_sync/client/xpack.py +2 -2
  81. elasticsearch/_version.py +1 -1
  82. elasticsearch/client.py +2 -0
  83. elasticsearch/helpers/actions.py +1 -1
  84. {elasticsearch-8.11.1.dist-info → elasticsearch-8.12.0.dist-info}/METADATA +2 -3
  85. elasticsearch-8.12.0.dist-info/RECORD +103 -0
  86. elasticsearch-8.11.1.dist-info/RECORD +0 -99
  87. {elasticsearch-8.11.1.dist-info → elasticsearch-8.12.0.dist-info}/LICENSE +0 -0
  88. {elasticsearch-8.11.1.dist-info → elasticsearch-8.12.0.dist-info}/NOTICE +0 -0
  89. {elasticsearch-8.11.1.dist-info → elasticsearch-8.12.0.dist-info}/WHEEL +0 -0
  90. {elasticsearch-8.11.1.dist-info → elasticsearch-8.12.0.dist-info}/top_level.txt +0 -0
@@ -49,11 +49,13 @@ from .cluster import ClusterClient
49
49
  from .dangling_indices import DanglingIndicesClient
50
50
  from .enrich import EnrichClient
51
51
  from .eql import EqlClient
52
+ from .esql import EsqlClient
52
53
  from .features import FeaturesClient
53
54
  from .fleet import FleetClient
54
55
  from .graph import GraphClient
55
56
  from .ilm import IlmClient
56
57
  from .indices import IndicesClient
58
+ from .inference import InferenceClient
57
59
  from .ingest import IngestClient
58
60
  from .license import LicenseClient
59
61
  from .logstash import LogstashClient
@@ -434,6 +436,7 @@ class AsyncElasticsearch(BaseClient):
434
436
  self.fleet = FleetClient(self)
435
437
  self.features = FeaturesClient(self)
436
438
  self.indices = IndicesClient(self)
439
+ self.inference = InferenceClient(self)
437
440
  self.ingest = IngestClient(self)
438
441
  self.nodes = NodesClient(self)
439
442
  self.snapshot = SnapshotClient(self)
@@ -444,6 +447,7 @@ class AsyncElasticsearch(BaseClient):
444
447
  self.dangling_indices = DanglingIndicesClient(self)
445
448
  self.enrich = EnrichClient(self)
446
449
  self.eql = EqlClient(self)
450
+ self.esql = EsqlClient(self)
447
451
  self.graph = GraphClient(self)
448
452
  self.ilm = IlmClient(self)
449
453
  self.license = LicenseClient(self)
@@ -612,7 +616,8 @@ class AsyncElasticsearch(BaseClient):
612
616
  async def bulk(
613
617
  self,
614
618
  *,
615
- operations: t.Sequence[t.Mapping[str, t.Any]],
619
+ operations: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
620
+ body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
616
621
  index: t.Optional[str] = None,
617
622
  error_trace: t.Optional[bool] = None,
618
623
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -635,7 +640,7 @@ class AsyncElasticsearch(BaseClient):
635
640
  """
636
641
  Allows to perform multiple index/update/delete operations in a single request.
637
642
 
638
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-bulk.html>`_
643
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-bulk.html>`_
639
644
 
640
645
  :param operations:
641
646
  :param index: Name of the data stream, index, or index alias to perform bulk
@@ -663,8 +668,12 @@ class AsyncElasticsearch(BaseClient):
663
668
  before proceeding with the operation. Set to all or any positive integer
664
669
  up to the total number of shards in the index (`number_of_replicas+1`).
665
670
  """
666
- if operations is None:
667
- raise ValueError("Empty value passed for parameter 'operations'")
671
+ if operations is None and body is None:
672
+ raise ValueError(
673
+ "Empty value passed for parameters 'operations' and 'body', one of them should be set."
674
+ )
675
+ elif operations is not None and body is not None:
676
+ raise ValueError("Cannot set both 'operations' and 'body'")
668
677
  if index not in SKIP_IN_PATH:
669
678
  __path = f"/{_quote(index)}/_bulk"
670
679
  else:
@@ -696,7 +705,7 @@ class AsyncElasticsearch(BaseClient):
696
705
  __query["timeout"] = timeout
697
706
  if wait_for_active_shards is not None:
698
707
  __query["wait_for_active_shards"] = wait_for_active_shards
699
- __body = operations
708
+ __body = operations if operations is not None else body
700
709
  __headers = {
701
710
  "accept": "application/json",
702
711
  "content-type": "application/x-ndjson",
@@ -706,7 +715,7 @@ class AsyncElasticsearch(BaseClient):
706
715
  )
707
716
 
708
717
  @_rewrite_parameters(
709
- body_fields=True,
718
+ body_fields=("scroll_id",),
710
719
  )
711
720
  async def clear_scroll(
712
721
  self,
@@ -716,17 +725,18 @@ class AsyncElasticsearch(BaseClient):
716
725
  human: t.Optional[bool] = None,
717
726
  pretty: t.Optional[bool] = None,
718
727
  scroll_id: t.Optional[t.Union[str, t.Sequence[str]]] = None,
728
+ body: t.Optional[t.Dict[str, t.Any]] = None,
719
729
  ) -> ObjectApiResponse[t.Any]:
720
730
  """
721
731
  Explicitly clears the search context for a scroll.
722
732
 
723
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/clear-scroll-api.html>`_
733
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/clear-scroll-api.html>`_
724
734
 
725
735
  :param scroll_id: Scroll IDs to clear. To clear all scroll IDs, use `_all`.
726
736
  """
727
737
  __path = "/_search/scroll"
728
738
  __query: t.Dict[str, t.Any] = {}
729
- __body: t.Dict[str, t.Any] = {}
739
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
730
740
  if error_trace is not None:
731
741
  __query["error_trace"] = error_trace
732
742
  if filter_path is not None:
@@ -735,8 +745,9 @@ class AsyncElasticsearch(BaseClient):
735
745
  __query["human"] = human
736
746
  if pretty is not None:
737
747
  __query["pretty"] = pretty
738
- if scroll_id is not None:
739
- __body["scroll_id"] = scroll_id
748
+ if not __body:
749
+ if scroll_id is not None:
750
+ __body["scroll_id"] = scroll_id
740
751
  if not __body:
741
752
  __body = None # type: ignore[assignment]
742
753
  __headers = {"accept": "application/json"}
@@ -747,31 +758,30 @@ class AsyncElasticsearch(BaseClient):
747
758
  )
748
759
 
749
760
  @_rewrite_parameters(
750
- body_fields=True,
761
+ body_fields=("id",),
751
762
  )
752
763
  async def close_point_in_time(
753
764
  self,
754
765
  *,
755
- id: str,
766
+ id: t.Optional[str] = None,
756
767
  error_trace: t.Optional[bool] = None,
757
768
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
758
769
  human: t.Optional[bool] = None,
759
770
  pretty: t.Optional[bool] = None,
771
+ body: t.Optional[t.Dict[str, t.Any]] = None,
760
772
  ) -> ObjectApiResponse[t.Any]:
761
773
  """
762
774
  Close a point in time
763
775
 
764
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/point-in-time-api.html>`_
776
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/point-in-time-api.html>`_
765
777
 
766
778
  :param id: The ID of the point-in-time.
767
779
  """
768
- if id is None:
780
+ if id is None and body is None:
769
781
  raise ValueError("Empty value passed for parameter 'id'")
770
782
  __path = "/_pit"
771
- __body: t.Dict[str, t.Any] = {}
772
783
  __query: t.Dict[str, t.Any] = {}
773
- if id is not None:
774
- __body["id"] = id
784
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
775
785
  if error_trace is not None:
776
786
  __query["error_trace"] = error_trace
777
787
  if filter_path is not None:
@@ -780,6 +790,9 @@ class AsyncElasticsearch(BaseClient):
780
790
  __query["human"] = human
781
791
  if pretty is not None:
782
792
  __query["pretty"] = pretty
793
+ if not __body:
794
+ if id is not None:
795
+ __body["id"] = id
783
796
  if not __body:
784
797
  __body = None # type: ignore[assignment]
785
798
  __headers = {"accept": "application/json"}
@@ -790,7 +803,7 @@ class AsyncElasticsearch(BaseClient):
790
803
  )
791
804
 
792
805
  @_rewrite_parameters(
793
- body_fields=True,
806
+ body_fields=("query",),
794
807
  )
795
808
  async def count(
796
809
  self,
@@ -822,11 +835,12 @@ class AsyncElasticsearch(BaseClient):
822
835
  query: t.Optional[t.Mapping[str, t.Any]] = None,
823
836
  routing: t.Optional[str] = None,
824
837
  terminate_after: t.Optional[int] = None,
838
+ body: t.Optional[t.Dict[str, t.Any]] = None,
825
839
  ) -> ObjectApiResponse[t.Any]:
826
840
  """
827
841
  Returns number of documents matching a query.
828
842
 
829
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-count.html>`_
843
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-count.html>`_
830
844
 
831
845
  :param index: Comma-separated list of data streams, indices, and aliases to search.
832
846
  Supports wildcards (`*`). To search all data streams and indices, omit this
@@ -870,7 +884,7 @@ class AsyncElasticsearch(BaseClient):
870
884
  else:
871
885
  __path = "/_count"
872
886
  __query: t.Dict[str, t.Any] = {}
873
- __body: t.Dict[str, t.Any] = {}
887
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
874
888
  if allow_no_indices is not None:
875
889
  __query["allow_no_indices"] = allow_no_indices
876
890
  if analyze_wildcard is not None:
@@ -903,12 +917,13 @@ class AsyncElasticsearch(BaseClient):
903
917
  __query["pretty"] = pretty
904
918
  if q is not None:
905
919
  __query["q"] = q
906
- if query is not None:
907
- __body["query"] = query
908
920
  if routing is not None:
909
921
  __query["routing"] = routing
910
922
  if terminate_after is not None:
911
923
  __query["terminate_after"] = terminate_after
924
+ if not __body:
925
+ if query is not None:
926
+ __body["query"] = query
912
927
  if not __body:
913
928
  __body = None # type: ignore[assignment]
914
929
  __headers = {"accept": "application/json"}
@@ -926,7 +941,8 @@ class AsyncElasticsearch(BaseClient):
926
941
  *,
927
942
  index: str,
928
943
  id: str,
929
- document: t.Mapping[str, t.Any],
944
+ document: t.Optional[t.Mapping[str, t.Any]] = None,
945
+ body: t.Optional[t.Mapping[str, t.Any]] = None,
930
946
  error_trace: t.Optional[bool] = None,
931
947
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
932
948
  human: t.Optional[bool] = None,
@@ -949,7 +965,7 @@ class AsyncElasticsearch(BaseClient):
949
965
  Creates a new document in the index. Returns a 409 response when a document with
950
966
  a same ID already exists in the index.
951
967
 
952
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-index_.html>`_
968
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-index_.html>`_
953
969
 
954
970
  :param index: Name of the data stream or index to target. If the target doesn’t
955
971
  exist and matches the name or wildcard (`*`) pattern of an index template
@@ -982,8 +998,12 @@ class AsyncElasticsearch(BaseClient):
982
998
  raise ValueError("Empty value passed for parameter 'index'")
983
999
  if id in SKIP_IN_PATH:
984
1000
  raise ValueError("Empty value passed for parameter 'id'")
985
- if document is None:
986
- raise ValueError("Empty value passed for parameter 'document'")
1001
+ if document is None and body is None:
1002
+ raise ValueError(
1003
+ "Empty value passed for parameters 'document' and 'body', one of them should be set."
1004
+ )
1005
+ elif document is not None and body is not None:
1006
+ raise ValueError("Cannot set both 'document' and 'body'")
987
1007
  __path = f"/{_quote(index)}/_create/{_quote(id)}"
988
1008
  __query: t.Dict[str, t.Any] = {}
989
1009
  if error_trace is not None:
@@ -1008,7 +1028,7 @@ class AsyncElasticsearch(BaseClient):
1008
1028
  __query["version_type"] = version_type
1009
1029
  if wait_for_active_shards is not None:
1010
1030
  __query["wait_for_active_shards"] = wait_for_active_shards
1011
- __body = document
1031
+ __body = document if document is not None else body
1012
1032
  __headers = {"accept": "application/json", "content-type": "application/json"}
1013
1033
  return await self.perform_request( # type: ignore[return-value]
1014
1034
  "PUT", __path, params=__query, headers=__headers, body=__body
@@ -1042,7 +1062,7 @@ class AsyncElasticsearch(BaseClient):
1042
1062
  """
1043
1063
  Removes a document from the index.
1044
1064
 
1045
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-delete.html>`_
1065
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-delete.html>`_
1046
1066
 
1047
1067
  :param index: Name of the target index.
1048
1068
  :param id: Unique identifier for the document.
@@ -1100,7 +1120,7 @@ class AsyncElasticsearch(BaseClient):
1100
1120
  )
1101
1121
 
1102
1122
  @_rewrite_parameters(
1103
- body_fields=True,
1123
+ body_fields=("max_docs", "query", "slice"),
1104
1124
  parameter_aliases={"from": "from_"},
1105
1125
  )
1106
1126
  async def delete_by_query(
@@ -1155,11 +1175,12 @@ class AsyncElasticsearch(BaseClient):
1155
1175
  t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
1156
1176
  ] = None,
1157
1177
  wait_for_completion: t.Optional[bool] = None,
1178
+ body: t.Optional[t.Dict[str, t.Any]] = None,
1158
1179
  ) -> ObjectApiResponse[t.Any]:
1159
1180
  """
1160
1181
  Deletes documents matching the provided query.
1161
1182
 
1162
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-delete-by-query.html>`_
1183
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-delete-by-query.html>`_
1163
1184
 
1164
1185
  :param index: Comma-separated list of data streams, indices, and aliases to search.
1165
1186
  Supports wildcards (`*`). To search all data streams or indices, omit this
@@ -1228,7 +1249,7 @@ class AsyncElasticsearch(BaseClient):
1228
1249
  raise ValueError("Empty value passed for parameter 'index'")
1229
1250
  __path = f"/{_quote(index)}/_delete_by_query"
1230
1251
  __query: t.Dict[str, t.Any] = {}
1231
- __body: t.Dict[str, t.Any] = {}
1252
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
1232
1253
  # The 'sort' parameter with a colon can't be encoded to the body.
1233
1254
  if sort is not None and (
1234
1255
  (isinstance(sort, str) and ":" in sort)
@@ -1266,16 +1287,12 @@ class AsyncElasticsearch(BaseClient):
1266
1287
  __query["ignore_unavailable"] = ignore_unavailable
1267
1288
  if lenient is not None:
1268
1289
  __query["lenient"] = lenient
1269
- if max_docs is not None:
1270
- __body["max_docs"] = max_docs
1271
1290
  if preference is not None:
1272
1291
  __query["preference"] = preference
1273
1292
  if pretty is not None:
1274
1293
  __query["pretty"] = pretty
1275
1294
  if q is not None:
1276
1295
  __query["q"] = q
1277
- if query is not None:
1278
- __body["query"] = query
1279
1296
  if refresh is not None:
1280
1297
  __query["refresh"] = refresh
1281
1298
  if request_cache is not None:
@@ -1292,8 +1309,6 @@ class AsyncElasticsearch(BaseClient):
1292
1309
  __query["search_timeout"] = search_timeout
1293
1310
  if search_type is not None:
1294
1311
  __query["search_type"] = search_type
1295
- if slice is not None:
1296
- __body["slice"] = slice
1297
1312
  if slices is not None:
1298
1313
  __query["slices"] = slices
1299
1314
  if sort is not None:
@@ -1310,6 +1325,13 @@ class AsyncElasticsearch(BaseClient):
1310
1325
  __query["wait_for_active_shards"] = wait_for_active_shards
1311
1326
  if wait_for_completion is not None:
1312
1327
  __query["wait_for_completion"] = wait_for_completion
1328
+ if not __body:
1329
+ if max_docs is not None:
1330
+ __body["max_docs"] = max_docs
1331
+ if query is not None:
1332
+ __body["query"] = query
1333
+ if slice is not None:
1334
+ __body["slice"] = slice
1313
1335
  __headers = {"accept": "application/json", "content-type": "application/json"}
1314
1336
  return await self.perform_request( # type: ignore[return-value]
1315
1337
  "POST", __path, params=__query, headers=__headers, body=__body
@@ -1329,7 +1351,7 @@ class AsyncElasticsearch(BaseClient):
1329
1351
  """
1330
1352
  Changes the number of requests per second for a particular Delete By Query operation.
1331
1353
 
1332
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-delete-by-query.html>`_
1354
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-delete-by-query.html>`_
1333
1355
 
1334
1356
  :param task_id: The ID for the task.
1335
1357
  :param requests_per_second: The throttle for this request in sub-requests per
@@ -1371,7 +1393,7 @@ class AsyncElasticsearch(BaseClient):
1371
1393
  """
1372
1394
  Deletes a script.
1373
1395
 
1374
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/modules-scripting.html>`_
1396
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
1375
1397
 
1376
1398
  :param id: Identifier for the stored script or search template.
1377
1399
  :param master_timeout: Period to wait for a connection to the master node. If
@@ -1433,7 +1455,7 @@ class AsyncElasticsearch(BaseClient):
1433
1455
  """
1434
1456
  Returns information about whether a document exists in an index.
1435
1457
 
1436
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-get.html>`_
1458
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
1437
1459
 
1438
1460
  :param index: Comma-separated list of data streams, indices, and aliases. Supports
1439
1461
  wildcards (`*`).
@@ -1528,7 +1550,7 @@ class AsyncElasticsearch(BaseClient):
1528
1550
  """
1529
1551
  Returns information about whether a document source exists in an index.
1530
1552
 
1531
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-get.html>`_
1553
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
1532
1554
 
1533
1555
  :param index: Comma-separated list of data streams, indices, and aliases. Supports
1534
1556
  wildcards (`*`).
@@ -1588,7 +1610,7 @@ class AsyncElasticsearch(BaseClient):
1588
1610
  )
1589
1611
 
1590
1612
  @_rewrite_parameters(
1591
- body_fields=True,
1613
+ body_fields=("query",),
1592
1614
  parameter_aliases={
1593
1615
  "_source": "source",
1594
1616
  "_source_excludes": "source_excludes",
@@ -1617,11 +1639,12 @@ class AsyncElasticsearch(BaseClient):
1617
1639
  source_excludes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1618
1640
  source_includes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1619
1641
  stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1642
+ body: t.Optional[t.Dict[str, t.Any]] = None,
1620
1643
  ) -> ObjectApiResponse[t.Any]:
1621
1644
  """
1622
1645
  Returns information about why a specific matches (or doesn't match) a query.
1623
1646
 
1624
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-explain.html>`_
1647
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-explain.html>`_
1625
1648
 
1626
1649
  :param index: Index names used to limit the request. Only a single index name
1627
1650
  can be provided to this parameter.
@@ -1655,7 +1678,7 @@ class AsyncElasticsearch(BaseClient):
1655
1678
  raise ValueError("Empty value passed for parameter 'id'")
1656
1679
  __path = f"/{_quote(index)}/_explain/{_quote(id)}"
1657
1680
  __query: t.Dict[str, t.Any] = {}
1658
- __body: t.Dict[str, t.Any] = {}
1681
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
1659
1682
  if analyze_wildcard is not None:
1660
1683
  __query["analyze_wildcard"] = analyze_wildcard
1661
1684
  if analyzer is not None:
@@ -1678,8 +1701,6 @@ class AsyncElasticsearch(BaseClient):
1678
1701
  __query["pretty"] = pretty
1679
1702
  if q is not None:
1680
1703
  __query["q"] = q
1681
- if query is not None:
1682
- __body["query"] = query
1683
1704
  if routing is not None:
1684
1705
  __query["routing"] = routing
1685
1706
  if source is not None:
@@ -1690,6 +1711,9 @@ class AsyncElasticsearch(BaseClient):
1690
1711
  __query["_source_includes"] = source_includes
1691
1712
  if stored_fields is not None:
1692
1713
  __query["stored_fields"] = stored_fields
1714
+ if not __body:
1715
+ if query is not None:
1716
+ __body["query"] = query
1693
1717
  if not __body:
1694
1718
  __body = None # type: ignore[assignment]
1695
1719
  __headers = {"accept": "application/json"}
@@ -1700,7 +1724,7 @@ class AsyncElasticsearch(BaseClient):
1700
1724
  )
1701
1725
 
1702
1726
  @_rewrite_parameters(
1703
- body_fields=True,
1727
+ body_fields=("fields", "index_filter", "runtime_mappings"),
1704
1728
  )
1705
1729
  async def field_caps(
1706
1730
  self,
@@ -1726,11 +1750,12 @@ class AsyncElasticsearch(BaseClient):
1726
1750
  pretty: t.Optional[bool] = None,
1727
1751
  runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
1728
1752
  types: t.Optional[t.Sequence[str]] = None,
1753
+ body: t.Optional[t.Dict[str, t.Any]] = None,
1729
1754
  ) -> ObjectApiResponse[t.Any]:
1730
1755
  """
1731
1756
  Returns the information about the capabilities of fields among multiple indices.
1732
1757
 
1733
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-field-caps.html>`_
1758
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-field-caps.html>`_
1734
1759
 
1735
1760
  :param index: Comma-separated list of data streams, indices, and aliases used
1736
1761
  to limit the request. Supports wildcards (*). To target all data streams
@@ -1764,15 +1789,13 @@ class AsyncElasticsearch(BaseClient):
1764
1789
  else:
1765
1790
  __path = "/_field_caps"
1766
1791
  __query: t.Dict[str, t.Any] = {}
1767
- __body: t.Dict[str, t.Any] = {}
1792
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
1768
1793
  if allow_no_indices is not None:
1769
1794
  __query["allow_no_indices"] = allow_no_indices
1770
1795
  if error_trace is not None:
1771
1796
  __query["error_trace"] = error_trace
1772
1797
  if expand_wildcards is not None:
1773
1798
  __query["expand_wildcards"] = expand_wildcards
1774
- if fields is not None:
1775
- __body["fields"] = fields
1776
1799
  if filter_path is not None:
1777
1800
  __query["filter_path"] = filter_path
1778
1801
  if filters is not None:
@@ -1783,14 +1806,17 @@ class AsyncElasticsearch(BaseClient):
1783
1806
  __query["ignore_unavailable"] = ignore_unavailable
1784
1807
  if include_unmapped is not None:
1785
1808
  __query["include_unmapped"] = include_unmapped
1786
- if index_filter is not None:
1787
- __body["index_filter"] = index_filter
1788
1809
  if pretty is not None:
1789
1810
  __query["pretty"] = pretty
1790
- if runtime_mappings is not None:
1791
- __body["runtime_mappings"] = runtime_mappings
1792
1811
  if types is not None:
1793
1812
  __query["types"] = types
1813
+ if not __body:
1814
+ if fields is not None:
1815
+ __body["fields"] = fields
1816
+ if index_filter is not None:
1817
+ __body["index_filter"] = index_filter
1818
+ if runtime_mappings is not None:
1819
+ __body["runtime_mappings"] = runtime_mappings
1794
1820
  if not __body:
1795
1821
  __body = None # type: ignore[assignment]
1796
1822
  __headers = {"accept": "application/json"}
@@ -1832,7 +1858,7 @@ class AsyncElasticsearch(BaseClient):
1832
1858
  """
1833
1859
  Returns a document.
1834
1860
 
1835
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-get.html>`_
1861
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
1836
1862
 
1837
1863
  :param index: Name of the index that contains the document.
1838
1864
  :param id: Unique identifier of the document.
@@ -1911,7 +1937,7 @@ class AsyncElasticsearch(BaseClient):
1911
1937
  """
1912
1938
  Returns a script.
1913
1939
 
1914
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/modules-scripting.html>`_
1940
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
1915
1941
 
1916
1942
  :param id: Identifier for the stored script or search template.
1917
1943
  :param master_timeout: Specify timeout for connection to master
@@ -1947,7 +1973,7 @@ class AsyncElasticsearch(BaseClient):
1947
1973
  """
1948
1974
  Returns all script contexts.
1949
1975
 
1950
- `<https://www.elastic.co/guide/en/elasticsearch/painless/8.11/painless-contexts.html>`_
1976
+ `<https://www.elastic.co/guide/en/elasticsearch/painless/8.12/painless-contexts.html>`_
1951
1977
  """
1952
1978
  __path = "/_script_context"
1953
1979
  __query: t.Dict[str, t.Any] = {}
@@ -1976,7 +2002,7 @@ class AsyncElasticsearch(BaseClient):
1976
2002
  """
1977
2003
  Returns available script types, languages and contexts
1978
2004
 
1979
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/modules-scripting.html>`_
2005
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
1980
2006
  """
1981
2007
  __path = "/_script_language"
1982
2008
  __query: t.Dict[str, t.Any] = {}
@@ -2025,7 +2051,7 @@ class AsyncElasticsearch(BaseClient):
2025
2051
  """
2026
2052
  Returns the source of a document.
2027
2053
 
2028
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-get.html>`_
2054
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
2029
2055
 
2030
2056
  :param index: Name of the index that contains the document.
2031
2057
  :param id: Unique identifier of the document.
@@ -2102,7 +2128,7 @@ class AsyncElasticsearch(BaseClient):
2102
2128
  """
2103
2129
  Returns the health of the cluster.
2104
2130
 
2105
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/health-api.html>`_
2131
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/health-api.html>`_
2106
2132
 
2107
2133
  :param feature: A feature of the cluster, as returned by the top-level health
2108
2134
  report API.
@@ -2141,7 +2167,8 @@ class AsyncElasticsearch(BaseClient):
2141
2167
  self,
2142
2168
  *,
2143
2169
  index: str,
2144
- document: t.Mapping[str, t.Any],
2170
+ document: t.Optional[t.Mapping[str, t.Any]] = None,
2171
+ body: t.Optional[t.Mapping[str, t.Any]] = None,
2145
2172
  id: t.Optional[str] = None,
2146
2173
  error_trace: t.Optional[bool] = None,
2147
2174
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -2168,7 +2195,7 @@ class AsyncElasticsearch(BaseClient):
2168
2195
  """
2169
2196
  Creates or updates a document in an index.
2170
2197
 
2171
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-index_.html>`_
2198
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-index_.html>`_
2172
2199
 
2173
2200
  :param index: Name of the data stream or index to target.
2174
2201
  :param document:
@@ -2205,8 +2232,12 @@ class AsyncElasticsearch(BaseClient):
2205
2232
  """
2206
2233
  if index in SKIP_IN_PATH:
2207
2234
  raise ValueError("Empty value passed for parameter 'index'")
2208
- if document is None:
2209
- raise ValueError("Empty value passed for parameter 'document'")
2235
+ if document is None and body is None:
2236
+ raise ValueError(
2237
+ "Empty value passed for parameters 'document' and 'body', one of them should be set."
2238
+ )
2239
+ elif document is not None and body is not None:
2240
+ raise ValueError("Cannot set both 'document' and 'body'")
2210
2241
  if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH:
2211
2242
  __path = f"/{_quote(index)}/_doc/{_quote(id)}"
2212
2243
  __method = "PUT"
@@ -2246,7 +2277,7 @@ class AsyncElasticsearch(BaseClient):
2246
2277
  __query["version_type"] = version_type
2247
2278
  if wait_for_active_shards is not None:
2248
2279
  __query["wait_for_active_shards"] = wait_for_active_shards
2249
- __body = document
2280
+ __body = document if document is not None else body
2250
2281
  __headers = {"accept": "application/json", "content-type": "application/json"}
2251
2282
  return await self.perform_request( # type: ignore[return-value]
2252
2283
  __method, __path, params=__query, headers=__headers, body=__body
@@ -2264,7 +2295,7 @@ class AsyncElasticsearch(BaseClient):
2264
2295
  """
2265
2296
  Returns basic information about the cluster.
2266
2297
 
2267
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/index.html>`_
2298
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/index.html>`_
2268
2299
  """
2269
2300
  __path = "/"
2270
2301
  __query: t.Dict[str, t.Any] = {}
@@ -2282,14 +2313,21 @@ class AsyncElasticsearch(BaseClient):
2282
2313
  )
2283
2314
 
2284
2315
  @_rewrite_parameters(
2285
- body_fields=True,
2316
+ body_fields=(
2317
+ "knn",
2318
+ "docvalue_fields",
2319
+ "fields",
2320
+ "filter",
2321
+ "source",
2322
+ "stored_fields",
2323
+ ),
2286
2324
  parameter_aliases={"_source": "source"},
2287
2325
  )
2288
2326
  async def knn_search(
2289
2327
  self,
2290
2328
  *,
2291
2329
  index: t.Union[str, t.Sequence[str]],
2292
- knn: t.Mapping[str, t.Any],
2330
+ knn: t.Optional[t.Mapping[str, t.Any]] = None,
2293
2331
  docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2294
2332
  error_trace: t.Optional[bool] = None,
2295
2333
  fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -2302,11 +2340,12 @@ class AsyncElasticsearch(BaseClient):
2302
2340
  routing: t.Optional[str] = None,
2303
2341
  source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None,
2304
2342
  stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2343
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2305
2344
  ) -> ObjectApiResponse[t.Any]:
2306
2345
  """
2307
2346
  Performs a kNN search.
2308
2347
 
2309
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-search.html>`_
2348
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-search.html>`_
2310
2349
 
2311
2350
  :param index: A comma-separated list of index names to search; use `_all` or
2312
2351
  to perform the operation on all indices
@@ -2331,21 +2370,13 @@ class AsyncElasticsearch(BaseClient):
2331
2370
  """
2332
2371
  if index in SKIP_IN_PATH:
2333
2372
  raise ValueError("Empty value passed for parameter 'index'")
2334
- if knn is None:
2373
+ if knn is None and body is None:
2335
2374
  raise ValueError("Empty value passed for parameter 'knn'")
2336
2375
  __path = f"/{_quote(index)}/_knn_search"
2337
- __body: t.Dict[str, t.Any] = {}
2338
2376
  __query: t.Dict[str, t.Any] = {}
2339
- if knn is not None:
2340
- __body["knn"] = knn
2341
- if docvalue_fields is not None:
2342
- __body["docvalue_fields"] = docvalue_fields
2377
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2343
2378
  if error_trace is not None:
2344
2379
  __query["error_trace"] = error_trace
2345
- if fields is not None:
2346
- __body["fields"] = fields
2347
- if filter is not None:
2348
- __body["filter"] = filter
2349
2380
  if filter_path is not None:
2350
2381
  __query["filter_path"] = filter_path
2351
2382
  if human is not None:
@@ -2354,10 +2385,19 @@ class AsyncElasticsearch(BaseClient):
2354
2385
  __query["pretty"] = pretty
2355
2386
  if routing is not None:
2356
2387
  __query["routing"] = routing
2357
- if source is not None:
2358
- __body["_source"] = source
2359
- if stored_fields is not None:
2360
- __body["stored_fields"] = stored_fields
2388
+ if not __body:
2389
+ if knn is not None:
2390
+ __body["knn"] = knn
2391
+ if docvalue_fields is not None:
2392
+ __body["docvalue_fields"] = docvalue_fields
2393
+ if fields is not None:
2394
+ __body["fields"] = fields
2395
+ if filter is not None:
2396
+ __body["filter"] = filter
2397
+ if source is not None:
2398
+ __body["_source"] = source
2399
+ if stored_fields is not None:
2400
+ __body["stored_fields"] = stored_fields
2361
2401
  if not __body:
2362
2402
  __body = None # type: ignore[assignment]
2363
2403
  __headers = {"accept": "application/json"}
@@ -2368,7 +2408,7 @@ class AsyncElasticsearch(BaseClient):
2368
2408
  )
2369
2409
 
2370
2410
  @_rewrite_parameters(
2371
- body_fields=True,
2411
+ body_fields=("docs", "ids"),
2372
2412
  parameter_aliases={
2373
2413
  "_source": "source",
2374
2414
  "_source_excludes": "source_excludes",
@@ -2393,11 +2433,12 @@ class AsyncElasticsearch(BaseClient):
2393
2433
  source_excludes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2394
2434
  source_includes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2395
2435
  stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2436
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2396
2437
  ) -> ObjectApiResponse[t.Any]:
2397
2438
  """
2398
2439
  Allows to get multiple documents in one request.
2399
2440
 
2400
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-multi-get.html>`_
2441
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-multi-get.html>`_
2401
2442
 
2402
2443
  :param index: Name of the index to retrieve documents from when `ids` are specified,
2403
2444
  or when a document in the `docs` array does not specify an index.
@@ -2428,18 +2469,14 @@ class AsyncElasticsearch(BaseClient):
2428
2469
  __path = f"/{_quote(index)}/_mget"
2429
2470
  else:
2430
2471
  __path = "/_mget"
2431
- __body: t.Dict[str, t.Any] = {}
2432
2472
  __query: t.Dict[str, t.Any] = {}
2433
- if docs is not None:
2434
- __body["docs"] = docs
2473
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2435
2474
  if error_trace is not None:
2436
2475
  __query["error_trace"] = error_trace
2437
2476
  if filter_path is not None:
2438
2477
  __query["filter_path"] = filter_path
2439
2478
  if human is not None:
2440
2479
  __query["human"] = human
2441
- if ids is not None:
2442
- __body["ids"] = ids
2443
2480
  if preference is not None:
2444
2481
  __query["preference"] = preference
2445
2482
  if pretty is not None:
@@ -2458,6 +2495,11 @@ class AsyncElasticsearch(BaseClient):
2458
2495
  __query["_source_includes"] = source_includes
2459
2496
  if stored_fields is not None:
2460
2497
  __query["stored_fields"] = stored_fields
2498
+ if not __body:
2499
+ if docs is not None:
2500
+ __body["docs"] = docs
2501
+ if ids is not None:
2502
+ __body["ids"] = ids
2461
2503
  __headers = {"accept": "application/json", "content-type": "application/json"}
2462
2504
  return await self.perform_request( # type: ignore[return-value]
2463
2505
  "POST", __path, params=__query, headers=__headers, body=__body
@@ -2469,7 +2511,8 @@ class AsyncElasticsearch(BaseClient):
2469
2511
  async def msearch(
2470
2512
  self,
2471
2513
  *,
2472
- searches: t.Sequence[t.Mapping[str, t.Any]],
2514
+ searches: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2515
+ body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2473
2516
  index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2474
2517
  allow_no_indices: t.Optional[bool] = None,
2475
2518
  ccs_minimize_roundtrips: t.Optional[bool] = None,
@@ -2500,7 +2543,7 @@ class AsyncElasticsearch(BaseClient):
2500
2543
  """
2501
2544
  Allows to execute several search operations in one request.
2502
2545
 
2503
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-multi-search.html>`_
2546
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-multi-search.html>`_
2504
2547
 
2505
2548
  :param searches:
2506
2549
  :param index: Comma-separated list of data streams, indices, and index aliases
@@ -2538,8 +2581,12 @@ class AsyncElasticsearch(BaseClient):
2538
2581
  :param typed_keys: Specifies whether aggregation and suggester names should be
2539
2582
  prefixed by their respective types in the response.
2540
2583
  """
2541
- if searches is None:
2542
- raise ValueError("Empty value passed for parameter 'searches'")
2584
+ if searches is None and body is None:
2585
+ raise ValueError(
2586
+ "Empty value passed for parameters 'searches' and 'body', one of them should be set."
2587
+ )
2588
+ elif searches is not None and body is not None:
2589
+ raise ValueError("Cannot set both 'searches' and 'body'")
2543
2590
  if index not in SKIP_IN_PATH:
2544
2591
  __path = f"/{_quote(index)}/_msearch"
2545
2592
  else:
@@ -2577,7 +2624,7 @@ class AsyncElasticsearch(BaseClient):
2577
2624
  __query["search_type"] = search_type
2578
2625
  if typed_keys is not None:
2579
2626
  __query["typed_keys"] = typed_keys
2580
- __body = searches
2627
+ __body = searches if searches is not None else body
2581
2628
  __headers = {
2582
2629
  "accept": "application/json",
2583
2630
  "content-type": "application/x-ndjson",
@@ -2592,7 +2639,8 @@ class AsyncElasticsearch(BaseClient):
2592
2639
  async def msearch_template(
2593
2640
  self,
2594
2641
  *,
2595
- search_templates: t.Sequence[t.Mapping[str, t.Any]],
2642
+ search_templates: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2643
+ body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2596
2644
  index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2597
2645
  ccs_minimize_roundtrips: t.Optional[bool] = None,
2598
2646
  error_trace: t.Optional[bool] = None,
@@ -2609,7 +2657,7 @@ class AsyncElasticsearch(BaseClient):
2609
2657
  """
2610
2658
  Allows to execute several search template operations in one request.
2611
2659
 
2612
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-multi-search.html>`_
2660
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-multi-search.html>`_
2613
2661
 
2614
2662
  :param search_templates:
2615
2663
  :param index: Comma-separated list of data streams, indices, and aliases to search.
@@ -2626,8 +2674,12 @@ class AsyncElasticsearch(BaseClient):
2626
2674
  :param typed_keys: If `true`, the response prefixes aggregation and suggester
2627
2675
  names with their respective types.
2628
2676
  """
2629
- if search_templates is None:
2630
- raise ValueError("Empty value passed for parameter 'search_templates'")
2677
+ if search_templates is None and body is None:
2678
+ raise ValueError(
2679
+ "Empty value passed for parameters 'search_templates' and 'body', one of them should be set."
2680
+ )
2681
+ elif search_templates is not None and body is not None:
2682
+ raise ValueError("Cannot set both 'search_templates' and 'body'")
2631
2683
  if index not in SKIP_IN_PATH:
2632
2684
  __path = f"/{_quote(index)}/_msearch/template"
2633
2685
  else:
@@ -2651,7 +2703,7 @@ class AsyncElasticsearch(BaseClient):
2651
2703
  __query["search_type"] = search_type
2652
2704
  if typed_keys is not None:
2653
2705
  __query["typed_keys"] = typed_keys
2654
- __body = search_templates
2706
+ __body = search_templates if search_templates is not None else body
2655
2707
  __headers = {
2656
2708
  "accept": "application/json",
2657
2709
  "content-type": "application/x-ndjson",
@@ -2661,7 +2713,7 @@ class AsyncElasticsearch(BaseClient):
2661
2713
  )
2662
2714
 
2663
2715
  @_rewrite_parameters(
2664
- body_fields=True,
2716
+ body_fields=("docs", "ids"),
2665
2717
  )
2666
2718
  async def mtermvectors(
2667
2719
  self,
@@ -2686,11 +2738,12 @@ class AsyncElasticsearch(BaseClient):
2686
2738
  version_type: t.Optional[
2687
2739
  t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str]
2688
2740
  ] = None,
2741
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2689
2742
  ) -> ObjectApiResponse[t.Any]:
2690
2743
  """
2691
2744
  Returns multiple termvectors in one request.
2692
2745
 
2693
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-multi-termvectors.html>`_
2746
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-multi-termvectors.html>`_
2694
2747
 
2695
2748
  :param index: Name of the index that contains the documents.
2696
2749
  :param docs: Array of existing or artificial documents.
@@ -2717,10 +2770,8 @@ class AsyncElasticsearch(BaseClient):
2717
2770
  __path = f"/{_quote(index)}/_mtermvectors"
2718
2771
  else:
2719
2772
  __path = "/_mtermvectors"
2720
- __body: t.Dict[str, t.Any] = {}
2721
2773
  __query: t.Dict[str, t.Any] = {}
2722
- if docs is not None:
2723
- __body["docs"] = docs
2774
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2724
2775
  if error_trace is not None:
2725
2776
  __query["error_trace"] = error_trace
2726
2777
  if field_statistics is not None:
@@ -2731,8 +2782,6 @@ class AsyncElasticsearch(BaseClient):
2731
2782
  __query["filter_path"] = filter_path
2732
2783
  if human is not None:
2733
2784
  __query["human"] = human
2734
- if ids is not None:
2735
- __body["ids"] = ids
2736
2785
  if offsets is not None:
2737
2786
  __query["offsets"] = offsets
2738
2787
  if payloads is not None:
@@ -2753,6 +2802,11 @@ class AsyncElasticsearch(BaseClient):
2753
2802
  __query["version"] = version
2754
2803
  if version_type is not None:
2755
2804
  __query["version_type"] = version_type
2805
+ if not __body:
2806
+ if docs is not None:
2807
+ __body["docs"] = docs
2808
+ if ids is not None:
2809
+ __body["ids"] = ids
2756
2810
  if not __body:
2757
2811
  __body = None # type: ignore[assignment]
2758
2812
  __headers = {"accept": "application/json"}
@@ -2787,7 +2841,7 @@ class AsyncElasticsearch(BaseClient):
2787
2841
  """
2788
2842
  Open a point in time that can be used in subsequent searches
2789
2843
 
2790
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/point-in-time-api.html>`_
2844
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/point-in-time-api.html>`_
2791
2845
 
2792
2846
  :param index: A comma-separated list of index names to open point in time; use
2793
2847
  `_all` or empty string to perform the operation on all indices
@@ -2832,13 +2886,13 @@ class AsyncElasticsearch(BaseClient):
2832
2886
  )
2833
2887
 
2834
2888
  @_rewrite_parameters(
2835
- body_fields=True,
2889
+ body_fields=("script",),
2836
2890
  )
2837
2891
  async def put_script(
2838
2892
  self,
2839
2893
  *,
2840
2894
  id: str,
2841
- script: t.Mapping[str, t.Any],
2895
+ script: t.Optional[t.Mapping[str, t.Any]] = None,
2842
2896
  context: t.Optional[str] = None,
2843
2897
  error_trace: t.Optional[bool] = None,
2844
2898
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -2848,11 +2902,12 @@ class AsyncElasticsearch(BaseClient):
2848
2902
  ] = None,
2849
2903
  pretty: t.Optional[bool] = None,
2850
2904
  timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
2905
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2851
2906
  ) -> ObjectApiResponse[t.Any]:
2852
2907
  """
2853
2908
  Creates or updates a script.
2854
2909
 
2855
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/modules-scripting.html>`_
2910
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
2856
2911
 
2857
2912
  :param id: Identifier for the stored script or search template. Must be unique
2858
2913
  within the cluster.
@@ -2869,7 +2924,7 @@ class AsyncElasticsearch(BaseClient):
2869
2924
  """
2870
2925
  if id in SKIP_IN_PATH:
2871
2926
  raise ValueError("Empty value passed for parameter 'id'")
2872
- if script is None:
2927
+ if script is None and body is None:
2873
2928
  raise ValueError("Empty value passed for parameter 'script'")
2874
2929
  if id not in SKIP_IN_PATH and context not in SKIP_IN_PATH:
2875
2930
  __path = f"/_scripts/{_quote(id)}/{_quote(context)}"
@@ -2877,10 +2932,8 @@ class AsyncElasticsearch(BaseClient):
2877
2932
  __path = f"/_scripts/{_quote(id)}"
2878
2933
  else:
2879
2934
  raise ValueError("Couldn't find a path for the given parameters")
2880
- __body: t.Dict[str, t.Any] = {}
2881
2935
  __query: t.Dict[str, t.Any] = {}
2882
- if script is not None:
2883
- __body["script"] = script
2936
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2884
2937
  if error_trace is not None:
2885
2938
  __query["error_trace"] = error_trace
2886
2939
  if filter_path is not None:
@@ -2893,18 +2946,21 @@ class AsyncElasticsearch(BaseClient):
2893
2946
  __query["pretty"] = pretty
2894
2947
  if timeout is not None:
2895
2948
  __query["timeout"] = timeout
2949
+ if not __body:
2950
+ if script is not None:
2951
+ __body["script"] = script
2896
2952
  __headers = {"accept": "application/json", "content-type": "application/json"}
2897
2953
  return await self.perform_request( # type: ignore[return-value]
2898
2954
  "PUT", __path, params=__query, headers=__headers, body=__body
2899
2955
  )
2900
2956
 
2901
2957
  @_rewrite_parameters(
2902
- body_fields=True,
2958
+ body_fields=("requests", "metric"),
2903
2959
  )
2904
2960
  async def rank_eval(
2905
2961
  self,
2906
2962
  *,
2907
- requests: t.Sequence[t.Mapping[str, t.Any]],
2963
+ requests: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2908
2964
  index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2909
2965
  allow_no_indices: t.Optional[bool] = None,
2910
2966
  error_trace: t.Optional[bool] = None,
@@ -2922,12 +2978,13 @@ class AsyncElasticsearch(BaseClient):
2922
2978
  metric: t.Optional[t.Mapping[str, t.Any]] = None,
2923
2979
  pretty: t.Optional[bool] = None,
2924
2980
  search_type: t.Optional[str] = None,
2981
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2925
2982
  ) -> ObjectApiResponse[t.Any]:
2926
2983
  """
2927
2984
  Allows to evaluate the quality of ranked search results over a set of typical
2928
2985
  search queries
2929
2986
 
2930
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-rank-eval.html>`_
2987
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-rank-eval.html>`_
2931
2988
 
2932
2989
  :param requests: A set of typical search requests, together with their provided
2933
2990
  ratings.
@@ -2947,16 +3004,14 @@ class AsyncElasticsearch(BaseClient):
2947
3004
  :param metric: Definition of the evaluation metric to calculate.
2948
3005
  :param search_type: Search operation type
2949
3006
  """
2950
- if requests is None:
3007
+ if requests is None and body is None:
2951
3008
  raise ValueError("Empty value passed for parameter 'requests'")
2952
3009
  if index not in SKIP_IN_PATH:
2953
3010
  __path = f"/{_quote(index)}/_rank_eval"
2954
3011
  else:
2955
3012
  __path = "/_rank_eval"
2956
- __body: t.Dict[str, t.Any] = {}
2957
3013
  __query: t.Dict[str, t.Any] = {}
2958
- if requests is not None:
2959
- __body["requests"] = requests
3014
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2960
3015
  if allow_no_indices is not None:
2961
3016
  __query["allow_no_indices"] = allow_no_indices
2962
3017
  if error_trace is not None:
@@ -2969,25 +3024,28 @@ class AsyncElasticsearch(BaseClient):
2969
3024
  __query["human"] = human
2970
3025
  if ignore_unavailable is not None:
2971
3026
  __query["ignore_unavailable"] = ignore_unavailable
2972
- if metric is not None:
2973
- __body["metric"] = metric
2974
3027
  if pretty is not None:
2975
3028
  __query["pretty"] = pretty
2976
3029
  if search_type is not None:
2977
3030
  __query["search_type"] = search_type
3031
+ if not __body:
3032
+ if requests is not None:
3033
+ __body["requests"] = requests
3034
+ if metric is not None:
3035
+ __body["metric"] = metric
2978
3036
  __headers = {"accept": "application/json", "content-type": "application/json"}
2979
3037
  return await self.perform_request( # type: ignore[return-value]
2980
3038
  "POST", __path, params=__query, headers=__headers, body=__body
2981
3039
  )
2982
3040
 
2983
3041
  @_rewrite_parameters(
2984
- body_fields=True,
3042
+ body_fields=("dest", "source", "conflicts", "max_docs", "script", "size"),
2985
3043
  )
2986
3044
  async def reindex(
2987
3045
  self,
2988
3046
  *,
2989
- dest: t.Mapping[str, t.Any],
2990
- source: t.Mapping[str, t.Any],
3047
+ dest: t.Optional[t.Mapping[str, t.Any]] = None,
3048
+ source: t.Optional[t.Mapping[str, t.Any]] = None,
2991
3049
  conflicts: t.Optional[t.Union["t.Literal['abort', 'proceed']", str]] = None,
2992
3050
  error_trace: t.Optional[bool] = None,
2993
3051
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -3006,13 +3064,14 @@ class AsyncElasticsearch(BaseClient):
3006
3064
  t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
3007
3065
  ] = None,
3008
3066
  wait_for_completion: t.Optional[bool] = None,
3067
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3009
3068
  ) -> ObjectApiResponse[t.Any]:
3010
3069
  """
3011
3070
  Allows to copy documents from one index to another, optionally filtering the
3012
3071
  source documents by a query, changing the destination index settings, or fetching
3013
3072
  the documents from a remote cluster.
3014
3073
 
3015
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-reindex.html>`_
3074
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-reindex.html>`_
3016
3075
 
3017
3076
  :param dest: The destination you are copying to.
3018
3077
  :param source: The source you are copying from.
@@ -3038,27 +3097,19 @@ class AsyncElasticsearch(BaseClient):
3038
3097
  :param wait_for_completion: If `true`, the request blocks until the operation
3039
3098
  is complete.
3040
3099
  """
3041
- if dest is None:
3100
+ if dest is None and body is None:
3042
3101
  raise ValueError("Empty value passed for parameter 'dest'")
3043
- if source is None:
3102
+ if source is None and body is None:
3044
3103
  raise ValueError("Empty value passed for parameter 'source'")
3045
3104
  __path = "/_reindex"
3046
- __body: t.Dict[str, t.Any] = {}
3047
3105
  __query: t.Dict[str, t.Any] = {}
3048
- if dest is not None:
3049
- __body["dest"] = dest
3050
- if source is not None:
3051
- __body["source"] = source
3052
- if conflicts is not None:
3053
- __body["conflicts"] = conflicts
3106
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3054
3107
  if error_trace is not None:
3055
3108
  __query["error_trace"] = error_trace
3056
3109
  if filter_path is not None:
3057
3110
  __query["filter_path"] = filter_path
3058
3111
  if human is not None:
3059
3112
  __query["human"] = human
3060
- if max_docs is not None:
3061
- __body["max_docs"] = max_docs
3062
3113
  if pretty is not None:
3063
3114
  __query["pretty"] = pretty
3064
3115
  if refresh is not None:
@@ -3067,12 +3118,8 @@ class AsyncElasticsearch(BaseClient):
3067
3118
  __query["requests_per_second"] = requests_per_second
3068
3119
  if require_alias is not None:
3069
3120
  __query["require_alias"] = require_alias
3070
- if script is not None:
3071
- __body["script"] = script
3072
3121
  if scroll is not None:
3073
3122
  __query["scroll"] = scroll
3074
- if size is not None:
3075
- __body["size"] = size
3076
3123
  if slices is not None:
3077
3124
  __query["slices"] = slices
3078
3125
  if timeout is not None:
@@ -3081,6 +3128,19 @@ class AsyncElasticsearch(BaseClient):
3081
3128
  __query["wait_for_active_shards"] = wait_for_active_shards
3082
3129
  if wait_for_completion is not None:
3083
3130
  __query["wait_for_completion"] = wait_for_completion
3131
+ if not __body:
3132
+ if dest is not None:
3133
+ __body["dest"] = dest
3134
+ if source is not None:
3135
+ __body["source"] = source
3136
+ if conflicts is not None:
3137
+ __body["conflicts"] = conflicts
3138
+ if max_docs is not None:
3139
+ __body["max_docs"] = max_docs
3140
+ if script is not None:
3141
+ __body["script"] = script
3142
+ if size is not None:
3143
+ __body["size"] = size
3084
3144
  __headers = {"accept": "application/json", "content-type": "application/json"}
3085
3145
  return await self.perform_request( # type: ignore[return-value]
3086
3146
  "POST", __path, params=__query, headers=__headers, body=__body
@@ -3100,7 +3160,7 @@ class AsyncElasticsearch(BaseClient):
3100
3160
  """
3101
3161
  Changes the number of requests per second for a particular Reindex operation.
3102
3162
 
3103
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-reindex.html>`_
3163
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-reindex.html>`_
3104
3164
 
3105
3165
  :param task_id: Identifier for the task.
3106
3166
  :param requests_per_second: The throttle for this request in sub-requests per
@@ -3126,7 +3186,7 @@ class AsyncElasticsearch(BaseClient):
3126
3186
  )
3127
3187
 
3128
3188
  @_rewrite_parameters(
3129
- body_fields=True,
3189
+ body_fields=("file", "params", "source"),
3130
3190
  ignore_deprecated_options={"params"},
3131
3191
  )
3132
3192
  async def render_search_template(
@@ -3140,11 +3200,12 @@ class AsyncElasticsearch(BaseClient):
3140
3200
  params: t.Optional[t.Mapping[str, t.Any]] = None,
3141
3201
  pretty: t.Optional[bool] = None,
3142
3202
  source: t.Optional[str] = None,
3203
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3143
3204
  ) -> ObjectApiResponse[t.Any]:
3144
3205
  """
3145
3206
  Allows to use the Mustache language to pre-render a search definition.
3146
3207
 
3147
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/render-search-template-api.html>`_
3208
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/render-search-template-api.html>`_
3148
3209
 
3149
3210
  :param id: ID of the search template to render. If no `source` is specified,
3150
3211
  this or the `id` request body parameter is required.
@@ -3160,21 +3221,22 @@ class AsyncElasticsearch(BaseClient):
3160
3221
  else:
3161
3222
  __path = "/_render/template"
3162
3223
  __query: t.Dict[str, t.Any] = {}
3163
- __body: t.Dict[str, t.Any] = {}
3224
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3164
3225
  if error_trace is not None:
3165
3226
  __query["error_trace"] = error_trace
3166
- if file is not None:
3167
- __body["file"] = file
3168
3227
  if filter_path is not None:
3169
3228
  __query["filter_path"] = filter_path
3170
3229
  if human is not None:
3171
3230
  __query["human"] = human
3172
- if params is not None:
3173
- __body["params"] = params
3174
3231
  if pretty is not None:
3175
3232
  __query["pretty"] = pretty
3176
- if source is not None:
3177
- __body["source"] = source
3233
+ if not __body:
3234
+ if file is not None:
3235
+ __body["file"] = file
3236
+ if params is not None:
3237
+ __body["params"] = params
3238
+ if source is not None:
3239
+ __body["source"] = source
3178
3240
  if not __body:
3179
3241
  __body = None # type: ignore[assignment]
3180
3242
  __headers = {"accept": "application/json"}
@@ -3185,7 +3247,7 @@ class AsyncElasticsearch(BaseClient):
3185
3247
  )
3186
3248
 
3187
3249
  @_rewrite_parameters(
3188
- body_fields=True,
3250
+ body_fields=("context", "context_setup", "script"),
3189
3251
  )
3190
3252
  async def scripts_painless_execute(
3191
3253
  self,
@@ -3197,23 +3259,20 @@ class AsyncElasticsearch(BaseClient):
3197
3259
  human: t.Optional[bool] = None,
3198
3260
  pretty: t.Optional[bool] = None,
3199
3261
  script: t.Optional[t.Mapping[str, t.Any]] = None,
3262
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3200
3263
  ) -> ObjectApiResponse[t.Any]:
3201
3264
  """
3202
3265
  Allows an arbitrary script to be executed and a result to be returned
3203
3266
 
3204
- `<https://www.elastic.co/guide/en/elasticsearch/painless/8.11/painless-execute-api.html>`_
3267
+ `<https://www.elastic.co/guide/en/elasticsearch/painless/8.12/painless-execute-api.html>`_
3205
3268
 
3206
3269
  :param context: The context that the script should run in.
3207
3270
  :param context_setup: Additional parameters for the `context`.
3208
3271
  :param script: The Painless script to execute.
3209
3272
  """
3210
3273
  __path = "/_scripts/painless/_execute"
3211
- __body: t.Dict[str, t.Any] = {}
3212
3274
  __query: t.Dict[str, t.Any] = {}
3213
- if context is not None:
3214
- __body["context"] = context
3215
- if context_setup is not None:
3216
- __body["context_setup"] = context_setup
3275
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3217
3276
  if error_trace is not None:
3218
3277
  __query["error_trace"] = error_trace
3219
3278
  if filter_path is not None:
@@ -3222,8 +3281,13 @@ class AsyncElasticsearch(BaseClient):
3222
3281
  __query["human"] = human
3223
3282
  if pretty is not None:
3224
3283
  __query["pretty"] = pretty
3225
- if script is not None:
3226
- __body["script"] = script
3284
+ if not __body:
3285
+ if context is not None:
3286
+ __body["context"] = context
3287
+ if context_setup is not None:
3288
+ __body["context_setup"] = context_setup
3289
+ if script is not None:
3290
+ __body["script"] = script
3227
3291
  if not __body:
3228
3292
  __body = None # type: ignore[assignment]
3229
3293
  __headers = {"accept": "application/json"}
@@ -3234,23 +3298,24 @@ class AsyncElasticsearch(BaseClient):
3234
3298
  )
3235
3299
 
3236
3300
  @_rewrite_parameters(
3237
- body_fields=True,
3301
+ body_fields=("scroll_id", "scroll"),
3238
3302
  )
3239
3303
  async def scroll(
3240
3304
  self,
3241
3305
  *,
3242
- scroll_id: str,
3306
+ scroll_id: t.Optional[str] = None,
3243
3307
  error_trace: t.Optional[bool] = None,
3244
3308
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3245
3309
  human: t.Optional[bool] = None,
3246
3310
  pretty: t.Optional[bool] = None,
3247
3311
  rest_total_hits_as_int: t.Optional[bool] = None,
3248
3312
  scroll: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
3313
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3249
3314
  ) -> ObjectApiResponse[t.Any]:
3250
3315
  """
3251
3316
  Allows to retrieve a large numbers of results from a single search request.
3252
3317
 
3253
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-request-body.html#request-body-search-scroll>`_
3318
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-request-body.html#request-body-search-scroll>`_
3254
3319
 
3255
3320
  :param scroll_id: Scroll ID of the search.
3256
3321
  :param rest_total_hits_as_int: If true, the API response’s hit.total property
@@ -3258,13 +3323,11 @@ class AsyncElasticsearch(BaseClient):
3258
3323
  is returned as an object.
3259
3324
  :param scroll: Period to retain the search context for scrolling.
3260
3325
  """
3261
- if scroll_id is None:
3326
+ if scroll_id is None and body is None:
3262
3327
  raise ValueError("Empty value passed for parameter 'scroll_id'")
3263
3328
  __path = "/_search/scroll"
3264
- __body: t.Dict[str, t.Any] = {}
3265
3329
  __query: t.Dict[str, t.Any] = {}
3266
- if scroll_id is not None:
3267
- __body["scroll_id"] = scroll_id
3330
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3268
3331
  if error_trace is not None:
3269
3332
  __query["error_trace"] = error_trace
3270
3333
  if filter_path is not None:
@@ -3275,8 +3338,11 @@ class AsyncElasticsearch(BaseClient):
3275
3338
  __query["pretty"] = pretty
3276
3339
  if rest_total_hits_as_int is not None:
3277
3340
  __query["rest_total_hits_as_int"] = rest_total_hits_as_int
3278
- if scroll is not None:
3279
- __body["scroll"] = scroll
3341
+ if not __body:
3342
+ if scroll_id is not None:
3343
+ __body["scroll_id"] = scroll_id
3344
+ if scroll is not None:
3345
+ __body["scroll"] = scroll
3280
3346
  if not __body:
3281
3347
  __body = None # type: ignore[assignment]
3282
3348
  __headers = {"accept": "application/json"}
@@ -3287,7 +3353,42 @@ class AsyncElasticsearch(BaseClient):
3287
3353
  )
3288
3354
 
3289
3355
  @_rewrite_parameters(
3290
- body_fields=True,
3356
+ body_fields=(
3357
+ "aggregations",
3358
+ "aggs",
3359
+ "collapse",
3360
+ "docvalue_fields",
3361
+ "explain",
3362
+ "ext",
3363
+ "fields",
3364
+ "from_",
3365
+ "highlight",
3366
+ "indices_boost",
3367
+ "knn",
3368
+ "min_score",
3369
+ "pit",
3370
+ "post_filter",
3371
+ "profile",
3372
+ "query",
3373
+ "rank",
3374
+ "rescore",
3375
+ "runtime_mappings",
3376
+ "script_fields",
3377
+ "search_after",
3378
+ "seq_no_primary_term",
3379
+ "size",
3380
+ "slice",
3381
+ "sort",
3382
+ "source",
3383
+ "stats",
3384
+ "stored_fields",
3385
+ "suggest",
3386
+ "terminate_after",
3387
+ "timeout",
3388
+ "track_scores",
3389
+ "track_total_hits",
3390
+ "version",
3391
+ ),
3291
3392
  parameter_aliases={
3292
3393
  "_source": "source",
3293
3394
  "_source_excludes": "source_excludes",
@@ -3388,11 +3489,12 @@ class AsyncElasticsearch(BaseClient):
3388
3489
  track_total_hits: t.Optional[t.Union[bool, int]] = None,
3389
3490
  typed_keys: t.Optional[bool] = None,
3390
3491
  version: t.Optional[bool] = None,
3492
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3391
3493
  ) -> ObjectApiResponse[t.Any]:
3392
3494
  """
3393
3495
  Returns results matching a query.
3394
3496
 
3395
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-search.html>`_
3497
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-search.html>`_
3396
3498
 
3397
3499
  :param index: Comma-separated list of data streams, indices, and aliases to search.
3398
3500
  Supports wildcards (`*`). To search all data streams and indices, omit this
@@ -3580,8 +3682,8 @@ class AsyncElasticsearch(BaseClient):
3580
3682
  __path = f"/{_quote(index)}/_search"
3581
3683
  else:
3582
3684
  __path = "/_search"
3583
- __body: t.Dict[str, t.Any] = {}
3584
3685
  __query: t.Dict[str, t.Any] = {}
3686
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3585
3687
  # The 'sort' parameter with a colon can't be encoded to the body.
3586
3688
  if sort is not None and (
3587
3689
  (isinstance(sort, str) and ":" in sort)
@@ -3593,10 +3695,6 @@ class AsyncElasticsearch(BaseClient):
3593
3695
  ):
3594
3696
  __query["sort"] = sort
3595
3697
  sort = None
3596
- if aggregations is not None:
3597
- __body["aggregations"] = aggregations
3598
- if aggs is not None:
3599
- __body["aggs"] = aggs
3600
3698
  if allow_no_indices is not None:
3601
3699
  __query["allow_no_indices"] = allow_no_indices
3602
3700
  if allow_partial_search_results is not None:
@@ -3609,104 +3707,50 @@ class AsyncElasticsearch(BaseClient):
3609
3707
  __query["batched_reduce_size"] = batched_reduce_size
3610
3708
  if ccs_minimize_roundtrips is not None:
3611
3709
  __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips
3612
- if collapse is not None:
3613
- __body["collapse"] = collapse
3614
3710
  if default_operator is not None:
3615
3711
  __query["default_operator"] = default_operator
3616
3712
  if df is not None:
3617
3713
  __query["df"] = df
3618
- if docvalue_fields is not None:
3619
- __body["docvalue_fields"] = docvalue_fields
3620
3714
  if error_trace is not None:
3621
3715
  __query["error_trace"] = error_trace
3622
3716
  if expand_wildcards is not None:
3623
3717
  __query["expand_wildcards"] = expand_wildcards
3624
- if explain is not None:
3625
- __body["explain"] = explain
3626
- if ext is not None:
3627
- __body["ext"] = ext
3628
- if fields is not None:
3629
- __body["fields"] = fields
3630
3718
  if filter_path is not None:
3631
3719
  __query["filter_path"] = filter_path
3632
- if from_ is not None:
3633
- __body["from"] = from_
3634
- if highlight is not None:
3635
- __body["highlight"] = highlight
3636
3720
  if human is not None:
3637
3721
  __query["human"] = human
3638
3722
  if ignore_throttled is not None:
3639
3723
  __query["ignore_throttled"] = ignore_throttled
3640
3724
  if ignore_unavailable is not None:
3641
3725
  __query["ignore_unavailable"] = ignore_unavailable
3642
- if indices_boost is not None:
3643
- __body["indices_boost"] = indices_boost
3644
- if knn is not None:
3645
- __body["knn"] = knn
3646
3726
  if lenient is not None:
3647
3727
  __query["lenient"] = lenient
3648
3728
  if max_concurrent_shard_requests is not None:
3649
3729
  __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
3650
3730
  if min_compatible_shard_node is not None:
3651
3731
  __query["min_compatible_shard_node"] = min_compatible_shard_node
3652
- if min_score is not None:
3653
- __body["min_score"] = min_score
3654
- if pit is not None:
3655
- __body["pit"] = pit
3656
- if post_filter is not None:
3657
- __body["post_filter"] = post_filter
3658
3732
  if pre_filter_shard_size is not None:
3659
3733
  __query["pre_filter_shard_size"] = pre_filter_shard_size
3660
3734
  if preference is not None:
3661
3735
  __query["preference"] = preference
3662
3736
  if pretty is not None:
3663
3737
  __query["pretty"] = pretty
3664
- if profile is not None:
3665
- __body["profile"] = profile
3666
3738
  if q is not None:
3667
3739
  __query["q"] = q
3668
- if query is not None:
3669
- __body["query"] = query
3670
- if rank is not None:
3671
- __body["rank"] = rank
3672
3740
  if request_cache is not None:
3673
3741
  __query["request_cache"] = request_cache
3674
- if rescore is not None:
3675
- __body["rescore"] = rescore
3676
3742
  if rest_total_hits_as_int is not None:
3677
3743
  __query["rest_total_hits_as_int"] = rest_total_hits_as_int
3678
3744
  if routing is not None:
3679
3745
  __query["routing"] = routing
3680
- if runtime_mappings is not None:
3681
- __body["runtime_mappings"] = runtime_mappings
3682
- if script_fields is not None:
3683
- __body["script_fields"] = script_fields
3684
3746
  if scroll is not None:
3685
3747
  __query["scroll"] = scroll
3686
- if search_after is not None:
3687
- __body["search_after"] = search_after
3688
3748
  if search_type is not None:
3689
3749
  __query["search_type"] = search_type
3690
- if seq_no_primary_term is not None:
3691
- __body["seq_no_primary_term"] = seq_no_primary_term
3692
- if size is not None:
3693
- __body["size"] = size
3694
- if slice is not None:
3695
- __body["slice"] = slice
3696
- if sort is not None:
3697
- __body["sort"] = sort
3698
- if source is not None:
3699
- __body["_source"] = source
3700
3750
  if source_excludes is not None:
3701
3751
  __query["_source_excludes"] = source_excludes
3702
3752
  if source_includes is not None:
3703
3753
  __query["_source_includes"] = source_includes
3704
- if stats is not None:
3705
- __body["stats"] = stats
3706
- if stored_fields is not None:
3707
- __body["stored_fields"] = stored_fields
3708
- if suggest is not None:
3709
- __body["suggest"] = suggest
3710
3754
  if suggest_field is not None:
3711
3755
  __query["suggest_field"] = suggest_field
3712
3756
  if suggest_mode is not None:
@@ -3715,18 +3759,77 @@ class AsyncElasticsearch(BaseClient):
3715
3759
  __query["suggest_size"] = suggest_size
3716
3760
  if suggest_text is not None:
3717
3761
  __query["suggest_text"] = suggest_text
3718
- if terminate_after is not None:
3719
- __body["terminate_after"] = terminate_after
3720
- if timeout is not None:
3721
- __body["timeout"] = timeout
3722
- if track_scores is not None:
3723
- __body["track_scores"] = track_scores
3724
- if track_total_hits is not None:
3725
- __body["track_total_hits"] = track_total_hits
3726
3762
  if typed_keys is not None:
3727
3763
  __query["typed_keys"] = typed_keys
3728
- if version is not None:
3729
- __body["version"] = version
3764
+ if not __body:
3765
+ if aggregations is not None:
3766
+ __body["aggregations"] = aggregations
3767
+ if aggs is not None:
3768
+ __body["aggs"] = aggs
3769
+ if collapse is not None:
3770
+ __body["collapse"] = collapse
3771
+ if docvalue_fields is not None:
3772
+ __body["docvalue_fields"] = docvalue_fields
3773
+ if explain is not None:
3774
+ __body["explain"] = explain
3775
+ if ext is not None:
3776
+ __body["ext"] = ext
3777
+ if fields is not None:
3778
+ __body["fields"] = fields
3779
+ if from_ is not None:
3780
+ __body["from"] = from_
3781
+ if highlight is not None:
3782
+ __body["highlight"] = highlight
3783
+ if indices_boost is not None:
3784
+ __body["indices_boost"] = indices_boost
3785
+ if knn is not None:
3786
+ __body["knn"] = knn
3787
+ if min_score is not None:
3788
+ __body["min_score"] = min_score
3789
+ if pit is not None:
3790
+ __body["pit"] = pit
3791
+ if post_filter is not None:
3792
+ __body["post_filter"] = post_filter
3793
+ if profile is not None:
3794
+ __body["profile"] = profile
3795
+ if query is not None:
3796
+ __body["query"] = query
3797
+ if rank is not None:
3798
+ __body["rank"] = rank
3799
+ if rescore is not None:
3800
+ __body["rescore"] = rescore
3801
+ if runtime_mappings is not None:
3802
+ __body["runtime_mappings"] = runtime_mappings
3803
+ if script_fields is not None:
3804
+ __body["script_fields"] = script_fields
3805
+ if search_after is not None:
3806
+ __body["search_after"] = search_after
3807
+ if seq_no_primary_term is not None:
3808
+ __body["seq_no_primary_term"] = seq_no_primary_term
3809
+ if size is not None:
3810
+ __body["size"] = size
3811
+ if slice is not None:
3812
+ __body["slice"] = slice
3813
+ if sort is not None:
3814
+ __body["sort"] = sort
3815
+ if source is not None:
3816
+ __body["_source"] = source
3817
+ if stats is not None:
3818
+ __body["stats"] = stats
3819
+ if stored_fields is not None:
3820
+ __body["stored_fields"] = stored_fields
3821
+ if suggest is not None:
3822
+ __body["suggest"] = suggest
3823
+ if terminate_after is not None:
3824
+ __body["terminate_after"] = terminate_after
3825
+ if timeout is not None:
3826
+ __body["timeout"] = timeout
3827
+ if track_scores is not None:
3828
+ __body["track_scores"] = track_scores
3829
+ if track_total_hits is not None:
3830
+ __body["track_total_hits"] = track_total_hits
3831
+ if version is not None:
3832
+ __body["version"] = version
3730
3833
  if not __body:
3731
3834
  __body = None # type: ignore[assignment]
3732
3835
  __headers = {"accept": "application/json"}
@@ -3737,7 +3840,22 @@ class AsyncElasticsearch(BaseClient):
3737
3840
  )
3738
3841
 
3739
3842
  @_rewrite_parameters(
3740
- body_fields=True,
3843
+ body_fields=(
3844
+ "aggs",
3845
+ "buffer",
3846
+ "exact_bounds",
3847
+ "extent",
3848
+ "fields",
3849
+ "grid_agg",
3850
+ "grid_precision",
3851
+ "grid_type",
3852
+ "query",
3853
+ "runtime_mappings",
3854
+ "size",
3855
+ "sort",
3856
+ "track_total_hits",
3857
+ "with_labels",
3858
+ ),
3741
3859
  )
3742
3860
  async def search_mvt(
3743
3861
  self,
@@ -3772,12 +3890,13 @@ class AsyncElasticsearch(BaseClient):
3772
3890
  ] = None,
3773
3891
  track_total_hits: t.Optional[t.Union[bool, int]] = None,
3774
3892
  with_labels: t.Optional[bool] = None,
3893
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3775
3894
  ) -> BinaryApiResponse:
3776
3895
  """
3777
3896
  Searches a vector tile for geospatial values. Returns results as a binary Mapbox
3778
3897
  vector tile.
3779
3898
 
3780
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-vector-tile-api.html>`_
3899
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-vector-tile-api.html>`_
3781
3900
 
3782
3901
  :param index: Comma-separated list of data streams, indices, or aliases to search
3783
3902
  :param field: Field containing geospatial data to return
@@ -3833,8 +3952,8 @@ class AsyncElasticsearch(BaseClient):
3833
3952
  if y in SKIP_IN_PATH:
3834
3953
  raise ValueError("Empty value passed for parameter 'y'")
3835
3954
  __path = f"/{_quote(index)}/_mvt/{_quote(field)}/{_quote(zoom)}/{_quote(x)}/{_quote(y)}"
3836
- __body: t.Dict[str, t.Any] = {}
3837
3955
  __query: t.Dict[str, t.Any] = {}
3956
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3838
3957
  # The 'sort' parameter with a colon can't be encoded to the body.
3839
3958
  if sort is not None and (
3840
3959
  (isinstance(sort, str) and ":" in sort)
@@ -3846,42 +3965,43 @@ class AsyncElasticsearch(BaseClient):
3846
3965
  ):
3847
3966
  __query["sort"] = sort
3848
3967
  sort = None
3849
- if aggs is not None:
3850
- __body["aggs"] = aggs
3851
- if buffer is not None:
3852
- __body["buffer"] = buffer
3853
3968
  if error_trace is not None:
3854
3969
  __query["error_trace"] = error_trace
3855
- if exact_bounds is not None:
3856
- __body["exact_bounds"] = exact_bounds
3857
- if extent is not None:
3858
- __body["extent"] = extent
3859
- if fields is not None:
3860
- __body["fields"] = fields
3861
3970
  if filter_path is not None:
3862
3971
  __query["filter_path"] = filter_path
3863
- if grid_agg is not None:
3864
- __body["grid_agg"] = grid_agg
3865
- if grid_precision is not None:
3866
- __body["grid_precision"] = grid_precision
3867
- if grid_type is not None:
3868
- __body["grid_type"] = grid_type
3869
3972
  if human is not None:
3870
3973
  __query["human"] = human
3871
3974
  if pretty is not None:
3872
3975
  __query["pretty"] = pretty
3873
- if query is not None:
3874
- __body["query"] = query
3875
- if runtime_mappings is not None:
3876
- __body["runtime_mappings"] = runtime_mappings
3877
- if size is not None:
3878
- __body["size"] = size
3879
- if sort is not None:
3880
- __body["sort"] = sort
3881
- if track_total_hits is not None:
3882
- __body["track_total_hits"] = track_total_hits
3883
- if with_labels is not None:
3884
- __body["with_labels"] = with_labels
3976
+ if not __body:
3977
+ if aggs is not None:
3978
+ __body["aggs"] = aggs
3979
+ if buffer is not None:
3980
+ __body["buffer"] = buffer
3981
+ if exact_bounds is not None:
3982
+ __body["exact_bounds"] = exact_bounds
3983
+ if extent is not None:
3984
+ __body["extent"] = extent
3985
+ if fields is not None:
3986
+ __body["fields"] = fields
3987
+ if grid_agg is not None:
3988
+ __body["grid_agg"] = grid_agg
3989
+ if grid_precision is not None:
3990
+ __body["grid_precision"] = grid_precision
3991
+ if grid_type is not None:
3992
+ __body["grid_type"] = grid_type
3993
+ if query is not None:
3994
+ __body["query"] = query
3995
+ if runtime_mappings is not None:
3996
+ __body["runtime_mappings"] = runtime_mappings
3997
+ if size is not None:
3998
+ __body["size"] = size
3999
+ if sort is not None:
4000
+ __body["sort"] = sort
4001
+ if track_total_hits is not None:
4002
+ __body["track_total_hits"] = track_total_hits
4003
+ if with_labels is not None:
4004
+ __body["with_labels"] = with_labels
3885
4005
  if not __body:
3886
4006
  __body = None # type: ignore[assignment]
3887
4007
  __headers = {"accept": "application/vnd.mapbox-vector-tile"}
@@ -3918,7 +4038,7 @@ class AsyncElasticsearch(BaseClient):
3918
4038
  Returns information about the indices and shards that a search request would
3919
4039
  be executed against.
3920
4040
 
3921
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-shards.html>`_
4041
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-shards.html>`_
3922
4042
 
3923
4043
  :param index: Returns the indices and shards that a search request would be executed
3924
4044
  against.
@@ -3970,7 +4090,7 @@ class AsyncElasticsearch(BaseClient):
3970
4090
  )
3971
4091
 
3972
4092
  @_rewrite_parameters(
3973
- body_fields=True,
4093
+ body_fields=("explain", "id", "params", "profile", "source"),
3974
4094
  ignore_deprecated_options={"params"},
3975
4095
  )
3976
4096
  async def search_template(
@@ -4006,11 +4126,12 @@ class AsyncElasticsearch(BaseClient):
4006
4126
  ] = None,
4007
4127
  source: t.Optional[str] = None,
4008
4128
  typed_keys: t.Optional[bool] = None,
4129
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4009
4130
  ) -> ObjectApiResponse[t.Any]:
4010
4131
  """
4011
4132
  Allows to use the Mustache language to pre-render a search definition.
4012
4133
 
4013
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-template.html>`_
4134
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-template.html>`_
4014
4135
 
4015
4136
  :param index: Comma-separated list of data streams, indices, and aliases to search.
4016
4137
  Supports wildcards (*).
@@ -4055,7 +4176,7 @@ class AsyncElasticsearch(BaseClient):
4055
4176
  else:
4056
4177
  __path = "/_search/template"
4057
4178
  __query: t.Dict[str, t.Any] = {}
4058
- __body: t.Dict[str, t.Any] = {}
4179
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4059
4180
  if allow_no_indices is not None:
4060
4181
  __query["allow_no_indices"] = allow_no_indices
4061
4182
  if ccs_minimize_roundtrips is not None:
@@ -4064,26 +4185,18 @@ class AsyncElasticsearch(BaseClient):
4064
4185
  __query["error_trace"] = error_trace
4065
4186
  if expand_wildcards is not None:
4066
4187
  __query["expand_wildcards"] = expand_wildcards
4067
- if explain is not None:
4068
- __body["explain"] = explain
4069
4188
  if filter_path is not None:
4070
4189
  __query["filter_path"] = filter_path
4071
4190
  if human is not None:
4072
4191
  __query["human"] = human
4073
- if id is not None:
4074
- __body["id"] = id
4075
4192
  if ignore_throttled is not None:
4076
4193
  __query["ignore_throttled"] = ignore_throttled
4077
4194
  if ignore_unavailable is not None:
4078
4195
  __query["ignore_unavailable"] = ignore_unavailable
4079
- if params is not None:
4080
- __body["params"] = params
4081
4196
  if preference is not None:
4082
4197
  __query["preference"] = preference
4083
4198
  if pretty is not None:
4084
4199
  __query["pretty"] = pretty
4085
- if profile is not None:
4086
- __body["profile"] = profile
4087
4200
  if rest_total_hits_as_int is not None:
4088
4201
  __query["rest_total_hits_as_int"] = rest_total_hits_as_int
4089
4202
  if routing is not None:
@@ -4092,23 +4205,40 @@ class AsyncElasticsearch(BaseClient):
4092
4205
  __query["scroll"] = scroll
4093
4206
  if search_type is not None:
4094
4207
  __query["search_type"] = search_type
4095
- if source is not None:
4096
- __body["source"] = source
4097
4208
  if typed_keys is not None:
4098
4209
  __query["typed_keys"] = typed_keys
4210
+ if not __body:
4211
+ if explain is not None:
4212
+ __body["explain"] = explain
4213
+ if id is not None:
4214
+ __body["id"] = id
4215
+ if params is not None:
4216
+ __body["params"] = params
4217
+ if profile is not None:
4218
+ __body["profile"] = profile
4219
+ if source is not None:
4220
+ __body["source"] = source
4099
4221
  __headers = {"accept": "application/json", "content-type": "application/json"}
4100
4222
  return await self.perform_request( # type: ignore[return-value]
4101
4223
  "POST", __path, params=__query, headers=__headers, body=__body
4102
4224
  )
4103
4225
 
4104
4226
  @_rewrite_parameters(
4105
- body_fields=True,
4227
+ body_fields=(
4228
+ "field",
4229
+ "case_insensitive",
4230
+ "index_filter",
4231
+ "search_after",
4232
+ "size",
4233
+ "string",
4234
+ "timeout",
4235
+ ),
4106
4236
  )
4107
4237
  async def terms_enum(
4108
4238
  self,
4109
4239
  *,
4110
4240
  index: str,
4111
- field: str,
4241
+ field: t.Optional[str] = None,
4112
4242
  case_insensitive: t.Optional[bool] = None,
4113
4243
  error_trace: t.Optional[bool] = None,
4114
4244
  filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -4119,13 +4249,14 @@ class AsyncElasticsearch(BaseClient):
4119
4249
  size: t.Optional[int] = None,
4120
4250
  string: t.Optional[str] = None,
4121
4251
  timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
4252
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4122
4253
  ) -> ObjectApiResponse[t.Any]:
4123
4254
  """
4124
4255
  The terms enum API can be used to discover terms in the index that begin with
4125
4256
  the provided string. It is designed for low-latency look-ups used in auto-complete
4126
4257
  scenarios.
4127
4258
 
4128
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-terms-enum.html>`_
4259
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-terms-enum.html>`_
4129
4260
 
4130
4261
  :param index: Comma-separated list of data streams, indices, and index aliases
4131
4262
  to search. Wildcard (*) expressions are supported.
@@ -4146,33 +4277,34 @@ class AsyncElasticsearch(BaseClient):
4146
4277
  """
4147
4278
  if index in SKIP_IN_PATH:
4148
4279
  raise ValueError("Empty value passed for parameter 'index'")
4149
- if field is None:
4280
+ if field is None and body is None:
4150
4281
  raise ValueError("Empty value passed for parameter 'field'")
4151
4282
  __path = f"/{_quote(index)}/_terms_enum"
4152
- __body: t.Dict[str, t.Any] = {}
4153
4283
  __query: t.Dict[str, t.Any] = {}
4154
- if field is not None:
4155
- __body["field"] = field
4156
- if case_insensitive is not None:
4157
- __body["case_insensitive"] = case_insensitive
4284
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4158
4285
  if error_trace is not None:
4159
4286
  __query["error_trace"] = error_trace
4160
4287
  if filter_path is not None:
4161
4288
  __query["filter_path"] = filter_path
4162
4289
  if human is not None:
4163
4290
  __query["human"] = human
4164
- if index_filter is not None:
4165
- __body["index_filter"] = index_filter
4166
4291
  if pretty is not None:
4167
4292
  __query["pretty"] = pretty
4168
- if search_after is not None:
4169
- __body["search_after"] = search_after
4170
- if size is not None:
4171
- __body["size"] = size
4172
- if string is not None:
4173
- __body["string"] = string
4174
- if timeout is not None:
4175
- __body["timeout"] = timeout
4293
+ if not __body:
4294
+ if field is not None:
4295
+ __body["field"] = field
4296
+ if case_insensitive is not None:
4297
+ __body["case_insensitive"] = case_insensitive
4298
+ if index_filter is not None:
4299
+ __body["index_filter"] = index_filter
4300
+ if search_after is not None:
4301
+ __body["search_after"] = search_after
4302
+ if size is not None:
4303
+ __body["size"] = size
4304
+ if string is not None:
4305
+ __body["string"] = string
4306
+ if timeout is not None:
4307
+ __body["timeout"] = timeout
4176
4308
  if not __body:
4177
4309
  __body = None # type: ignore[assignment]
4178
4310
  __headers = {"accept": "application/json"}
@@ -4183,7 +4315,7 @@ class AsyncElasticsearch(BaseClient):
4183
4315
  )
4184
4316
 
4185
4317
  @_rewrite_parameters(
4186
- body_fields=True,
4318
+ body_fields=("doc", "filter", "per_field_analyzer"),
4187
4319
  )
4188
4320
  async def termvectors(
4189
4321
  self,
@@ -4210,12 +4342,13 @@ class AsyncElasticsearch(BaseClient):
4210
4342
  version_type: t.Optional[
4211
4343
  t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str]
4212
4344
  ] = None,
4345
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4213
4346
  ) -> ObjectApiResponse[t.Any]:
4214
4347
  """
4215
4348
  Returns information and statistics about terms in the fields of a particular
4216
4349
  document.
4217
4350
 
4218
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-termvectors.html>`_
4351
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-termvectors.html>`_
4219
4352
 
4220
4353
  :param index: Name of the index that contains the document.
4221
4354
  :param id: Unique identifier of the document.
@@ -4248,18 +4381,14 @@ class AsyncElasticsearch(BaseClient):
4248
4381
  __path = f"/{_quote(index)}/_termvectors"
4249
4382
  else:
4250
4383
  raise ValueError("Couldn't find a path for the given parameters")
4251
- __body: t.Dict[str, t.Any] = {}
4252
4384
  __query: t.Dict[str, t.Any] = {}
4253
- if doc is not None:
4254
- __body["doc"] = doc
4385
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4255
4386
  if error_trace is not None:
4256
4387
  __query["error_trace"] = error_trace
4257
4388
  if field_statistics is not None:
4258
4389
  __query["field_statistics"] = field_statistics
4259
4390
  if fields is not None:
4260
4391
  __query["fields"] = fields
4261
- if filter is not None:
4262
- __body["filter"] = filter
4263
4392
  if filter_path is not None:
4264
4393
  __query["filter_path"] = filter_path
4265
4394
  if human is not None:
@@ -4268,8 +4397,6 @@ class AsyncElasticsearch(BaseClient):
4268
4397
  __query["offsets"] = offsets
4269
4398
  if payloads is not None:
4270
4399
  __query["payloads"] = payloads
4271
- if per_field_analyzer is not None:
4272
- __body["per_field_analyzer"] = per_field_analyzer
4273
4400
  if positions is not None:
4274
4401
  __query["positions"] = positions
4275
4402
  if preference is not None:
@@ -4286,6 +4413,13 @@ class AsyncElasticsearch(BaseClient):
4286
4413
  __query["version"] = version
4287
4414
  if version_type is not None:
4288
4415
  __query["version_type"] = version_type
4416
+ if not __body:
4417
+ if doc is not None:
4418
+ __body["doc"] = doc
4419
+ if filter is not None:
4420
+ __body["filter"] = filter
4421
+ if per_field_analyzer is not None:
4422
+ __body["per_field_analyzer"] = per_field_analyzer
4289
4423
  if not __body:
4290
4424
  __body = None # type: ignore[assignment]
4291
4425
  __headers = {"accept": "application/json"}
@@ -4296,7 +4430,15 @@ class AsyncElasticsearch(BaseClient):
4296
4430
  )
4297
4431
 
4298
4432
  @_rewrite_parameters(
4299
- body_fields=True,
4433
+ body_fields=(
4434
+ "detect_noop",
4435
+ "doc",
4436
+ "doc_as_upsert",
4437
+ "script",
4438
+ "scripted_upsert",
4439
+ "source",
4440
+ "upsert",
4441
+ ),
4300
4442
  parameter_aliases={
4301
4443
  "_source": "source",
4302
4444
  "_source_excludes": "source_excludes",
@@ -4334,11 +4476,12 @@ class AsyncElasticsearch(BaseClient):
4334
4476
  wait_for_active_shards: t.Optional[
4335
4477
  t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
4336
4478
  ] = None,
4479
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4337
4480
  ) -> ObjectApiResponse[t.Any]:
4338
4481
  """
4339
4482
  Updates a document with a script or partial document.
4340
4483
 
4341
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-update.html>`_
4484
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-update.html>`_
4342
4485
 
4343
4486
  :param index: The name of the index
4344
4487
  :param id: Document ID
@@ -4381,14 +4524,8 @@ class AsyncElasticsearch(BaseClient):
4381
4524
  if id in SKIP_IN_PATH:
4382
4525
  raise ValueError("Empty value passed for parameter 'id'")
4383
4526
  __path = f"/{_quote(index)}/_update/{_quote(id)}"
4384
- __body: t.Dict[str, t.Any] = {}
4385
4527
  __query: t.Dict[str, t.Any] = {}
4386
- if detect_noop is not None:
4387
- __body["detect_noop"] = detect_noop
4388
- if doc is not None:
4389
- __body["doc"] = doc
4390
- if doc_as_upsert is not None:
4391
- __body["doc_as_upsert"] = doc_as_upsert
4528
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4392
4529
  if error_trace is not None:
4393
4530
  __query["error_trace"] = error_trace
4394
4531
  if filter_path is not None:
@@ -4411,29 +4548,36 @@ class AsyncElasticsearch(BaseClient):
4411
4548
  __query["retry_on_conflict"] = retry_on_conflict
4412
4549
  if routing is not None:
4413
4550
  __query["routing"] = routing
4414
- if script is not None:
4415
- __body["script"] = script
4416
- if scripted_upsert is not None:
4417
- __body["scripted_upsert"] = scripted_upsert
4418
- if source is not None:
4419
- __body["_source"] = source
4420
4551
  if source_excludes is not None:
4421
4552
  __query["_source_excludes"] = source_excludes
4422
4553
  if source_includes is not None:
4423
4554
  __query["_source_includes"] = source_includes
4424
4555
  if timeout is not None:
4425
4556
  __query["timeout"] = timeout
4426
- if upsert is not None:
4427
- __body["upsert"] = upsert
4428
4557
  if wait_for_active_shards is not None:
4429
4558
  __query["wait_for_active_shards"] = wait_for_active_shards
4559
+ if not __body:
4560
+ if detect_noop is not None:
4561
+ __body["detect_noop"] = detect_noop
4562
+ if doc is not None:
4563
+ __body["doc"] = doc
4564
+ if doc_as_upsert is not None:
4565
+ __body["doc_as_upsert"] = doc_as_upsert
4566
+ if script is not None:
4567
+ __body["script"] = script
4568
+ if scripted_upsert is not None:
4569
+ __body["scripted_upsert"] = scripted_upsert
4570
+ if source is not None:
4571
+ __body["_source"] = source
4572
+ if upsert is not None:
4573
+ __body["upsert"] = upsert
4430
4574
  __headers = {"accept": "application/json", "content-type": "application/json"}
4431
4575
  return await self.perform_request( # type: ignore[return-value]
4432
4576
  "POST", __path, params=__query, headers=__headers, body=__body
4433
4577
  )
4434
4578
 
4435
4579
  @_rewrite_parameters(
4436
- body_fields=True,
4580
+ body_fields=("conflicts", "max_docs", "query", "script", "slice"),
4437
4581
  parameter_aliases={"from": "from_"},
4438
4582
  )
4439
4583
  async def update_by_query(
@@ -4490,12 +4634,13 @@ class AsyncElasticsearch(BaseClient):
4490
4634
  t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
4491
4635
  ] = None,
4492
4636
  wait_for_completion: t.Optional[bool] = None,
4637
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4493
4638
  ) -> ObjectApiResponse[t.Any]:
4494
4639
  """
4495
4640
  Performs an update on every document in the index without changing the source,
4496
4641
  for example to pick up a mapping change.
4497
4642
 
4498
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-update-by-query.html>`_
4643
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-update-by-query.html>`_
4499
4644
 
4500
4645
  :param index: Comma-separated list of data streams, indices, and aliases to search.
4501
4646
  Supports wildcards (`*`). To search all data streams or indices, omit this
@@ -4571,7 +4716,7 @@ class AsyncElasticsearch(BaseClient):
4571
4716
  raise ValueError("Empty value passed for parameter 'index'")
4572
4717
  __path = f"/{_quote(index)}/_update_by_query"
4573
4718
  __query: t.Dict[str, t.Any] = {}
4574
- __body: t.Dict[str, t.Any] = {}
4719
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4575
4720
  # The 'sort' parameter with a colon can't be encoded to the body.
4576
4721
  if sort is not None and (
4577
4722
  (isinstance(sort, str) and ":" in sort)
@@ -4589,8 +4734,6 @@ class AsyncElasticsearch(BaseClient):
4589
4734
  __query["analyze_wildcard"] = analyze_wildcard
4590
4735
  if analyzer is not None:
4591
4736
  __query["analyzer"] = analyzer
4592
- if conflicts is not None:
4593
- __body["conflicts"] = conflicts
4594
4737
  if default_operator is not None:
4595
4738
  __query["default_operator"] = default_operator
4596
4739
  if df is not None:
@@ -4609,16 +4752,12 @@ class AsyncElasticsearch(BaseClient):
4609
4752
  __query["ignore_unavailable"] = ignore_unavailable
4610
4753
  if lenient is not None:
4611
4754
  __query["lenient"] = lenient
4612
- if max_docs is not None:
4613
- __body["max_docs"] = max_docs
4614
4755
  if pipeline is not None:
4615
4756
  __query["pipeline"] = pipeline
4616
4757
  if preference is not None:
4617
4758
  __query["preference"] = preference
4618
4759
  if pretty is not None:
4619
4760
  __query["pretty"] = pretty
4620
- if query is not None:
4621
- __body["query"] = query
4622
4761
  if refresh is not None:
4623
4762
  __query["refresh"] = refresh
4624
4763
  if request_cache is not None:
@@ -4627,8 +4766,6 @@ class AsyncElasticsearch(BaseClient):
4627
4766
  __query["requests_per_second"] = requests_per_second
4628
4767
  if routing is not None:
4629
4768
  __query["routing"] = routing
4630
- if script is not None:
4631
- __body["script"] = script
4632
4769
  if scroll is not None:
4633
4770
  __query["scroll"] = scroll
4634
4771
  if scroll_size is not None:
@@ -4637,8 +4774,6 @@ class AsyncElasticsearch(BaseClient):
4637
4774
  __query["search_timeout"] = search_timeout
4638
4775
  if search_type is not None:
4639
4776
  __query["search_type"] = search_type
4640
- if slice is not None:
4641
- __body["slice"] = slice
4642
4777
  if slices is not None:
4643
4778
  __query["slices"] = slices
4644
4779
  if sort is not None:
@@ -4657,6 +4792,17 @@ class AsyncElasticsearch(BaseClient):
4657
4792
  __query["wait_for_active_shards"] = wait_for_active_shards
4658
4793
  if wait_for_completion is not None:
4659
4794
  __query["wait_for_completion"] = wait_for_completion
4795
+ if not __body:
4796
+ if conflicts is not None:
4797
+ __body["conflicts"] = conflicts
4798
+ if max_docs is not None:
4799
+ __body["max_docs"] = max_docs
4800
+ if query is not None:
4801
+ __body["query"] = query
4802
+ if script is not None:
4803
+ __body["script"] = script
4804
+ if slice is not None:
4805
+ __body["slice"] = slice
4660
4806
  if not __body:
4661
4807
  __body = None # type: ignore[assignment]
4662
4808
  __headers = {"accept": "application/json"}
@@ -4680,7 +4826,7 @@ class AsyncElasticsearch(BaseClient):
4680
4826
  """
4681
4827
  Changes the number of requests per second for a particular Update By Query operation.
4682
4828
 
4683
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-update-by-query.html>`_
4829
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-update-by-query.html>`_
4684
4830
 
4685
4831
  :param task_id: The ID for the task.
4686
4832
  :param requests_per_second: The throttle for this request in sub-requests per