elasticsearch 8.11.0__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.
- elasticsearch/_async/client/__init__.py +493 -347
- elasticsearch/_async/client/async_search.py +108 -72
- elasticsearch/_async/client/autoscaling.py +13 -8
- elasticsearch/_async/client/cat.py +26 -26
- elasticsearch/_async/client/ccr.py +178 -117
- elasticsearch/_async/client/cluster.py +56 -48
- elasticsearch/_async/client/dangling_indices.py +3 -3
- elasticsearch/_async/client/enrich.py +15 -13
- elasticsearch/_async/client/eql.py +53 -36
- elasticsearch/_async/client/esql.py +99 -0
- elasticsearch/_async/client/features.py +2 -2
- elasticsearch/_async/client/fleet.py +111 -71
- elasticsearch/_async/client/graph.py +13 -11
- elasticsearch/_async/client/ilm.py +33 -27
- elasticsearch/_async/client/indices.py +326 -227
- elasticsearch/_async/client/inference.py +212 -0
- elasticsearch/_async/client/ingest.py +28 -24
- elasticsearch/_async/client/license.py +15 -13
- elasticsearch/_async/client/logstash.py +13 -10
- elasticsearch/_async/client/migration.py +3 -3
- elasticsearch/_async/client/ml.py +762 -538
- elasticsearch/_async/client/monitoring.py +10 -5
- elasticsearch/_async/client/nodes.py +13 -11
- elasticsearch/_async/client/query_ruleset.py +12 -10
- elasticsearch/_async/client/rollup.py +59 -46
- elasticsearch/_async/client/search_application.py +23 -16
- elasticsearch/_async/client/searchable_snapshots.py +23 -16
- elasticsearch/_async/client/security.py +393 -287
- elasticsearch/_async/client/shutdown.py +18 -14
- elasticsearch/_async/client/slm.py +23 -21
- elasticsearch/_async/client/snapshot.py +91 -65
- elasticsearch/_async/client/sql.py +81 -58
- elasticsearch/_async/client/ssl.py +1 -1
- elasticsearch/_async/client/synonyms.py +23 -19
- elasticsearch/_async/client/tasks.py +3 -3
- elasticsearch/_async/client/text_structure.py +10 -5
- elasticsearch/_async/client/transform.py +111 -75
- elasticsearch/_async/client/watcher.py +77 -55
- elasticsearch/_async/client/xpack.py +2 -2
- elasticsearch/_async/helpers.py +1 -1
- elasticsearch/_sync/client/__init__.py +493 -347
- elasticsearch/_sync/client/async_search.py +108 -72
- elasticsearch/_sync/client/autoscaling.py +13 -8
- elasticsearch/_sync/client/cat.py +26 -26
- elasticsearch/_sync/client/ccr.py +178 -117
- elasticsearch/_sync/client/cluster.py +56 -48
- elasticsearch/_sync/client/dangling_indices.py +3 -3
- elasticsearch/_sync/client/enrich.py +15 -13
- elasticsearch/_sync/client/eql.py +53 -36
- elasticsearch/_sync/client/esql.py +99 -0
- elasticsearch/_sync/client/features.py +2 -2
- elasticsearch/_sync/client/fleet.py +111 -71
- elasticsearch/_sync/client/graph.py +13 -11
- elasticsearch/_sync/client/ilm.py +33 -27
- elasticsearch/_sync/client/indices.py +326 -227
- elasticsearch/_sync/client/inference.py +212 -0
- elasticsearch/_sync/client/ingest.py +28 -24
- elasticsearch/_sync/client/license.py +15 -13
- elasticsearch/_sync/client/logstash.py +13 -10
- elasticsearch/_sync/client/migration.py +3 -3
- elasticsearch/_sync/client/ml.py +762 -538
- elasticsearch/_sync/client/monitoring.py +10 -5
- elasticsearch/_sync/client/nodes.py +13 -11
- elasticsearch/_sync/client/query_ruleset.py +12 -10
- elasticsearch/_sync/client/rollup.py +59 -46
- elasticsearch/_sync/client/search_application.py +23 -16
- elasticsearch/_sync/client/searchable_snapshots.py +23 -16
- elasticsearch/_sync/client/security.py +393 -287
- elasticsearch/_sync/client/shutdown.py +18 -14
- elasticsearch/_sync/client/slm.py +23 -21
- elasticsearch/_sync/client/snapshot.py +91 -65
- elasticsearch/_sync/client/sql.py +81 -58
- elasticsearch/_sync/client/ssl.py +1 -1
- elasticsearch/_sync/client/synonyms.py +23 -19
- elasticsearch/_sync/client/tasks.py +3 -3
- elasticsearch/_sync/client/text_structure.py +10 -5
- elasticsearch/_sync/client/transform.py +111 -75
- elasticsearch/_sync/client/utils.py +34 -10
- elasticsearch/_sync/client/watcher.py +77 -55
- elasticsearch/_sync/client/xpack.py +2 -2
- elasticsearch/_version.py +1 -1
- elasticsearch/client.py +2 -0
- elasticsearch/helpers/actions.py +1 -1
- {elasticsearch-8.11.0.dist-info → elasticsearch-8.12.0.dist-info}/METADATA +7 -4
- elasticsearch-8.12.0.dist-info/RECORD +103 -0
- {elasticsearch-8.11.0.dist-info → elasticsearch-8.12.0.dist-info}/WHEEL +1 -1
- elasticsearch-8.11.0.dist-info/RECORD +0 -99
- {elasticsearch-8.11.0.dist-info → elasticsearch-8.12.0.dist-info}/LICENSE +0 -0
- {elasticsearch-8.11.0.dist-info → elasticsearch-8.12.0.dist-info}/NOTICE +0 -0
- {elasticsearch-8.11.0.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 Elasticsearch(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 Elasticsearch(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)
|
|
@@ -610,7 +614,8 @@ class Elasticsearch(BaseClient):
|
|
|
610
614
|
def bulk(
|
|
611
615
|
self,
|
|
612
616
|
*,
|
|
613
|
-
operations: t.Sequence[t.Mapping[str, t.Any]],
|
|
617
|
+
operations: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
618
|
+
body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
614
619
|
index: t.Optional[str] = None,
|
|
615
620
|
error_trace: t.Optional[bool] = None,
|
|
616
621
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -633,7 +638,7 @@ class Elasticsearch(BaseClient):
|
|
|
633
638
|
"""
|
|
634
639
|
Allows to perform multiple index/update/delete operations in a single request.
|
|
635
640
|
|
|
636
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
641
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-bulk.html>`_
|
|
637
642
|
|
|
638
643
|
:param operations:
|
|
639
644
|
:param index: Name of the data stream, index, or index alias to perform bulk
|
|
@@ -661,8 +666,12 @@ class Elasticsearch(BaseClient):
|
|
|
661
666
|
before proceeding with the operation. Set to all or any positive integer
|
|
662
667
|
up to the total number of shards in the index (`number_of_replicas+1`).
|
|
663
668
|
"""
|
|
664
|
-
if operations is None:
|
|
665
|
-
raise ValueError(
|
|
669
|
+
if operations is None and body is None:
|
|
670
|
+
raise ValueError(
|
|
671
|
+
"Empty value passed for parameters 'operations' and 'body', one of them should be set."
|
|
672
|
+
)
|
|
673
|
+
elif operations is not None and body is not None:
|
|
674
|
+
raise ValueError("Cannot set both 'operations' and 'body'")
|
|
666
675
|
if index not in SKIP_IN_PATH:
|
|
667
676
|
__path = f"/{_quote(index)}/_bulk"
|
|
668
677
|
else:
|
|
@@ -694,7 +703,7 @@ class Elasticsearch(BaseClient):
|
|
|
694
703
|
__query["timeout"] = timeout
|
|
695
704
|
if wait_for_active_shards is not None:
|
|
696
705
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
697
|
-
__body = operations
|
|
706
|
+
__body = operations if operations is not None else body
|
|
698
707
|
__headers = {
|
|
699
708
|
"accept": "application/json",
|
|
700
709
|
"content-type": "application/x-ndjson",
|
|
@@ -704,7 +713,7 @@ class Elasticsearch(BaseClient):
|
|
|
704
713
|
)
|
|
705
714
|
|
|
706
715
|
@_rewrite_parameters(
|
|
707
|
-
body_fields=
|
|
716
|
+
body_fields=("scroll_id",),
|
|
708
717
|
)
|
|
709
718
|
def clear_scroll(
|
|
710
719
|
self,
|
|
@@ -714,17 +723,18 @@ class Elasticsearch(BaseClient):
|
|
|
714
723
|
human: t.Optional[bool] = None,
|
|
715
724
|
pretty: t.Optional[bool] = None,
|
|
716
725
|
scroll_id: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
726
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
717
727
|
) -> ObjectApiResponse[t.Any]:
|
|
718
728
|
"""
|
|
719
729
|
Explicitly clears the search context for a scroll.
|
|
720
730
|
|
|
721
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
731
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/clear-scroll-api.html>`_
|
|
722
732
|
|
|
723
733
|
:param scroll_id: Scroll IDs to clear. To clear all scroll IDs, use `_all`.
|
|
724
734
|
"""
|
|
725
735
|
__path = "/_search/scroll"
|
|
726
736
|
__query: t.Dict[str, t.Any] = {}
|
|
727
|
-
__body: t.Dict[str, t.Any] = {}
|
|
737
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
728
738
|
if error_trace is not None:
|
|
729
739
|
__query["error_trace"] = error_trace
|
|
730
740
|
if filter_path is not None:
|
|
@@ -733,8 +743,9 @@ class Elasticsearch(BaseClient):
|
|
|
733
743
|
__query["human"] = human
|
|
734
744
|
if pretty is not None:
|
|
735
745
|
__query["pretty"] = pretty
|
|
736
|
-
if
|
|
737
|
-
|
|
746
|
+
if not __body:
|
|
747
|
+
if scroll_id is not None:
|
|
748
|
+
__body["scroll_id"] = scroll_id
|
|
738
749
|
if not __body:
|
|
739
750
|
__body = None # type: ignore[assignment]
|
|
740
751
|
__headers = {"accept": "application/json"}
|
|
@@ -745,31 +756,30 @@ class Elasticsearch(BaseClient):
|
|
|
745
756
|
)
|
|
746
757
|
|
|
747
758
|
@_rewrite_parameters(
|
|
748
|
-
body_fields=
|
|
759
|
+
body_fields=("id",),
|
|
749
760
|
)
|
|
750
761
|
def close_point_in_time(
|
|
751
762
|
self,
|
|
752
763
|
*,
|
|
753
|
-
id: str,
|
|
764
|
+
id: t.Optional[str] = None,
|
|
754
765
|
error_trace: t.Optional[bool] = None,
|
|
755
766
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
756
767
|
human: t.Optional[bool] = None,
|
|
757
768
|
pretty: t.Optional[bool] = None,
|
|
769
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
758
770
|
) -> ObjectApiResponse[t.Any]:
|
|
759
771
|
"""
|
|
760
772
|
Close a point in time
|
|
761
773
|
|
|
762
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
774
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/point-in-time-api.html>`_
|
|
763
775
|
|
|
764
776
|
:param id: The ID of the point-in-time.
|
|
765
777
|
"""
|
|
766
|
-
if id is None:
|
|
778
|
+
if id is None and body is None:
|
|
767
779
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
768
780
|
__path = "/_pit"
|
|
769
|
-
__body: t.Dict[str, t.Any] = {}
|
|
770
781
|
__query: t.Dict[str, t.Any] = {}
|
|
771
|
-
if
|
|
772
|
-
__body["id"] = id
|
|
782
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
773
783
|
if error_trace is not None:
|
|
774
784
|
__query["error_trace"] = error_trace
|
|
775
785
|
if filter_path is not None:
|
|
@@ -778,6 +788,9 @@ class Elasticsearch(BaseClient):
|
|
|
778
788
|
__query["human"] = human
|
|
779
789
|
if pretty is not None:
|
|
780
790
|
__query["pretty"] = pretty
|
|
791
|
+
if not __body:
|
|
792
|
+
if id is not None:
|
|
793
|
+
__body["id"] = id
|
|
781
794
|
if not __body:
|
|
782
795
|
__body = None # type: ignore[assignment]
|
|
783
796
|
__headers = {"accept": "application/json"}
|
|
@@ -788,7 +801,7 @@ class Elasticsearch(BaseClient):
|
|
|
788
801
|
)
|
|
789
802
|
|
|
790
803
|
@_rewrite_parameters(
|
|
791
|
-
body_fields=
|
|
804
|
+
body_fields=("query",),
|
|
792
805
|
)
|
|
793
806
|
def count(
|
|
794
807
|
self,
|
|
@@ -820,11 +833,12 @@ class Elasticsearch(BaseClient):
|
|
|
820
833
|
query: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
821
834
|
routing: t.Optional[str] = None,
|
|
822
835
|
terminate_after: t.Optional[int] = None,
|
|
836
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
823
837
|
) -> ObjectApiResponse[t.Any]:
|
|
824
838
|
"""
|
|
825
839
|
Returns number of documents matching a query.
|
|
826
840
|
|
|
827
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
841
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-count.html>`_
|
|
828
842
|
|
|
829
843
|
:param index: Comma-separated list of data streams, indices, and aliases to search.
|
|
830
844
|
Supports wildcards (`*`). To search all data streams and indices, omit this
|
|
@@ -868,7 +882,7 @@ class Elasticsearch(BaseClient):
|
|
|
868
882
|
else:
|
|
869
883
|
__path = "/_count"
|
|
870
884
|
__query: t.Dict[str, t.Any] = {}
|
|
871
|
-
__body: t.Dict[str, t.Any] = {}
|
|
885
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
872
886
|
if allow_no_indices is not None:
|
|
873
887
|
__query["allow_no_indices"] = allow_no_indices
|
|
874
888
|
if analyze_wildcard is not None:
|
|
@@ -901,12 +915,13 @@ class Elasticsearch(BaseClient):
|
|
|
901
915
|
__query["pretty"] = pretty
|
|
902
916
|
if q is not None:
|
|
903
917
|
__query["q"] = q
|
|
904
|
-
if query is not None:
|
|
905
|
-
__body["query"] = query
|
|
906
918
|
if routing is not None:
|
|
907
919
|
__query["routing"] = routing
|
|
908
920
|
if terminate_after is not None:
|
|
909
921
|
__query["terminate_after"] = terminate_after
|
|
922
|
+
if not __body:
|
|
923
|
+
if query is not None:
|
|
924
|
+
__body["query"] = query
|
|
910
925
|
if not __body:
|
|
911
926
|
__body = None # type: ignore[assignment]
|
|
912
927
|
__headers = {"accept": "application/json"}
|
|
@@ -924,7 +939,8 @@ class Elasticsearch(BaseClient):
|
|
|
924
939
|
*,
|
|
925
940
|
index: str,
|
|
926
941
|
id: str,
|
|
927
|
-
document: t.Mapping[str, t.Any],
|
|
942
|
+
document: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
943
|
+
body: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
928
944
|
error_trace: t.Optional[bool] = None,
|
|
929
945
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
930
946
|
human: t.Optional[bool] = None,
|
|
@@ -947,7 +963,7 @@ class Elasticsearch(BaseClient):
|
|
|
947
963
|
Creates a new document in the index. Returns a 409 response when a document with
|
|
948
964
|
a same ID already exists in the index.
|
|
949
965
|
|
|
950
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
966
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-index_.html>`_
|
|
951
967
|
|
|
952
968
|
:param index: Name of the data stream or index to target. If the target doesn’t
|
|
953
969
|
exist and matches the name or wildcard (`*`) pattern of an index template
|
|
@@ -980,8 +996,12 @@ class Elasticsearch(BaseClient):
|
|
|
980
996
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
981
997
|
if id in SKIP_IN_PATH:
|
|
982
998
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
983
|
-
if document is None:
|
|
984
|
-
raise ValueError(
|
|
999
|
+
if document is None and body is None:
|
|
1000
|
+
raise ValueError(
|
|
1001
|
+
"Empty value passed for parameters 'document' and 'body', one of them should be set."
|
|
1002
|
+
)
|
|
1003
|
+
elif document is not None and body is not None:
|
|
1004
|
+
raise ValueError("Cannot set both 'document' and 'body'")
|
|
985
1005
|
__path = f"/{_quote(index)}/_create/{_quote(id)}"
|
|
986
1006
|
__query: t.Dict[str, t.Any] = {}
|
|
987
1007
|
if error_trace is not None:
|
|
@@ -1006,7 +1026,7 @@ class Elasticsearch(BaseClient):
|
|
|
1006
1026
|
__query["version_type"] = version_type
|
|
1007
1027
|
if wait_for_active_shards is not None:
|
|
1008
1028
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
1009
|
-
__body = document
|
|
1029
|
+
__body = document if document is not None else body
|
|
1010
1030
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
1011
1031
|
return self.perform_request( # type: ignore[return-value]
|
|
1012
1032
|
"PUT", __path, params=__query, headers=__headers, body=__body
|
|
@@ -1040,7 +1060,7 @@ class Elasticsearch(BaseClient):
|
|
|
1040
1060
|
"""
|
|
1041
1061
|
Removes a document from the index.
|
|
1042
1062
|
|
|
1043
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1063
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-delete.html>`_
|
|
1044
1064
|
|
|
1045
1065
|
:param index: Name of the target index.
|
|
1046
1066
|
:param id: Unique identifier for the document.
|
|
@@ -1098,7 +1118,7 @@ class Elasticsearch(BaseClient):
|
|
|
1098
1118
|
)
|
|
1099
1119
|
|
|
1100
1120
|
@_rewrite_parameters(
|
|
1101
|
-
body_fields=
|
|
1121
|
+
body_fields=("max_docs", "query", "slice"),
|
|
1102
1122
|
parameter_aliases={"from": "from_"},
|
|
1103
1123
|
)
|
|
1104
1124
|
def delete_by_query(
|
|
@@ -1153,11 +1173,12 @@ class Elasticsearch(BaseClient):
|
|
|
1153
1173
|
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
|
|
1154
1174
|
] = None,
|
|
1155
1175
|
wait_for_completion: t.Optional[bool] = None,
|
|
1176
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
1156
1177
|
) -> ObjectApiResponse[t.Any]:
|
|
1157
1178
|
"""
|
|
1158
1179
|
Deletes documents matching the provided query.
|
|
1159
1180
|
|
|
1160
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1181
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-delete-by-query.html>`_
|
|
1161
1182
|
|
|
1162
1183
|
:param index: Comma-separated list of data streams, indices, and aliases to search.
|
|
1163
1184
|
Supports wildcards (`*`). To search all data streams or indices, omit this
|
|
@@ -1226,7 +1247,7 @@ class Elasticsearch(BaseClient):
|
|
|
1226
1247
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
1227
1248
|
__path = f"/{_quote(index)}/_delete_by_query"
|
|
1228
1249
|
__query: t.Dict[str, t.Any] = {}
|
|
1229
|
-
__body: t.Dict[str, t.Any] = {}
|
|
1250
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
1230
1251
|
# The 'sort' parameter with a colon can't be encoded to the body.
|
|
1231
1252
|
if sort is not None and (
|
|
1232
1253
|
(isinstance(sort, str) and ":" in sort)
|
|
@@ -1264,16 +1285,12 @@ class Elasticsearch(BaseClient):
|
|
|
1264
1285
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
1265
1286
|
if lenient is not None:
|
|
1266
1287
|
__query["lenient"] = lenient
|
|
1267
|
-
if max_docs is not None:
|
|
1268
|
-
__body["max_docs"] = max_docs
|
|
1269
1288
|
if preference is not None:
|
|
1270
1289
|
__query["preference"] = preference
|
|
1271
1290
|
if pretty is not None:
|
|
1272
1291
|
__query["pretty"] = pretty
|
|
1273
1292
|
if q is not None:
|
|
1274
1293
|
__query["q"] = q
|
|
1275
|
-
if query is not None:
|
|
1276
|
-
__body["query"] = query
|
|
1277
1294
|
if refresh is not None:
|
|
1278
1295
|
__query["refresh"] = refresh
|
|
1279
1296
|
if request_cache is not None:
|
|
@@ -1290,8 +1307,6 @@ class Elasticsearch(BaseClient):
|
|
|
1290
1307
|
__query["search_timeout"] = search_timeout
|
|
1291
1308
|
if search_type is not None:
|
|
1292
1309
|
__query["search_type"] = search_type
|
|
1293
|
-
if slice is not None:
|
|
1294
|
-
__body["slice"] = slice
|
|
1295
1310
|
if slices is not None:
|
|
1296
1311
|
__query["slices"] = slices
|
|
1297
1312
|
if sort is not None:
|
|
@@ -1308,6 +1323,13 @@ class Elasticsearch(BaseClient):
|
|
|
1308
1323
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
1309
1324
|
if wait_for_completion is not None:
|
|
1310
1325
|
__query["wait_for_completion"] = wait_for_completion
|
|
1326
|
+
if not __body:
|
|
1327
|
+
if max_docs is not None:
|
|
1328
|
+
__body["max_docs"] = max_docs
|
|
1329
|
+
if query is not None:
|
|
1330
|
+
__body["query"] = query
|
|
1331
|
+
if slice is not None:
|
|
1332
|
+
__body["slice"] = slice
|
|
1311
1333
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
1312
1334
|
return self.perform_request( # type: ignore[return-value]
|
|
1313
1335
|
"POST", __path, params=__query, headers=__headers, body=__body
|
|
@@ -1327,7 +1349,7 @@ class Elasticsearch(BaseClient):
|
|
|
1327
1349
|
"""
|
|
1328
1350
|
Changes the number of requests per second for a particular Delete By Query operation.
|
|
1329
1351
|
|
|
1330
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1352
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-delete-by-query.html>`_
|
|
1331
1353
|
|
|
1332
1354
|
:param task_id: The ID for the task.
|
|
1333
1355
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
@@ -1369,7 +1391,7 @@ class Elasticsearch(BaseClient):
|
|
|
1369
1391
|
"""
|
|
1370
1392
|
Deletes a script.
|
|
1371
1393
|
|
|
1372
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1394
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
|
|
1373
1395
|
|
|
1374
1396
|
:param id: Identifier for the stored script or search template.
|
|
1375
1397
|
:param master_timeout: Period to wait for a connection to the master node. If
|
|
@@ -1431,7 +1453,7 @@ class Elasticsearch(BaseClient):
|
|
|
1431
1453
|
"""
|
|
1432
1454
|
Returns information about whether a document exists in an index.
|
|
1433
1455
|
|
|
1434
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1456
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
|
|
1435
1457
|
|
|
1436
1458
|
:param index: Comma-separated list of data streams, indices, and aliases. Supports
|
|
1437
1459
|
wildcards (`*`).
|
|
@@ -1526,7 +1548,7 @@ class Elasticsearch(BaseClient):
|
|
|
1526
1548
|
"""
|
|
1527
1549
|
Returns information about whether a document source exists in an index.
|
|
1528
1550
|
|
|
1529
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1551
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
|
|
1530
1552
|
|
|
1531
1553
|
:param index: Comma-separated list of data streams, indices, and aliases. Supports
|
|
1532
1554
|
wildcards (`*`).
|
|
@@ -1586,7 +1608,7 @@ class Elasticsearch(BaseClient):
|
|
|
1586
1608
|
)
|
|
1587
1609
|
|
|
1588
1610
|
@_rewrite_parameters(
|
|
1589
|
-
body_fields=
|
|
1611
|
+
body_fields=("query",),
|
|
1590
1612
|
parameter_aliases={
|
|
1591
1613
|
"_source": "source",
|
|
1592
1614
|
"_source_excludes": "source_excludes",
|
|
@@ -1615,11 +1637,12 @@ class Elasticsearch(BaseClient):
|
|
|
1615
1637
|
source_excludes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
1616
1638
|
source_includes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
1617
1639
|
stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
1640
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
1618
1641
|
) -> ObjectApiResponse[t.Any]:
|
|
1619
1642
|
"""
|
|
1620
1643
|
Returns information about why a specific matches (or doesn't match) a query.
|
|
1621
1644
|
|
|
1622
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1645
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-explain.html>`_
|
|
1623
1646
|
|
|
1624
1647
|
:param index: Index names used to limit the request. Only a single index name
|
|
1625
1648
|
can be provided to this parameter.
|
|
@@ -1653,7 +1676,7 @@ class Elasticsearch(BaseClient):
|
|
|
1653
1676
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
1654
1677
|
__path = f"/{_quote(index)}/_explain/{_quote(id)}"
|
|
1655
1678
|
__query: t.Dict[str, t.Any] = {}
|
|
1656
|
-
__body: t.Dict[str, t.Any] = {}
|
|
1679
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
1657
1680
|
if analyze_wildcard is not None:
|
|
1658
1681
|
__query["analyze_wildcard"] = analyze_wildcard
|
|
1659
1682
|
if analyzer is not None:
|
|
@@ -1676,8 +1699,6 @@ class Elasticsearch(BaseClient):
|
|
|
1676
1699
|
__query["pretty"] = pretty
|
|
1677
1700
|
if q is not None:
|
|
1678
1701
|
__query["q"] = q
|
|
1679
|
-
if query is not None:
|
|
1680
|
-
__body["query"] = query
|
|
1681
1702
|
if routing is not None:
|
|
1682
1703
|
__query["routing"] = routing
|
|
1683
1704
|
if source is not None:
|
|
@@ -1688,6 +1709,9 @@ class Elasticsearch(BaseClient):
|
|
|
1688
1709
|
__query["_source_includes"] = source_includes
|
|
1689
1710
|
if stored_fields is not None:
|
|
1690
1711
|
__query["stored_fields"] = stored_fields
|
|
1712
|
+
if not __body:
|
|
1713
|
+
if query is not None:
|
|
1714
|
+
__body["query"] = query
|
|
1691
1715
|
if not __body:
|
|
1692
1716
|
__body = None # type: ignore[assignment]
|
|
1693
1717
|
__headers = {"accept": "application/json"}
|
|
@@ -1698,7 +1722,7 @@ class Elasticsearch(BaseClient):
|
|
|
1698
1722
|
)
|
|
1699
1723
|
|
|
1700
1724
|
@_rewrite_parameters(
|
|
1701
|
-
body_fields=
|
|
1725
|
+
body_fields=("fields", "index_filter", "runtime_mappings"),
|
|
1702
1726
|
)
|
|
1703
1727
|
def field_caps(
|
|
1704
1728
|
self,
|
|
@@ -1724,11 +1748,12 @@ class Elasticsearch(BaseClient):
|
|
|
1724
1748
|
pretty: t.Optional[bool] = None,
|
|
1725
1749
|
runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
|
|
1726
1750
|
types: t.Optional[t.Sequence[str]] = None,
|
|
1751
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
1727
1752
|
) -> ObjectApiResponse[t.Any]:
|
|
1728
1753
|
"""
|
|
1729
1754
|
Returns the information about the capabilities of fields among multiple indices.
|
|
1730
1755
|
|
|
1731
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1756
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-field-caps.html>`_
|
|
1732
1757
|
|
|
1733
1758
|
:param index: Comma-separated list of data streams, indices, and aliases used
|
|
1734
1759
|
to limit the request. Supports wildcards (*). To target all data streams
|
|
@@ -1762,15 +1787,13 @@ class Elasticsearch(BaseClient):
|
|
|
1762
1787
|
else:
|
|
1763
1788
|
__path = "/_field_caps"
|
|
1764
1789
|
__query: t.Dict[str, t.Any] = {}
|
|
1765
|
-
__body: t.Dict[str, t.Any] = {}
|
|
1790
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
1766
1791
|
if allow_no_indices is not None:
|
|
1767
1792
|
__query["allow_no_indices"] = allow_no_indices
|
|
1768
1793
|
if error_trace is not None:
|
|
1769
1794
|
__query["error_trace"] = error_trace
|
|
1770
1795
|
if expand_wildcards is not None:
|
|
1771
1796
|
__query["expand_wildcards"] = expand_wildcards
|
|
1772
|
-
if fields is not None:
|
|
1773
|
-
__body["fields"] = fields
|
|
1774
1797
|
if filter_path is not None:
|
|
1775
1798
|
__query["filter_path"] = filter_path
|
|
1776
1799
|
if filters is not None:
|
|
@@ -1781,14 +1804,17 @@ class Elasticsearch(BaseClient):
|
|
|
1781
1804
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
1782
1805
|
if include_unmapped is not None:
|
|
1783
1806
|
__query["include_unmapped"] = include_unmapped
|
|
1784
|
-
if index_filter is not None:
|
|
1785
|
-
__body["index_filter"] = index_filter
|
|
1786
1807
|
if pretty is not None:
|
|
1787
1808
|
__query["pretty"] = pretty
|
|
1788
|
-
if runtime_mappings is not None:
|
|
1789
|
-
__body["runtime_mappings"] = runtime_mappings
|
|
1790
1809
|
if types is not None:
|
|
1791
1810
|
__query["types"] = types
|
|
1811
|
+
if not __body:
|
|
1812
|
+
if fields is not None:
|
|
1813
|
+
__body["fields"] = fields
|
|
1814
|
+
if index_filter is not None:
|
|
1815
|
+
__body["index_filter"] = index_filter
|
|
1816
|
+
if runtime_mappings is not None:
|
|
1817
|
+
__body["runtime_mappings"] = runtime_mappings
|
|
1792
1818
|
if not __body:
|
|
1793
1819
|
__body = None # type: ignore[assignment]
|
|
1794
1820
|
__headers = {"accept": "application/json"}
|
|
@@ -1830,7 +1856,7 @@ class Elasticsearch(BaseClient):
|
|
|
1830
1856
|
"""
|
|
1831
1857
|
Returns a document.
|
|
1832
1858
|
|
|
1833
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1859
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
|
|
1834
1860
|
|
|
1835
1861
|
:param index: Name of the index that contains the document.
|
|
1836
1862
|
:param id: Unique identifier of the document.
|
|
@@ -1909,7 +1935,7 @@ class Elasticsearch(BaseClient):
|
|
|
1909
1935
|
"""
|
|
1910
1936
|
Returns a script.
|
|
1911
1937
|
|
|
1912
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
1938
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
|
|
1913
1939
|
|
|
1914
1940
|
:param id: Identifier for the stored script or search template.
|
|
1915
1941
|
:param master_timeout: Specify timeout for connection to master
|
|
@@ -1945,7 +1971,7 @@ class Elasticsearch(BaseClient):
|
|
|
1945
1971
|
"""
|
|
1946
1972
|
Returns all script contexts.
|
|
1947
1973
|
|
|
1948
|
-
`<https://www.elastic.co/guide/en/elasticsearch/painless/8.
|
|
1974
|
+
`<https://www.elastic.co/guide/en/elasticsearch/painless/8.12/painless-contexts.html>`_
|
|
1949
1975
|
"""
|
|
1950
1976
|
__path = "/_script_context"
|
|
1951
1977
|
__query: t.Dict[str, t.Any] = {}
|
|
@@ -1974,7 +2000,7 @@ class Elasticsearch(BaseClient):
|
|
|
1974
2000
|
"""
|
|
1975
2001
|
Returns available script types, languages and contexts
|
|
1976
2002
|
|
|
1977
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2003
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
|
|
1978
2004
|
"""
|
|
1979
2005
|
__path = "/_script_language"
|
|
1980
2006
|
__query: t.Dict[str, t.Any] = {}
|
|
@@ -2023,7 +2049,7 @@ class Elasticsearch(BaseClient):
|
|
|
2023
2049
|
"""
|
|
2024
2050
|
Returns the source of a document.
|
|
2025
2051
|
|
|
2026
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2052
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-get.html>`_
|
|
2027
2053
|
|
|
2028
2054
|
:param index: Name of the index that contains the document.
|
|
2029
2055
|
:param id: Unique identifier of the document.
|
|
@@ -2100,7 +2126,7 @@ class Elasticsearch(BaseClient):
|
|
|
2100
2126
|
"""
|
|
2101
2127
|
Returns the health of the cluster.
|
|
2102
2128
|
|
|
2103
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2129
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/health-api.html>`_
|
|
2104
2130
|
|
|
2105
2131
|
:param feature: A feature of the cluster, as returned by the top-level health
|
|
2106
2132
|
report API.
|
|
@@ -2139,7 +2165,8 @@ class Elasticsearch(BaseClient):
|
|
|
2139
2165
|
self,
|
|
2140
2166
|
*,
|
|
2141
2167
|
index: str,
|
|
2142
|
-
document: t.Mapping[str, t.Any],
|
|
2168
|
+
document: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2169
|
+
body: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2143
2170
|
id: t.Optional[str] = None,
|
|
2144
2171
|
error_trace: t.Optional[bool] = None,
|
|
2145
2172
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -2166,7 +2193,7 @@ class Elasticsearch(BaseClient):
|
|
|
2166
2193
|
"""
|
|
2167
2194
|
Creates or updates a document in an index.
|
|
2168
2195
|
|
|
2169
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2196
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-index_.html>`_
|
|
2170
2197
|
|
|
2171
2198
|
:param index: Name of the data stream or index to target.
|
|
2172
2199
|
:param document:
|
|
@@ -2203,8 +2230,12 @@ class Elasticsearch(BaseClient):
|
|
|
2203
2230
|
"""
|
|
2204
2231
|
if index in SKIP_IN_PATH:
|
|
2205
2232
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
2206
|
-
if document is None:
|
|
2207
|
-
raise ValueError(
|
|
2233
|
+
if document is None and body is None:
|
|
2234
|
+
raise ValueError(
|
|
2235
|
+
"Empty value passed for parameters 'document' and 'body', one of them should be set."
|
|
2236
|
+
)
|
|
2237
|
+
elif document is not None and body is not None:
|
|
2238
|
+
raise ValueError("Cannot set both 'document' and 'body'")
|
|
2208
2239
|
if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH:
|
|
2209
2240
|
__path = f"/{_quote(index)}/_doc/{_quote(id)}"
|
|
2210
2241
|
__method = "PUT"
|
|
@@ -2244,7 +2275,7 @@ class Elasticsearch(BaseClient):
|
|
|
2244
2275
|
__query["version_type"] = version_type
|
|
2245
2276
|
if wait_for_active_shards is not None:
|
|
2246
2277
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
2247
|
-
__body = document
|
|
2278
|
+
__body = document if document is not None else body
|
|
2248
2279
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
2249
2280
|
return self.perform_request( # type: ignore[return-value]
|
|
2250
2281
|
__method, __path, params=__query, headers=__headers, body=__body
|
|
@@ -2262,7 +2293,7 @@ class Elasticsearch(BaseClient):
|
|
|
2262
2293
|
"""
|
|
2263
2294
|
Returns basic information about the cluster.
|
|
2264
2295
|
|
|
2265
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2296
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/index.html>`_
|
|
2266
2297
|
"""
|
|
2267
2298
|
__path = "/"
|
|
2268
2299
|
__query: t.Dict[str, t.Any] = {}
|
|
@@ -2280,14 +2311,21 @@ class Elasticsearch(BaseClient):
|
|
|
2280
2311
|
)
|
|
2281
2312
|
|
|
2282
2313
|
@_rewrite_parameters(
|
|
2283
|
-
body_fields=
|
|
2314
|
+
body_fields=(
|
|
2315
|
+
"knn",
|
|
2316
|
+
"docvalue_fields",
|
|
2317
|
+
"fields",
|
|
2318
|
+
"filter",
|
|
2319
|
+
"source",
|
|
2320
|
+
"stored_fields",
|
|
2321
|
+
),
|
|
2284
2322
|
parameter_aliases={"_source": "source"},
|
|
2285
2323
|
)
|
|
2286
2324
|
def knn_search(
|
|
2287
2325
|
self,
|
|
2288
2326
|
*,
|
|
2289
2327
|
index: t.Union[str, t.Sequence[str]],
|
|
2290
|
-
knn: t.Mapping[str, t.Any],
|
|
2328
|
+
knn: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2291
2329
|
docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2292
2330
|
error_trace: t.Optional[bool] = None,
|
|
2293
2331
|
fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -2300,11 +2338,12 @@ class Elasticsearch(BaseClient):
|
|
|
2300
2338
|
routing: t.Optional[str] = None,
|
|
2301
2339
|
source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None,
|
|
2302
2340
|
stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2341
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2303
2342
|
) -> ObjectApiResponse[t.Any]:
|
|
2304
2343
|
"""
|
|
2305
2344
|
Performs a kNN search.
|
|
2306
2345
|
|
|
2307
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2346
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-search.html>`_
|
|
2308
2347
|
|
|
2309
2348
|
:param index: A comma-separated list of index names to search; use `_all` or
|
|
2310
2349
|
to perform the operation on all indices
|
|
@@ -2329,21 +2368,13 @@ class Elasticsearch(BaseClient):
|
|
|
2329
2368
|
"""
|
|
2330
2369
|
if index in SKIP_IN_PATH:
|
|
2331
2370
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
2332
|
-
if knn is None:
|
|
2371
|
+
if knn is None and body is None:
|
|
2333
2372
|
raise ValueError("Empty value passed for parameter 'knn'")
|
|
2334
2373
|
__path = f"/{_quote(index)}/_knn_search"
|
|
2335
|
-
__body: t.Dict[str, t.Any] = {}
|
|
2336
2374
|
__query: t.Dict[str, t.Any] = {}
|
|
2337
|
-
if
|
|
2338
|
-
__body["knn"] = knn
|
|
2339
|
-
if docvalue_fields is not None:
|
|
2340
|
-
__body["docvalue_fields"] = docvalue_fields
|
|
2375
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
2341
2376
|
if error_trace is not None:
|
|
2342
2377
|
__query["error_trace"] = error_trace
|
|
2343
|
-
if fields is not None:
|
|
2344
|
-
__body["fields"] = fields
|
|
2345
|
-
if filter is not None:
|
|
2346
|
-
__body["filter"] = filter
|
|
2347
2378
|
if filter_path is not None:
|
|
2348
2379
|
__query["filter_path"] = filter_path
|
|
2349
2380
|
if human is not None:
|
|
@@ -2352,10 +2383,19 @@ class Elasticsearch(BaseClient):
|
|
|
2352
2383
|
__query["pretty"] = pretty
|
|
2353
2384
|
if routing is not None:
|
|
2354
2385
|
__query["routing"] = routing
|
|
2355
|
-
if
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2386
|
+
if not __body:
|
|
2387
|
+
if knn is not None:
|
|
2388
|
+
__body["knn"] = knn
|
|
2389
|
+
if docvalue_fields is not None:
|
|
2390
|
+
__body["docvalue_fields"] = docvalue_fields
|
|
2391
|
+
if fields is not None:
|
|
2392
|
+
__body["fields"] = fields
|
|
2393
|
+
if filter is not None:
|
|
2394
|
+
__body["filter"] = filter
|
|
2395
|
+
if source is not None:
|
|
2396
|
+
__body["_source"] = source
|
|
2397
|
+
if stored_fields is not None:
|
|
2398
|
+
__body["stored_fields"] = stored_fields
|
|
2359
2399
|
if not __body:
|
|
2360
2400
|
__body = None # type: ignore[assignment]
|
|
2361
2401
|
__headers = {"accept": "application/json"}
|
|
@@ -2366,7 +2406,7 @@ class Elasticsearch(BaseClient):
|
|
|
2366
2406
|
)
|
|
2367
2407
|
|
|
2368
2408
|
@_rewrite_parameters(
|
|
2369
|
-
body_fields=
|
|
2409
|
+
body_fields=("docs", "ids"),
|
|
2370
2410
|
parameter_aliases={
|
|
2371
2411
|
"_source": "source",
|
|
2372
2412
|
"_source_excludes": "source_excludes",
|
|
@@ -2391,11 +2431,12 @@ class Elasticsearch(BaseClient):
|
|
|
2391
2431
|
source_excludes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2392
2432
|
source_includes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2393
2433
|
stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2434
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2394
2435
|
) -> ObjectApiResponse[t.Any]:
|
|
2395
2436
|
"""
|
|
2396
2437
|
Allows to get multiple documents in one request.
|
|
2397
2438
|
|
|
2398
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2439
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-multi-get.html>`_
|
|
2399
2440
|
|
|
2400
2441
|
:param index: Name of the index to retrieve documents from when `ids` are specified,
|
|
2401
2442
|
or when a document in the `docs` array does not specify an index.
|
|
@@ -2426,18 +2467,14 @@ class Elasticsearch(BaseClient):
|
|
|
2426
2467
|
__path = f"/{_quote(index)}/_mget"
|
|
2427
2468
|
else:
|
|
2428
2469
|
__path = "/_mget"
|
|
2429
|
-
__body: t.Dict[str, t.Any] = {}
|
|
2430
2470
|
__query: t.Dict[str, t.Any] = {}
|
|
2431
|
-
if
|
|
2432
|
-
__body["docs"] = docs
|
|
2471
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
2433
2472
|
if error_trace is not None:
|
|
2434
2473
|
__query["error_trace"] = error_trace
|
|
2435
2474
|
if filter_path is not None:
|
|
2436
2475
|
__query["filter_path"] = filter_path
|
|
2437
2476
|
if human is not None:
|
|
2438
2477
|
__query["human"] = human
|
|
2439
|
-
if ids is not None:
|
|
2440
|
-
__body["ids"] = ids
|
|
2441
2478
|
if preference is not None:
|
|
2442
2479
|
__query["preference"] = preference
|
|
2443
2480
|
if pretty is not None:
|
|
@@ -2456,6 +2493,11 @@ class Elasticsearch(BaseClient):
|
|
|
2456
2493
|
__query["_source_includes"] = source_includes
|
|
2457
2494
|
if stored_fields is not None:
|
|
2458
2495
|
__query["stored_fields"] = stored_fields
|
|
2496
|
+
if not __body:
|
|
2497
|
+
if docs is not None:
|
|
2498
|
+
__body["docs"] = docs
|
|
2499
|
+
if ids is not None:
|
|
2500
|
+
__body["ids"] = ids
|
|
2459
2501
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
2460
2502
|
return self.perform_request( # type: ignore[return-value]
|
|
2461
2503
|
"POST", __path, params=__query, headers=__headers, body=__body
|
|
@@ -2467,7 +2509,8 @@ class Elasticsearch(BaseClient):
|
|
|
2467
2509
|
def msearch(
|
|
2468
2510
|
self,
|
|
2469
2511
|
*,
|
|
2470
|
-
searches: t.Sequence[t.Mapping[str, t.Any]],
|
|
2512
|
+
searches: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2513
|
+
body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2471
2514
|
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2472
2515
|
allow_no_indices: t.Optional[bool] = None,
|
|
2473
2516
|
ccs_minimize_roundtrips: t.Optional[bool] = None,
|
|
@@ -2498,7 +2541,7 @@ class Elasticsearch(BaseClient):
|
|
|
2498
2541
|
"""
|
|
2499
2542
|
Allows to execute several search operations in one request.
|
|
2500
2543
|
|
|
2501
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2544
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-multi-search.html>`_
|
|
2502
2545
|
|
|
2503
2546
|
:param searches:
|
|
2504
2547
|
:param index: Comma-separated list of data streams, indices, and index aliases
|
|
@@ -2536,8 +2579,12 @@ class Elasticsearch(BaseClient):
|
|
|
2536
2579
|
:param typed_keys: Specifies whether aggregation and suggester names should be
|
|
2537
2580
|
prefixed by their respective types in the response.
|
|
2538
2581
|
"""
|
|
2539
|
-
if searches is None:
|
|
2540
|
-
raise ValueError(
|
|
2582
|
+
if searches is None and body is None:
|
|
2583
|
+
raise ValueError(
|
|
2584
|
+
"Empty value passed for parameters 'searches' and 'body', one of them should be set."
|
|
2585
|
+
)
|
|
2586
|
+
elif searches is not None and body is not None:
|
|
2587
|
+
raise ValueError("Cannot set both 'searches' and 'body'")
|
|
2541
2588
|
if index not in SKIP_IN_PATH:
|
|
2542
2589
|
__path = f"/{_quote(index)}/_msearch"
|
|
2543
2590
|
else:
|
|
@@ -2575,7 +2622,7 @@ class Elasticsearch(BaseClient):
|
|
|
2575
2622
|
__query["search_type"] = search_type
|
|
2576
2623
|
if typed_keys is not None:
|
|
2577
2624
|
__query["typed_keys"] = typed_keys
|
|
2578
|
-
__body = searches
|
|
2625
|
+
__body = searches if searches is not None else body
|
|
2579
2626
|
__headers = {
|
|
2580
2627
|
"accept": "application/json",
|
|
2581
2628
|
"content-type": "application/x-ndjson",
|
|
@@ -2590,7 +2637,8 @@ class Elasticsearch(BaseClient):
|
|
|
2590
2637
|
def msearch_template(
|
|
2591
2638
|
self,
|
|
2592
2639
|
*,
|
|
2593
|
-
search_templates: t.Sequence[t.Mapping[str, t.Any]],
|
|
2640
|
+
search_templates: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2641
|
+
body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2594
2642
|
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2595
2643
|
ccs_minimize_roundtrips: t.Optional[bool] = None,
|
|
2596
2644
|
error_trace: t.Optional[bool] = None,
|
|
@@ -2607,7 +2655,7 @@ class Elasticsearch(BaseClient):
|
|
|
2607
2655
|
"""
|
|
2608
2656
|
Allows to execute several search template operations in one request.
|
|
2609
2657
|
|
|
2610
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2658
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-multi-search.html>`_
|
|
2611
2659
|
|
|
2612
2660
|
:param search_templates:
|
|
2613
2661
|
:param index: Comma-separated list of data streams, indices, and aliases to search.
|
|
@@ -2624,8 +2672,12 @@ class Elasticsearch(BaseClient):
|
|
|
2624
2672
|
:param typed_keys: If `true`, the response prefixes aggregation and suggester
|
|
2625
2673
|
names with their respective types.
|
|
2626
2674
|
"""
|
|
2627
|
-
if search_templates is None:
|
|
2628
|
-
raise ValueError(
|
|
2675
|
+
if search_templates is None and body is None:
|
|
2676
|
+
raise ValueError(
|
|
2677
|
+
"Empty value passed for parameters 'search_templates' and 'body', one of them should be set."
|
|
2678
|
+
)
|
|
2679
|
+
elif search_templates is not None and body is not None:
|
|
2680
|
+
raise ValueError("Cannot set both 'search_templates' and 'body'")
|
|
2629
2681
|
if index not in SKIP_IN_PATH:
|
|
2630
2682
|
__path = f"/{_quote(index)}/_msearch/template"
|
|
2631
2683
|
else:
|
|
@@ -2649,7 +2701,7 @@ class Elasticsearch(BaseClient):
|
|
|
2649
2701
|
__query["search_type"] = search_type
|
|
2650
2702
|
if typed_keys is not None:
|
|
2651
2703
|
__query["typed_keys"] = typed_keys
|
|
2652
|
-
__body = search_templates
|
|
2704
|
+
__body = search_templates if search_templates is not None else body
|
|
2653
2705
|
__headers = {
|
|
2654
2706
|
"accept": "application/json",
|
|
2655
2707
|
"content-type": "application/x-ndjson",
|
|
@@ -2659,7 +2711,7 @@ class Elasticsearch(BaseClient):
|
|
|
2659
2711
|
)
|
|
2660
2712
|
|
|
2661
2713
|
@_rewrite_parameters(
|
|
2662
|
-
body_fields=
|
|
2714
|
+
body_fields=("docs", "ids"),
|
|
2663
2715
|
)
|
|
2664
2716
|
def mtermvectors(
|
|
2665
2717
|
self,
|
|
@@ -2684,11 +2736,12 @@ class Elasticsearch(BaseClient):
|
|
|
2684
2736
|
version_type: t.Optional[
|
|
2685
2737
|
t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str]
|
|
2686
2738
|
] = None,
|
|
2739
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2687
2740
|
) -> ObjectApiResponse[t.Any]:
|
|
2688
2741
|
"""
|
|
2689
2742
|
Returns multiple termvectors in one request.
|
|
2690
2743
|
|
|
2691
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2744
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-multi-termvectors.html>`_
|
|
2692
2745
|
|
|
2693
2746
|
:param index: Name of the index that contains the documents.
|
|
2694
2747
|
:param docs: Array of existing or artificial documents.
|
|
@@ -2715,10 +2768,8 @@ class Elasticsearch(BaseClient):
|
|
|
2715
2768
|
__path = f"/{_quote(index)}/_mtermvectors"
|
|
2716
2769
|
else:
|
|
2717
2770
|
__path = "/_mtermvectors"
|
|
2718
|
-
__body: t.Dict[str, t.Any] = {}
|
|
2719
2771
|
__query: t.Dict[str, t.Any] = {}
|
|
2720
|
-
if
|
|
2721
|
-
__body["docs"] = docs
|
|
2772
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
2722
2773
|
if error_trace is not None:
|
|
2723
2774
|
__query["error_trace"] = error_trace
|
|
2724
2775
|
if field_statistics is not None:
|
|
@@ -2729,8 +2780,6 @@ class Elasticsearch(BaseClient):
|
|
|
2729
2780
|
__query["filter_path"] = filter_path
|
|
2730
2781
|
if human is not None:
|
|
2731
2782
|
__query["human"] = human
|
|
2732
|
-
if ids is not None:
|
|
2733
|
-
__body["ids"] = ids
|
|
2734
2783
|
if offsets is not None:
|
|
2735
2784
|
__query["offsets"] = offsets
|
|
2736
2785
|
if payloads is not None:
|
|
@@ -2751,6 +2800,11 @@ class Elasticsearch(BaseClient):
|
|
|
2751
2800
|
__query["version"] = version
|
|
2752
2801
|
if version_type is not None:
|
|
2753
2802
|
__query["version_type"] = version_type
|
|
2803
|
+
if not __body:
|
|
2804
|
+
if docs is not None:
|
|
2805
|
+
__body["docs"] = docs
|
|
2806
|
+
if ids is not None:
|
|
2807
|
+
__body["ids"] = ids
|
|
2754
2808
|
if not __body:
|
|
2755
2809
|
__body = None # type: ignore[assignment]
|
|
2756
2810
|
__headers = {"accept": "application/json"}
|
|
@@ -2785,7 +2839,7 @@ class Elasticsearch(BaseClient):
|
|
|
2785
2839
|
"""
|
|
2786
2840
|
Open a point in time that can be used in subsequent searches
|
|
2787
2841
|
|
|
2788
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2842
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/point-in-time-api.html>`_
|
|
2789
2843
|
|
|
2790
2844
|
:param index: A comma-separated list of index names to open point in time; use
|
|
2791
2845
|
`_all` or empty string to perform the operation on all indices
|
|
@@ -2830,13 +2884,13 @@ class Elasticsearch(BaseClient):
|
|
|
2830
2884
|
)
|
|
2831
2885
|
|
|
2832
2886
|
@_rewrite_parameters(
|
|
2833
|
-
body_fields=
|
|
2887
|
+
body_fields=("script",),
|
|
2834
2888
|
)
|
|
2835
2889
|
def put_script(
|
|
2836
2890
|
self,
|
|
2837
2891
|
*,
|
|
2838
2892
|
id: str,
|
|
2839
|
-
script: t.Mapping[str, t.Any],
|
|
2893
|
+
script: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2840
2894
|
context: t.Optional[str] = None,
|
|
2841
2895
|
error_trace: t.Optional[bool] = None,
|
|
2842
2896
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -2846,11 +2900,12 @@ class Elasticsearch(BaseClient):
|
|
|
2846
2900
|
] = None,
|
|
2847
2901
|
pretty: t.Optional[bool] = None,
|
|
2848
2902
|
timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
|
|
2903
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2849
2904
|
) -> ObjectApiResponse[t.Any]:
|
|
2850
2905
|
"""
|
|
2851
2906
|
Creates or updates a script.
|
|
2852
2907
|
|
|
2853
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2908
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/modules-scripting.html>`_
|
|
2854
2909
|
|
|
2855
2910
|
:param id: Identifier for the stored script or search template. Must be unique
|
|
2856
2911
|
within the cluster.
|
|
@@ -2867,7 +2922,7 @@ class Elasticsearch(BaseClient):
|
|
|
2867
2922
|
"""
|
|
2868
2923
|
if id in SKIP_IN_PATH:
|
|
2869
2924
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
2870
|
-
if script is None:
|
|
2925
|
+
if script is None and body is None:
|
|
2871
2926
|
raise ValueError("Empty value passed for parameter 'script'")
|
|
2872
2927
|
if id not in SKIP_IN_PATH and context not in SKIP_IN_PATH:
|
|
2873
2928
|
__path = f"/_scripts/{_quote(id)}/{_quote(context)}"
|
|
@@ -2875,10 +2930,8 @@ class Elasticsearch(BaseClient):
|
|
|
2875
2930
|
__path = f"/_scripts/{_quote(id)}"
|
|
2876
2931
|
else:
|
|
2877
2932
|
raise ValueError("Couldn't find a path for the given parameters")
|
|
2878
|
-
__body: t.Dict[str, t.Any] = {}
|
|
2879
2933
|
__query: t.Dict[str, t.Any] = {}
|
|
2880
|
-
if
|
|
2881
|
-
__body["script"] = script
|
|
2934
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
2882
2935
|
if error_trace is not None:
|
|
2883
2936
|
__query["error_trace"] = error_trace
|
|
2884
2937
|
if filter_path is not None:
|
|
@@ -2891,18 +2944,21 @@ class Elasticsearch(BaseClient):
|
|
|
2891
2944
|
__query["pretty"] = pretty
|
|
2892
2945
|
if timeout is not None:
|
|
2893
2946
|
__query["timeout"] = timeout
|
|
2947
|
+
if not __body:
|
|
2948
|
+
if script is not None:
|
|
2949
|
+
__body["script"] = script
|
|
2894
2950
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
2895
2951
|
return self.perform_request( # type: ignore[return-value]
|
|
2896
2952
|
"PUT", __path, params=__query, headers=__headers, body=__body
|
|
2897
2953
|
)
|
|
2898
2954
|
|
|
2899
2955
|
@_rewrite_parameters(
|
|
2900
|
-
body_fields=
|
|
2956
|
+
body_fields=("requests", "metric"),
|
|
2901
2957
|
)
|
|
2902
2958
|
def rank_eval(
|
|
2903
2959
|
self,
|
|
2904
2960
|
*,
|
|
2905
|
-
requests: t.Sequence[t.Mapping[str, t.Any]],
|
|
2961
|
+
requests: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2906
2962
|
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2907
2963
|
allow_no_indices: t.Optional[bool] = None,
|
|
2908
2964
|
error_trace: t.Optional[bool] = None,
|
|
@@ -2920,12 +2976,13 @@ class Elasticsearch(BaseClient):
|
|
|
2920
2976
|
metric: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2921
2977
|
pretty: t.Optional[bool] = None,
|
|
2922
2978
|
search_type: t.Optional[str] = None,
|
|
2979
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2923
2980
|
) -> ObjectApiResponse[t.Any]:
|
|
2924
2981
|
"""
|
|
2925
2982
|
Allows to evaluate the quality of ranked search results over a set of typical
|
|
2926
2983
|
search queries
|
|
2927
2984
|
|
|
2928
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
2985
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-rank-eval.html>`_
|
|
2929
2986
|
|
|
2930
2987
|
:param requests: A set of typical search requests, together with their provided
|
|
2931
2988
|
ratings.
|
|
@@ -2945,16 +3002,14 @@ class Elasticsearch(BaseClient):
|
|
|
2945
3002
|
:param metric: Definition of the evaluation metric to calculate.
|
|
2946
3003
|
:param search_type: Search operation type
|
|
2947
3004
|
"""
|
|
2948
|
-
if requests is None:
|
|
3005
|
+
if requests is None and body is None:
|
|
2949
3006
|
raise ValueError("Empty value passed for parameter 'requests'")
|
|
2950
3007
|
if index not in SKIP_IN_PATH:
|
|
2951
3008
|
__path = f"/{_quote(index)}/_rank_eval"
|
|
2952
3009
|
else:
|
|
2953
3010
|
__path = "/_rank_eval"
|
|
2954
|
-
__body: t.Dict[str, t.Any] = {}
|
|
2955
3011
|
__query: t.Dict[str, t.Any] = {}
|
|
2956
|
-
if
|
|
2957
|
-
__body["requests"] = requests
|
|
3012
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
2958
3013
|
if allow_no_indices is not None:
|
|
2959
3014
|
__query["allow_no_indices"] = allow_no_indices
|
|
2960
3015
|
if error_trace is not None:
|
|
@@ -2967,25 +3022,28 @@ class Elasticsearch(BaseClient):
|
|
|
2967
3022
|
__query["human"] = human
|
|
2968
3023
|
if ignore_unavailable is not None:
|
|
2969
3024
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
2970
|
-
if metric is not None:
|
|
2971
|
-
__body["metric"] = metric
|
|
2972
3025
|
if pretty is not None:
|
|
2973
3026
|
__query["pretty"] = pretty
|
|
2974
3027
|
if search_type is not None:
|
|
2975
3028
|
__query["search_type"] = search_type
|
|
3029
|
+
if not __body:
|
|
3030
|
+
if requests is not None:
|
|
3031
|
+
__body["requests"] = requests
|
|
3032
|
+
if metric is not None:
|
|
3033
|
+
__body["metric"] = metric
|
|
2976
3034
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
2977
3035
|
return self.perform_request( # type: ignore[return-value]
|
|
2978
3036
|
"POST", __path, params=__query, headers=__headers, body=__body
|
|
2979
3037
|
)
|
|
2980
3038
|
|
|
2981
3039
|
@_rewrite_parameters(
|
|
2982
|
-
body_fields=
|
|
3040
|
+
body_fields=("dest", "source", "conflicts", "max_docs", "script", "size"),
|
|
2983
3041
|
)
|
|
2984
3042
|
def reindex(
|
|
2985
3043
|
self,
|
|
2986
3044
|
*,
|
|
2987
|
-
dest: t.Mapping[str, t.Any],
|
|
2988
|
-
source: t.Mapping[str, t.Any],
|
|
3045
|
+
dest: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3046
|
+
source: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2989
3047
|
conflicts: t.Optional[t.Union["t.Literal['abort', 'proceed']", str]] = None,
|
|
2990
3048
|
error_trace: t.Optional[bool] = None,
|
|
2991
3049
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -3004,13 +3062,14 @@ class Elasticsearch(BaseClient):
|
|
|
3004
3062
|
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
|
|
3005
3063
|
] = None,
|
|
3006
3064
|
wait_for_completion: t.Optional[bool] = None,
|
|
3065
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3007
3066
|
) -> ObjectApiResponse[t.Any]:
|
|
3008
3067
|
"""
|
|
3009
3068
|
Allows to copy documents from one index to another, optionally filtering the
|
|
3010
3069
|
source documents by a query, changing the destination index settings, or fetching
|
|
3011
3070
|
the documents from a remote cluster.
|
|
3012
3071
|
|
|
3013
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
3072
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-reindex.html>`_
|
|
3014
3073
|
|
|
3015
3074
|
:param dest: The destination you are copying to.
|
|
3016
3075
|
:param source: The source you are copying from.
|
|
@@ -3036,27 +3095,19 @@ class Elasticsearch(BaseClient):
|
|
|
3036
3095
|
:param wait_for_completion: If `true`, the request blocks until the operation
|
|
3037
3096
|
is complete.
|
|
3038
3097
|
"""
|
|
3039
|
-
if dest is None:
|
|
3098
|
+
if dest is None and body is None:
|
|
3040
3099
|
raise ValueError("Empty value passed for parameter 'dest'")
|
|
3041
|
-
if source is None:
|
|
3100
|
+
if source is None and body is None:
|
|
3042
3101
|
raise ValueError("Empty value passed for parameter 'source'")
|
|
3043
3102
|
__path = "/_reindex"
|
|
3044
|
-
__body: t.Dict[str, t.Any] = {}
|
|
3045
3103
|
__query: t.Dict[str, t.Any] = {}
|
|
3046
|
-
if
|
|
3047
|
-
__body["dest"] = dest
|
|
3048
|
-
if source is not None:
|
|
3049
|
-
__body["source"] = source
|
|
3050
|
-
if conflicts is not None:
|
|
3051
|
-
__body["conflicts"] = conflicts
|
|
3104
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
3052
3105
|
if error_trace is not None:
|
|
3053
3106
|
__query["error_trace"] = error_trace
|
|
3054
3107
|
if filter_path is not None:
|
|
3055
3108
|
__query["filter_path"] = filter_path
|
|
3056
3109
|
if human is not None:
|
|
3057
3110
|
__query["human"] = human
|
|
3058
|
-
if max_docs is not None:
|
|
3059
|
-
__body["max_docs"] = max_docs
|
|
3060
3111
|
if pretty is not None:
|
|
3061
3112
|
__query["pretty"] = pretty
|
|
3062
3113
|
if refresh is not None:
|
|
@@ -3065,12 +3116,8 @@ class Elasticsearch(BaseClient):
|
|
|
3065
3116
|
__query["requests_per_second"] = requests_per_second
|
|
3066
3117
|
if require_alias is not None:
|
|
3067
3118
|
__query["require_alias"] = require_alias
|
|
3068
|
-
if script is not None:
|
|
3069
|
-
__body["script"] = script
|
|
3070
3119
|
if scroll is not None:
|
|
3071
3120
|
__query["scroll"] = scroll
|
|
3072
|
-
if size is not None:
|
|
3073
|
-
__body["size"] = size
|
|
3074
3121
|
if slices is not None:
|
|
3075
3122
|
__query["slices"] = slices
|
|
3076
3123
|
if timeout is not None:
|
|
@@ -3079,6 +3126,19 @@ class Elasticsearch(BaseClient):
|
|
|
3079
3126
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
3080
3127
|
if wait_for_completion is not None:
|
|
3081
3128
|
__query["wait_for_completion"] = wait_for_completion
|
|
3129
|
+
if not __body:
|
|
3130
|
+
if dest is not None:
|
|
3131
|
+
__body["dest"] = dest
|
|
3132
|
+
if source is not None:
|
|
3133
|
+
__body["source"] = source
|
|
3134
|
+
if conflicts is not None:
|
|
3135
|
+
__body["conflicts"] = conflicts
|
|
3136
|
+
if max_docs is not None:
|
|
3137
|
+
__body["max_docs"] = max_docs
|
|
3138
|
+
if script is not None:
|
|
3139
|
+
__body["script"] = script
|
|
3140
|
+
if size is not None:
|
|
3141
|
+
__body["size"] = size
|
|
3082
3142
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
3083
3143
|
return self.perform_request( # type: ignore[return-value]
|
|
3084
3144
|
"POST", __path, params=__query, headers=__headers, body=__body
|
|
@@ -3098,7 +3158,7 @@ class Elasticsearch(BaseClient):
|
|
|
3098
3158
|
"""
|
|
3099
3159
|
Changes the number of requests per second for a particular Reindex operation.
|
|
3100
3160
|
|
|
3101
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
3161
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-reindex.html>`_
|
|
3102
3162
|
|
|
3103
3163
|
:param task_id: Identifier for the task.
|
|
3104
3164
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
@@ -3124,7 +3184,7 @@ class Elasticsearch(BaseClient):
|
|
|
3124
3184
|
)
|
|
3125
3185
|
|
|
3126
3186
|
@_rewrite_parameters(
|
|
3127
|
-
body_fields=
|
|
3187
|
+
body_fields=("file", "params", "source"),
|
|
3128
3188
|
ignore_deprecated_options={"params"},
|
|
3129
3189
|
)
|
|
3130
3190
|
def render_search_template(
|
|
@@ -3138,11 +3198,12 @@ class Elasticsearch(BaseClient):
|
|
|
3138
3198
|
params: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3139
3199
|
pretty: t.Optional[bool] = None,
|
|
3140
3200
|
source: t.Optional[str] = None,
|
|
3201
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3141
3202
|
) -> ObjectApiResponse[t.Any]:
|
|
3142
3203
|
"""
|
|
3143
3204
|
Allows to use the Mustache language to pre-render a search definition.
|
|
3144
3205
|
|
|
3145
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
3206
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/render-search-template-api.html>`_
|
|
3146
3207
|
|
|
3147
3208
|
:param id: ID of the search template to render. If no `source` is specified,
|
|
3148
3209
|
this or the `id` request body parameter is required.
|
|
@@ -3158,21 +3219,22 @@ class Elasticsearch(BaseClient):
|
|
|
3158
3219
|
else:
|
|
3159
3220
|
__path = "/_render/template"
|
|
3160
3221
|
__query: t.Dict[str, t.Any] = {}
|
|
3161
|
-
__body: t.Dict[str, t.Any] = {}
|
|
3222
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
3162
3223
|
if error_trace is not None:
|
|
3163
3224
|
__query["error_trace"] = error_trace
|
|
3164
|
-
if file is not None:
|
|
3165
|
-
__body["file"] = file
|
|
3166
3225
|
if filter_path is not None:
|
|
3167
3226
|
__query["filter_path"] = filter_path
|
|
3168
3227
|
if human is not None:
|
|
3169
3228
|
__query["human"] = human
|
|
3170
|
-
if params is not None:
|
|
3171
|
-
__body["params"] = params
|
|
3172
3229
|
if pretty is not None:
|
|
3173
3230
|
__query["pretty"] = pretty
|
|
3174
|
-
if
|
|
3175
|
-
|
|
3231
|
+
if not __body:
|
|
3232
|
+
if file is not None:
|
|
3233
|
+
__body["file"] = file
|
|
3234
|
+
if params is not None:
|
|
3235
|
+
__body["params"] = params
|
|
3236
|
+
if source is not None:
|
|
3237
|
+
__body["source"] = source
|
|
3176
3238
|
if not __body:
|
|
3177
3239
|
__body = None # type: ignore[assignment]
|
|
3178
3240
|
__headers = {"accept": "application/json"}
|
|
@@ -3183,7 +3245,7 @@ class Elasticsearch(BaseClient):
|
|
|
3183
3245
|
)
|
|
3184
3246
|
|
|
3185
3247
|
@_rewrite_parameters(
|
|
3186
|
-
body_fields=
|
|
3248
|
+
body_fields=("context", "context_setup", "script"),
|
|
3187
3249
|
)
|
|
3188
3250
|
def scripts_painless_execute(
|
|
3189
3251
|
self,
|
|
@@ -3195,23 +3257,20 @@ class Elasticsearch(BaseClient):
|
|
|
3195
3257
|
human: t.Optional[bool] = None,
|
|
3196
3258
|
pretty: t.Optional[bool] = None,
|
|
3197
3259
|
script: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3260
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3198
3261
|
) -> ObjectApiResponse[t.Any]:
|
|
3199
3262
|
"""
|
|
3200
3263
|
Allows an arbitrary script to be executed and a result to be returned
|
|
3201
3264
|
|
|
3202
|
-
`<https://www.elastic.co/guide/en/elasticsearch/painless/8.
|
|
3265
|
+
`<https://www.elastic.co/guide/en/elasticsearch/painless/8.12/painless-execute-api.html>`_
|
|
3203
3266
|
|
|
3204
3267
|
:param context: The context that the script should run in.
|
|
3205
3268
|
:param context_setup: Additional parameters for the `context`.
|
|
3206
3269
|
:param script: The Painless script to execute.
|
|
3207
3270
|
"""
|
|
3208
3271
|
__path = "/_scripts/painless/_execute"
|
|
3209
|
-
__body: t.Dict[str, t.Any] = {}
|
|
3210
3272
|
__query: t.Dict[str, t.Any] = {}
|
|
3211
|
-
if
|
|
3212
|
-
__body["context"] = context
|
|
3213
|
-
if context_setup is not None:
|
|
3214
|
-
__body["context_setup"] = context_setup
|
|
3273
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
3215
3274
|
if error_trace is not None:
|
|
3216
3275
|
__query["error_trace"] = error_trace
|
|
3217
3276
|
if filter_path is not None:
|
|
@@ -3220,8 +3279,13 @@ class Elasticsearch(BaseClient):
|
|
|
3220
3279
|
__query["human"] = human
|
|
3221
3280
|
if pretty is not None:
|
|
3222
3281
|
__query["pretty"] = pretty
|
|
3223
|
-
if
|
|
3224
|
-
|
|
3282
|
+
if not __body:
|
|
3283
|
+
if context is not None:
|
|
3284
|
+
__body["context"] = context
|
|
3285
|
+
if context_setup is not None:
|
|
3286
|
+
__body["context_setup"] = context_setup
|
|
3287
|
+
if script is not None:
|
|
3288
|
+
__body["script"] = script
|
|
3225
3289
|
if not __body:
|
|
3226
3290
|
__body = None # type: ignore[assignment]
|
|
3227
3291
|
__headers = {"accept": "application/json"}
|
|
@@ -3232,23 +3296,24 @@ class Elasticsearch(BaseClient):
|
|
|
3232
3296
|
)
|
|
3233
3297
|
|
|
3234
3298
|
@_rewrite_parameters(
|
|
3235
|
-
body_fields=
|
|
3299
|
+
body_fields=("scroll_id", "scroll"),
|
|
3236
3300
|
)
|
|
3237
3301
|
def scroll(
|
|
3238
3302
|
self,
|
|
3239
3303
|
*,
|
|
3240
|
-
scroll_id: str,
|
|
3304
|
+
scroll_id: t.Optional[str] = None,
|
|
3241
3305
|
error_trace: t.Optional[bool] = None,
|
|
3242
3306
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
3243
3307
|
human: t.Optional[bool] = None,
|
|
3244
3308
|
pretty: t.Optional[bool] = None,
|
|
3245
3309
|
rest_total_hits_as_int: t.Optional[bool] = None,
|
|
3246
3310
|
scroll: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
|
|
3311
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3247
3312
|
) -> ObjectApiResponse[t.Any]:
|
|
3248
3313
|
"""
|
|
3249
3314
|
Allows to retrieve a large numbers of results from a single search request.
|
|
3250
3315
|
|
|
3251
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
3316
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-request-body.html#request-body-search-scroll>`_
|
|
3252
3317
|
|
|
3253
3318
|
:param scroll_id: Scroll ID of the search.
|
|
3254
3319
|
:param rest_total_hits_as_int: If true, the API response’s hit.total property
|
|
@@ -3256,13 +3321,11 @@ class Elasticsearch(BaseClient):
|
|
|
3256
3321
|
is returned as an object.
|
|
3257
3322
|
:param scroll: Period to retain the search context for scrolling.
|
|
3258
3323
|
"""
|
|
3259
|
-
if scroll_id is None:
|
|
3324
|
+
if scroll_id is None and body is None:
|
|
3260
3325
|
raise ValueError("Empty value passed for parameter 'scroll_id'")
|
|
3261
3326
|
__path = "/_search/scroll"
|
|
3262
|
-
__body: t.Dict[str, t.Any] = {}
|
|
3263
3327
|
__query: t.Dict[str, t.Any] = {}
|
|
3264
|
-
if
|
|
3265
|
-
__body["scroll_id"] = scroll_id
|
|
3328
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
3266
3329
|
if error_trace is not None:
|
|
3267
3330
|
__query["error_trace"] = error_trace
|
|
3268
3331
|
if filter_path is not None:
|
|
@@ -3273,8 +3336,11 @@ class Elasticsearch(BaseClient):
|
|
|
3273
3336
|
__query["pretty"] = pretty
|
|
3274
3337
|
if rest_total_hits_as_int is not None:
|
|
3275
3338
|
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
|
|
3276
|
-
if
|
|
3277
|
-
|
|
3339
|
+
if not __body:
|
|
3340
|
+
if scroll_id is not None:
|
|
3341
|
+
__body["scroll_id"] = scroll_id
|
|
3342
|
+
if scroll is not None:
|
|
3343
|
+
__body["scroll"] = scroll
|
|
3278
3344
|
if not __body:
|
|
3279
3345
|
__body = None # type: ignore[assignment]
|
|
3280
3346
|
__headers = {"accept": "application/json"}
|
|
@@ -3285,7 +3351,42 @@ class Elasticsearch(BaseClient):
|
|
|
3285
3351
|
)
|
|
3286
3352
|
|
|
3287
3353
|
@_rewrite_parameters(
|
|
3288
|
-
body_fields=
|
|
3354
|
+
body_fields=(
|
|
3355
|
+
"aggregations",
|
|
3356
|
+
"aggs",
|
|
3357
|
+
"collapse",
|
|
3358
|
+
"docvalue_fields",
|
|
3359
|
+
"explain",
|
|
3360
|
+
"ext",
|
|
3361
|
+
"fields",
|
|
3362
|
+
"from_",
|
|
3363
|
+
"highlight",
|
|
3364
|
+
"indices_boost",
|
|
3365
|
+
"knn",
|
|
3366
|
+
"min_score",
|
|
3367
|
+
"pit",
|
|
3368
|
+
"post_filter",
|
|
3369
|
+
"profile",
|
|
3370
|
+
"query",
|
|
3371
|
+
"rank",
|
|
3372
|
+
"rescore",
|
|
3373
|
+
"runtime_mappings",
|
|
3374
|
+
"script_fields",
|
|
3375
|
+
"search_after",
|
|
3376
|
+
"seq_no_primary_term",
|
|
3377
|
+
"size",
|
|
3378
|
+
"slice",
|
|
3379
|
+
"sort",
|
|
3380
|
+
"source",
|
|
3381
|
+
"stats",
|
|
3382
|
+
"stored_fields",
|
|
3383
|
+
"suggest",
|
|
3384
|
+
"terminate_after",
|
|
3385
|
+
"timeout",
|
|
3386
|
+
"track_scores",
|
|
3387
|
+
"track_total_hits",
|
|
3388
|
+
"version",
|
|
3389
|
+
),
|
|
3289
3390
|
parameter_aliases={
|
|
3290
3391
|
"_source": "source",
|
|
3291
3392
|
"_source_excludes": "source_excludes",
|
|
@@ -3386,11 +3487,12 @@ class Elasticsearch(BaseClient):
|
|
|
3386
3487
|
track_total_hits: t.Optional[t.Union[bool, int]] = None,
|
|
3387
3488
|
typed_keys: t.Optional[bool] = None,
|
|
3388
3489
|
version: t.Optional[bool] = None,
|
|
3490
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3389
3491
|
) -> ObjectApiResponse[t.Any]:
|
|
3390
3492
|
"""
|
|
3391
3493
|
Returns results matching a query.
|
|
3392
3494
|
|
|
3393
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
3495
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-search.html>`_
|
|
3394
3496
|
|
|
3395
3497
|
:param index: Comma-separated list of data streams, indices, and aliases to search.
|
|
3396
3498
|
Supports wildcards (`*`). To search all data streams and indices, omit this
|
|
@@ -3578,8 +3680,8 @@ class Elasticsearch(BaseClient):
|
|
|
3578
3680
|
__path = f"/{_quote(index)}/_search"
|
|
3579
3681
|
else:
|
|
3580
3682
|
__path = "/_search"
|
|
3581
|
-
__body: t.Dict[str, t.Any] = {}
|
|
3582
3683
|
__query: t.Dict[str, t.Any] = {}
|
|
3684
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
3583
3685
|
# The 'sort' parameter with a colon can't be encoded to the body.
|
|
3584
3686
|
if sort is not None and (
|
|
3585
3687
|
(isinstance(sort, str) and ":" in sort)
|
|
@@ -3591,10 +3693,6 @@ class Elasticsearch(BaseClient):
|
|
|
3591
3693
|
):
|
|
3592
3694
|
__query["sort"] = sort
|
|
3593
3695
|
sort = None
|
|
3594
|
-
if aggregations is not None:
|
|
3595
|
-
__body["aggregations"] = aggregations
|
|
3596
|
-
if aggs is not None:
|
|
3597
|
-
__body["aggs"] = aggs
|
|
3598
3696
|
if allow_no_indices is not None:
|
|
3599
3697
|
__query["allow_no_indices"] = allow_no_indices
|
|
3600
3698
|
if allow_partial_search_results is not None:
|
|
@@ -3607,104 +3705,50 @@ class Elasticsearch(BaseClient):
|
|
|
3607
3705
|
__query["batched_reduce_size"] = batched_reduce_size
|
|
3608
3706
|
if ccs_minimize_roundtrips is not None:
|
|
3609
3707
|
__query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips
|
|
3610
|
-
if collapse is not None:
|
|
3611
|
-
__body["collapse"] = collapse
|
|
3612
3708
|
if default_operator is not None:
|
|
3613
3709
|
__query["default_operator"] = default_operator
|
|
3614
3710
|
if df is not None:
|
|
3615
3711
|
__query["df"] = df
|
|
3616
|
-
if docvalue_fields is not None:
|
|
3617
|
-
__body["docvalue_fields"] = docvalue_fields
|
|
3618
3712
|
if error_trace is not None:
|
|
3619
3713
|
__query["error_trace"] = error_trace
|
|
3620
3714
|
if expand_wildcards is not None:
|
|
3621
3715
|
__query["expand_wildcards"] = expand_wildcards
|
|
3622
|
-
if explain is not None:
|
|
3623
|
-
__body["explain"] = explain
|
|
3624
|
-
if ext is not None:
|
|
3625
|
-
__body["ext"] = ext
|
|
3626
|
-
if fields is not None:
|
|
3627
|
-
__body["fields"] = fields
|
|
3628
3716
|
if filter_path is not None:
|
|
3629
3717
|
__query["filter_path"] = filter_path
|
|
3630
|
-
if from_ is not None:
|
|
3631
|
-
__body["from"] = from_
|
|
3632
|
-
if highlight is not None:
|
|
3633
|
-
__body["highlight"] = highlight
|
|
3634
3718
|
if human is not None:
|
|
3635
3719
|
__query["human"] = human
|
|
3636
3720
|
if ignore_throttled is not None:
|
|
3637
3721
|
__query["ignore_throttled"] = ignore_throttled
|
|
3638
3722
|
if ignore_unavailable is not None:
|
|
3639
3723
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
3640
|
-
if indices_boost is not None:
|
|
3641
|
-
__body["indices_boost"] = indices_boost
|
|
3642
|
-
if knn is not None:
|
|
3643
|
-
__body["knn"] = knn
|
|
3644
3724
|
if lenient is not None:
|
|
3645
3725
|
__query["lenient"] = lenient
|
|
3646
3726
|
if max_concurrent_shard_requests is not None:
|
|
3647
3727
|
__query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
|
|
3648
3728
|
if min_compatible_shard_node is not None:
|
|
3649
3729
|
__query["min_compatible_shard_node"] = min_compatible_shard_node
|
|
3650
|
-
if min_score is not None:
|
|
3651
|
-
__body["min_score"] = min_score
|
|
3652
|
-
if pit is not None:
|
|
3653
|
-
__body["pit"] = pit
|
|
3654
|
-
if post_filter is not None:
|
|
3655
|
-
__body["post_filter"] = post_filter
|
|
3656
3730
|
if pre_filter_shard_size is not None:
|
|
3657
3731
|
__query["pre_filter_shard_size"] = pre_filter_shard_size
|
|
3658
3732
|
if preference is not None:
|
|
3659
3733
|
__query["preference"] = preference
|
|
3660
3734
|
if pretty is not None:
|
|
3661
3735
|
__query["pretty"] = pretty
|
|
3662
|
-
if profile is not None:
|
|
3663
|
-
__body["profile"] = profile
|
|
3664
3736
|
if q is not None:
|
|
3665
3737
|
__query["q"] = q
|
|
3666
|
-
if query is not None:
|
|
3667
|
-
__body["query"] = query
|
|
3668
|
-
if rank is not None:
|
|
3669
|
-
__body["rank"] = rank
|
|
3670
3738
|
if request_cache is not None:
|
|
3671
3739
|
__query["request_cache"] = request_cache
|
|
3672
|
-
if rescore is not None:
|
|
3673
|
-
__body["rescore"] = rescore
|
|
3674
3740
|
if rest_total_hits_as_int is not None:
|
|
3675
3741
|
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
|
|
3676
3742
|
if routing is not None:
|
|
3677
3743
|
__query["routing"] = routing
|
|
3678
|
-
if runtime_mappings is not None:
|
|
3679
|
-
__body["runtime_mappings"] = runtime_mappings
|
|
3680
|
-
if script_fields is not None:
|
|
3681
|
-
__body["script_fields"] = script_fields
|
|
3682
3744
|
if scroll is not None:
|
|
3683
3745
|
__query["scroll"] = scroll
|
|
3684
|
-
if search_after is not None:
|
|
3685
|
-
__body["search_after"] = search_after
|
|
3686
3746
|
if search_type is not None:
|
|
3687
3747
|
__query["search_type"] = search_type
|
|
3688
|
-
if seq_no_primary_term is not None:
|
|
3689
|
-
__body["seq_no_primary_term"] = seq_no_primary_term
|
|
3690
|
-
if size is not None:
|
|
3691
|
-
__body["size"] = size
|
|
3692
|
-
if slice is not None:
|
|
3693
|
-
__body["slice"] = slice
|
|
3694
|
-
if sort is not None:
|
|
3695
|
-
__body["sort"] = sort
|
|
3696
|
-
if source is not None:
|
|
3697
|
-
__body["_source"] = source
|
|
3698
3748
|
if source_excludes is not None:
|
|
3699
3749
|
__query["_source_excludes"] = source_excludes
|
|
3700
3750
|
if source_includes is not None:
|
|
3701
3751
|
__query["_source_includes"] = source_includes
|
|
3702
|
-
if stats is not None:
|
|
3703
|
-
__body["stats"] = stats
|
|
3704
|
-
if stored_fields is not None:
|
|
3705
|
-
__body["stored_fields"] = stored_fields
|
|
3706
|
-
if suggest is not None:
|
|
3707
|
-
__body["suggest"] = suggest
|
|
3708
3752
|
if suggest_field is not None:
|
|
3709
3753
|
__query["suggest_field"] = suggest_field
|
|
3710
3754
|
if suggest_mode is not None:
|
|
@@ -3713,18 +3757,77 @@ class Elasticsearch(BaseClient):
|
|
|
3713
3757
|
__query["suggest_size"] = suggest_size
|
|
3714
3758
|
if suggest_text is not None:
|
|
3715
3759
|
__query["suggest_text"] = suggest_text
|
|
3716
|
-
if terminate_after is not None:
|
|
3717
|
-
__body["terminate_after"] = terminate_after
|
|
3718
|
-
if timeout is not None:
|
|
3719
|
-
__body["timeout"] = timeout
|
|
3720
|
-
if track_scores is not None:
|
|
3721
|
-
__body["track_scores"] = track_scores
|
|
3722
|
-
if track_total_hits is not None:
|
|
3723
|
-
__body["track_total_hits"] = track_total_hits
|
|
3724
3760
|
if typed_keys is not None:
|
|
3725
3761
|
__query["typed_keys"] = typed_keys
|
|
3726
|
-
if
|
|
3727
|
-
|
|
3762
|
+
if not __body:
|
|
3763
|
+
if aggregations is not None:
|
|
3764
|
+
__body["aggregations"] = aggregations
|
|
3765
|
+
if aggs is not None:
|
|
3766
|
+
__body["aggs"] = aggs
|
|
3767
|
+
if collapse is not None:
|
|
3768
|
+
__body["collapse"] = collapse
|
|
3769
|
+
if docvalue_fields is not None:
|
|
3770
|
+
__body["docvalue_fields"] = docvalue_fields
|
|
3771
|
+
if explain is not None:
|
|
3772
|
+
__body["explain"] = explain
|
|
3773
|
+
if ext is not None:
|
|
3774
|
+
__body["ext"] = ext
|
|
3775
|
+
if fields is not None:
|
|
3776
|
+
__body["fields"] = fields
|
|
3777
|
+
if from_ is not None:
|
|
3778
|
+
__body["from"] = from_
|
|
3779
|
+
if highlight is not None:
|
|
3780
|
+
__body["highlight"] = highlight
|
|
3781
|
+
if indices_boost is not None:
|
|
3782
|
+
__body["indices_boost"] = indices_boost
|
|
3783
|
+
if knn is not None:
|
|
3784
|
+
__body["knn"] = knn
|
|
3785
|
+
if min_score is not None:
|
|
3786
|
+
__body["min_score"] = min_score
|
|
3787
|
+
if pit is not None:
|
|
3788
|
+
__body["pit"] = pit
|
|
3789
|
+
if post_filter is not None:
|
|
3790
|
+
__body["post_filter"] = post_filter
|
|
3791
|
+
if profile is not None:
|
|
3792
|
+
__body["profile"] = profile
|
|
3793
|
+
if query is not None:
|
|
3794
|
+
__body["query"] = query
|
|
3795
|
+
if rank is not None:
|
|
3796
|
+
__body["rank"] = rank
|
|
3797
|
+
if rescore is not None:
|
|
3798
|
+
__body["rescore"] = rescore
|
|
3799
|
+
if runtime_mappings is not None:
|
|
3800
|
+
__body["runtime_mappings"] = runtime_mappings
|
|
3801
|
+
if script_fields is not None:
|
|
3802
|
+
__body["script_fields"] = script_fields
|
|
3803
|
+
if search_after is not None:
|
|
3804
|
+
__body["search_after"] = search_after
|
|
3805
|
+
if seq_no_primary_term is not None:
|
|
3806
|
+
__body["seq_no_primary_term"] = seq_no_primary_term
|
|
3807
|
+
if size is not None:
|
|
3808
|
+
__body["size"] = size
|
|
3809
|
+
if slice is not None:
|
|
3810
|
+
__body["slice"] = slice
|
|
3811
|
+
if sort is not None:
|
|
3812
|
+
__body["sort"] = sort
|
|
3813
|
+
if source is not None:
|
|
3814
|
+
__body["_source"] = source
|
|
3815
|
+
if stats is not None:
|
|
3816
|
+
__body["stats"] = stats
|
|
3817
|
+
if stored_fields is not None:
|
|
3818
|
+
__body["stored_fields"] = stored_fields
|
|
3819
|
+
if suggest is not None:
|
|
3820
|
+
__body["suggest"] = suggest
|
|
3821
|
+
if terminate_after is not None:
|
|
3822
|
+
__body["terminate_after"] = terminate_after
|
|
3823
|
+
if timeout is not None:
|
|
3824
|
+
__body["timeout"] = timeout
|
|
3825
|
+
if track_scores is not None:
|
|
3826
|
+
__body["track_scores"] = track_scores
|
|
3827
|
+
if track_total_hits is not None:
|
|
3828
|
+
__body["track_total_hits"] = track_total_hits
|
|
3829
|
+
if version is not None:
|
|
3830
|
+
__body["version"] = version
|
|
3728
3831
|
if not __body:
|
|
3729
3832
|
__body = None # type: ignore[assignment]
|
|
3730
3833
|
__headers = {"accept": "application/json"}
|
|
@@ -3735,7 +3838,22 @@ class Elasticsearch(BaseClient):
|
|
|
3735
3838
|
)
|
|
3736
3839
|
|
|
3737
3840
|
@_rewrite_parameters(
|
|
3738
|
-
body_fields=
|
|
3841
|
+
body_fields=(
|
|
3842
|
+
"aggs",
|
|
3843
|
+
"buffer",
|
|
3844
|
+
"exact_bounds",
|
|
3845
|
+
"extent",
|
|
3846
|
+
"fields",
|
|
3847
|
+
"grid_agg",
|
|
3848
|
+
"grid_precision",
|
|
3849
|
+
"grid_type",
|
|
3850
|
+
"query",
|
|
3851
|
+
"runtime_mappings",
|
|
3852
|
+
"size",
|
|
3853
|
+
"sort",
|
|
3854
|
+
"track_total_hits",
|
|
3855
|
+
"with_labels",
|
|
3856
|
+
),
|
|
3739
3857
|
)
|
|
3740
3858
|
def search_mvt(
|
|
3741
3859
|
self,
|
|
@@ -3770,12 +3888,13 @@ class Elasticsearch(BaseClient):
|
|
|
3770
3888
|
] = None,
|
|
3771
3889
|
track_total_hits: t.Optional[t.Union[bool, int]] = None,
|
|
3772
3890
|
with_labels: t.Optional[bool] = None,
|
|
3891
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3773
3892
|
) -> BinaryApiResponse:
|
|
3774
3893
|
"""
|
|
3775
3894
|
Searches a vector tile for geospatial values. Returns results as a binary Mapbox
|
|
3776
3895
|
vector tile.
|
|
3777
3896
|
|
|
3778
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
3897
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-vector-tile-api.html>`_
|
|
3779
3898
|
|
|
3780
3899
|
:param index: Comma-separated list of data streams, indices, or aliases to search
|
|
3781
3900
|
:param field: Field containing geospatial data to return
|
|
@@ -3831,8 +3950,8 @@ class Elasticsearch(BaseClient):
|
|
|
3831
3950
|
if y in SKIP_IN_PATH:
|
|
3832
3951
|
raise ValueError("Empty value passed for parameter 'y'")
|
|
3833
3952
|
__path = f"/{_quote(index)}/_mvt/{_quote(field)}/{_quote(zoom)}/{_quote(x)}/{_quote(y)}"
|
|
3834
|
-
__body: t.Dict[str, t.Any] = {}
|
|
3835
3953
|
__query: t.Dict[str, t.Any] = {}
|
|
3954
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
3836
3955
|
# The 'sort' parameter with a colon can't be encoded to the body.
|
|
3837
3956
|
if sort is not None and (
|
|
3838
3957
|
(isinstance(sort, str) and ":" in sort)
|
|
@@ -3844,42 +3963,43 @@ class Elasticsearch(BaseClient):
|
|
|
3844
3963
|
):
|
|
3845
3964
|
__query["sort"] = sort
|
|
3846
3965
|
sort = None
|
|
3847
|
-
if aggs is not None:
|
|
3848
|
-
__body["aggs"] = aggs
|
|
3849
|
-
if buffer is not None:
|
|
3850
|
-
__body["buffer"] = buffer
|
|
3851
3966
|
if error_trace is not None:
|
|
3852
3967
|
__query["error_trace"] = error_trace
|
|
3853
|
-
if exact_bounds is not None:
|
|
3854
|
-
__body["exact_bounds"] = exact_bounds
|
|
3855
|
-
if extent is not None:
|
|
3856
|
-
__body["extent"] = extent
|
|
3857
|
-
if fields is not None:
|
|
3858
|
-
__body["fields"] = fields
|
|
3859
3968
|
if filter_path is not None:
|
|
3860
3969
|
__query["filter_path"] = filter_path
|
|
3861
|
-
if grid_agg is not None:
|
|
3862
|
-
__body["grid_agg"] = grid_agg
|
|
3863
|
-
if grid_precision is not None:
|
|
3864
|
-
__body["grid_precision"] = grid_precision
|
|
3865
|
-
if grid_type is not None:
|
|
3866
|
-
__body["grid_type"] = grid_type
|
|
3867
3970
|
if human is not None:
|
|
3868
3971
|
__query["human"] = human
|
|
3869
3972
|
if pretty is not None:
|
|
3870
3973
|
__query["pretty"] = pretty
|
|
3871
|
-
if
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3974
|
+
if not __body:
|
|
3975
|
+
if aggs is not None:
|
|
3976
|
+
__body["aggs"] = aggs
|
|
3977
|
+
if buffer is not None:
|
|
3978
|
+
__body["buffer"] = buffer
|
|
3979
|
+
if exact_bounds is not None:
|
|
3980
|
+
__body["exact_bounds"] = exact_bounds
|
|
3981
|
+
if extent is not None:
|
|
3982
|
+
__body["extent"] = extent
|
|
3983
|
+
if fields is not None:
|
|
3984
|
+
__body["fields"] = fields
|
|
3985
|
+
if grid_agg is not None:
|
|
3986
|
+
__body["grid_agg"] = grid_agg
|
|
3987
|
+
if grid_precision is not None:
|
|
3988
|
+
__body["grid_precision"] = grid_precision
|
|
3989
|
+
if grid_type is not None:
|
|
3990
|
+
__body["grid_type"] = grid_type
|
|
3991
|
+
if query is not None:
|
|
3992
|
+
__body["query"] = query
|
|
3993
|
+
if runtime_mappings is not None:
|
|
3994
|
+
__body["runtime_mappings"] = runtime_mappings
|
|
3995
|
+
if size is not None:
|
|
3996
|
+
__body["size"] = size
|
|
3997
|
+
if sort is not None:
|
|
3998
|
+
__body["sort"] = sort
|
|
3999
|
+
if track_total_hits is not None:
|
|
4000
|
+
__body["track_total_hits"] = track_total_hits
|
|
4001
|
+
if with_labels is not None:
|
|
4002
|
+
__body["with_labels"] = with_labels
|
|
3883
4003
|
if not __body:
|
|
3884
4004
|
__body = None # type: ignore[assignment]
|
|
3885
4005
|
__headers = {"accept": "application/vnd.mapbox-vector-tile"}
|
|
@@ -3916,7 +4036,7 @@ class Elasticsearch(BaseClient):
|
|
|
3916
4036
|
Returns information about the indices and shards that a search request would
|
|
3917
4037
|
be executed against.
|
|
3918
4038
|
|
|
3919
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4039
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-shards.html>`_
|
|
3920
4040
|
|
|
3921
4041
|
:param index: Returns the indices and shards that a search request would be executed
|
|
3922
4042
|
against.
|
|
@@ -3968,7 +4088,7 @@ class Elasticsearch(BaseClient):
|
|
|
3968
4088
|
)
|
|
3969
4089
|
|
|
3970
4090
|
@_rewrite_parameters(
|
|
3971
|
-
body_fields=
|
|
4091
|
+
body_fields=("explain", "id", "params", "profile", "source"),
|
|
3972
4092
|
ignore_deprecated_options={"params"},
|
|
3973
4093
|
)
|
|
3974
4094
|
def search_template(
|
|
@@ -4004,11 +4124,12 @@ class Elasticsearch(BaseClient):
|
|
|
4004
4124
|
] = None,
|
|
4005
4125
|
source: t.Optional[str] = None,
|
|
4006
4126
|
typed_keys: t.Optional[bool] = None,
|
|
4127
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4007
4128
|
) -> ObjectApiResponse[t.Any]:
|
|
4008
4129
|
"""
|
|
4009
4130
|
Allows to use the Mustache language to pre-render a search definition.
|
|
4010
4131
|
|
|
4011
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4132
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-template.html>`_
|
|
4012
4133
|
|
|
4013
4134
|
:param index: Comma-separated list of data streams, indices, and aliases to search.
|
|
4014
4135
|
Supports wildcards (*).
|
|
@@ -4053,7 +4174,7 @@ class Elasticsearch(BaseClient):
|
|
|
4053
4174
|
else:
|
|
4054
4175
|
__path = "/_search/template"
|
|
4055
4176
|
__query: t.Dict[str, t.Any] = {}
|
|
4056
|
-
__body: t.Dict[str, t.Any] = {}
|
|
4177
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
4057
4178
|
if allow_no_indices is not None:
|
|
4058
4179
|
__query["allow_no_indices"] = allow_no_indices
|
|
4059
4180
|
if ccs_minimize_roundtrips is not None:
|
|
@@ -4062,26 +4183,18 @@ class Elasticsearch(BaseClient):
|
|
|
4062
4183
|
__query["error_trace"] = error_trace
|
|
4063
4184
|
if expand_wildcards is not None:
|
|
4064
4185
|
__query["expand_wildcards"] = expand_wildcards
|
|
4065
|
-
if explain is not None:
|
|
4066
|
-
__body["explain"] = explain
|
|
4067
4186
|
if filter_path is not None:
|
|
4068
4187
|
__query["filter_path"] = filter_path
|
|
4069
4188
|
if human is not None:
|
|
4070
4189
|
__query["human"] = human
|
|
4071
|
-
if id is not None:
|
|
4072
|
-
__body["id"] = id
|
|
4073
4190
|
if ignore_throttled is not None:
|
|
4074
4191
|
__query["ignore_throttled"] = ignore_throttled
|
|
4075
4192
|
if ignore_unavailable is not None:
|
|
4076
4193
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
4077
|
-
if params is not None:
|
|
4078
|
-
__body["params"] = params
|
|
4079
4194
|
if preference is not None:
|
|
4080
4195
|
__query["preference"] = preference
|
|
4081
4196
|
if pretty is not None:
|
|
4082
4197
|
__query["pretty"] = pretty
|
|
4083
|
-
if profile is not None:
|
|
4084
|
-
__body["profile"] = profile
|
|
4085
4198
|
if rest_total_hits_as_int is not None:
|
|
4086
4199
|
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
|
|
4087
4200
|
if routing is not None:
|
|
@@ -4090,23 +4203,40 @@ class Elasticsearch(BaseClient):
|
|
|
4090
4203
|
__query["scroll"] = scroll
|
|
4091
4204
|
if search_type is not None:
|
|
4092
4205
|
__query["search_type"] = search_type
|
|
4093
|
-
if source is not None:
|
|
4094
|
-
__body["source"] = source
|
|
4095
4206
|
if typed_keys is not None:
|
|
4096
4207
|
__query["typed_keys"] = typed_keys
|
|
4208
|
+
if not __body:
|
|
4209
|
+
if explain is not None:
|
|
4210
|
+
__body["explain"] = explain
|
|
4211
|
+
if id is not None:
|
|
4212
|
+
__body["id"] = id
|
|
4213
|
+
if params is not None:
|
|
4214
|
+
__body["params"] = params
|
|
4215
|
+
if profile is not None:
|
|
4216
|
+
__body["profile"] = profile
|
|
4217
|
+
if source is not None:
|
|
4218
|
+
__body["source"] = source
|
|
4097
4219
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
4098
4220
|
return self.perform_request( # type: ignore[return-value]
|
|
4099
4221
|
"POST", __path, params=__query, headers=__headers, body=__body
|
|
4100
4222
|
)
|
|
4101
4223
|
|
|
4102
4224
|
@_rewrite_parameters(
|
|
4103
|
-
body_fields=
|
|
4225
|
+
body_fields=(
|
|
4226
|
+
"field",
|
|
4227
|
+
"case_insensitive",
|
|
4228
|
+
"index_filter",
|
|
4229
|
+
"search_after",
|
|
4230
|
+
"size",
|
|
4231
|
+
"string",
|
|
4232
|
+
"timeout",
|
|
4233
|
+
),
|
|
4104
4234
|
)
|
|
4105
4235
|
def terms_enum(
|
|
4106
4236
|
self,
|
|
4107
4237
|
*,
|
|
4108
4238
|
index: str,
|
|
4109
|
-
field: str,
|
|
4239
|
+
field: t.Optional[str] = None,
|
|
4110
4240
|
case_insensitive: t.Optional[bool] = None,
|
|
4111
4241
|
error_trace: t.Optional[bool] = None,
|
|
4112
4242
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -4117,13 +4247,14 @@ class Elasticsearch(BaseClient):
|
|
|
4117
4247
|
size: t.Optional[int] = None,
|
|
4118
4248
|
string: t.Optional[str] = None,
|
|
4119
4249
|
timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None,
|
|
4250
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4120
4251
|
) -> ObjectApiResponse[t.Any]:
|
|
4121
4252
|
"""
|
|
4122
4253
|
The terms enum API can be used to discover terms in the index that begin with
|
|
4123
4254
|
the provided string. It is designed for low-latency look-ups used in auto-complete
|
|
4124
4255
|
scenarios.
|
|
4125
4256
|
|
|
4126
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4257
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-terms-enum.html>`_
|
|
4127
4258
|
|
|
4128
4259
|
:param index: Comma-separated list of data streams, indices, and index aliases
|
|
4129
4260
|
to search. Wildcard (*) expressions are supported.
|
|
@@ -4144,33 +4275,34 @@ class Elasticsearch(BaseClient):
|
|
|
4144
4275
|
"""
|
|
4145
4276
|
if index in SKIP_IN_PATH:
|
|
4146
4277
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
4147
|
-
if field is None:
|
|
4278
|
+
if field is None and body is None:
|
|
4148
4279
|
raise ValueError("Empty value passed for parameter 'field'")
|
|
4149
4280
|
__path = f"/{_quote(index)}/_terms_enum"
|
|
4150
|
-
__body: t.Dict[str, t.Any] = {}
|
|
4151
4281
|
__query: t.Dict[str, t.Any] = {}
|
|
4152
|
-
if
|
|
4153
|
-
__body["field"] = field
|
|
4154
|
-
if case_insensitive is not None:
|
|
4155
|
-
__body["case_insensitive"] = case_insensitive
|
|
4282
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
4156
4283
|
if error_trace is not None:
|
|
4157
4284
|
__query["error_trace"] = error_trace
|
|
4158
4285
|
if filter_path is not None:
|
|
4159
4286
|
__query["filter_path"] = filter_path
|
|
4160
4287
|
if human is not None:
|
|
4161
4288
|
__query["human"] = human
|
|
4162
|
-
if index_filter is not None:
|
|
4163
|
-
__body["index_filter"] = index_filter
|
|
4164
4289
|
if pretty is not None:
|
|
4165
4290
|
__query["pretty"] = pretty
|
|
4166
|
-
if
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4291
|
+
if not __body:
|
|
4292
|
+
if field is not None:
|
|
4293
|
+
__body["field"] = field
|
|
4294
|
+
if case_insensitive is not None:
|
|
4295
|
+
__body["case_insensitive"] = case_insensitive
|
|
4296
|
+
if index_filter is not None:
|
|
4297
|
+
__body["index_filter"] = index_filter
|
|
4298
|
+
if search_after is not None:
|
|
4299
|
+
__body["search_after"] = search_after
|
|
4300
|
+
if size is not None:
|
|
4301
|
+
__body["size"] = size
|
|
4302
|
+
if string is not None:
|
|
4303
|
+
__body["string"] = string
|
|
4304
|
+
if timeout is not None:
|
|
4305
|
+
__body["timeout"] = timeout
|
|
4174
4306
|
if not __body:
|
|
4175
4307
|
__body = None # type: ignore[assignment]
|
|
4176
4308
|
__headers = {"accept": "application/json"}
|
|
@@ -4181,7 +4313,7 @@ class Elasticsearch(BaseClient):
|
|
|
4181
4313
|
)
|
|
4182
4314
|
|
|
4183
4315
|
@_rewrite_parameters(
|
|
4184
|
-
body_fields=
|
|
4316
|
+
body_fields=("doc", "filter", "per_field_analyzer"),
|
|
4185
4317
|
)
|
|
4186
4318
|
def termvectors(
|
|
4187
4319
|
self,
|
|
@@ -4208,12 +4340,13 @@ class Elasticsearch(BaseClient):
|
|
|
4208
4340
|
version_type: t.Optional[
|
|
4209
4341
|
t.Union["t.Literal['external', 'external_gte', 'force', 'internal']", str]
|
|
4210
4342
|
] = None,
|
|
4343
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4211
4344
|
) -> ObjectApiResponse[t.Any]:
|
|
4212
4345
|
"""
|
|
4213
4346
|
Returns information and statistics about terms in the fields of a particular
|
|
4214
4347
|
document.
|
|
4215
4348
|
|
|
4216
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4349
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-termvectors.html>`_
|
|
4217
4350
|
|
|
4218
4351
|
:param index: Name of the index that contains the document.
|
|
4219
4352
|
:param id: Unique identifier of the document.
|
|
@@ -4246,18 +4379,14 @@ class Elasticsearch(BaseClient):
|
|
|
4246
4379
|
__path = f"/{_quote(index)}/_termvectors"
|
|
4247
4380
|
else:
|
|
4248
4381
|
raise ValueError("Couldn't find a path for the given parameters")
|
|
4249
|
-
__body: t.Dict[str, t.Any] = {}
|
|
4250
4382
|
__query: t.Dict[str, t.Any] = {}
|
|
4251
|
-
if
|
|
4252
|
-
__body["doc"] = doc
|
|
4383
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
4253
4384
|
if error_trace is not None:
|
|
4254
4385
|
__query["error_trace"] = error_trace
|
|
4255
4386
|
if field_statistics is not None:
|
|
4256
4387
|
__query["field_statistics"] = field_statistics
|
|
4257
4388
|
if fields is not None:
|
|
4258
4389
|
__query["fields"] = fields
|
|
4259
|
-
if filter is not None:
|
|
4260
|
-
__body["filter"] = filter
|
|
4261
4390
|
if filter_path is not None:
|
|
4262
4391
|
__query["filter_path"] = filter_path
|
|
4263
4392
|
if human is not None:
|
|
@@ -4266,8 +4395,6 @@ class Elasticsearch(BaseClient):
|
|
|
4266
4395
|
__query["offsets"] = offsets
|
|
4267
4396
|
if payloads is not None:
|
|
4268
4397
|
__query["payloads"] = payloads
|
|
4269
|
-
if per_field_analyzer is not None:
|
|
4270
|
-
__body["per_field_analyzer"] = per_field_analyzer
|
|
4271
4398
|
if positions is not None:
|
|
4272
4399
|
__query["positions"] = positions
|
|
4273
4400
|
if preference is not None:
|
|
@@ -4284,6 +4411,13 @@ class Elasticsearch(BaseClient):
|
|
|
4284
4411
|
__query["version"] = version
|
|
4285
4412
|
if version_type is not None:
|
|
4286
4413
|
__query["version_type"] = version_type
|
|
4414
|
+
if not __body:
|
|
4415
|
+
if doc is not None:
|
|
4416
|
+
__body["doc"] = doc
|
|
4417
|
+
if filter is not None:
|
|
4418
|
+
__body["filter"] = filter
|
|
4419
|
+
if per_field_analyzer is not None:
|
|
4420
|
+
__body["per_field_analyzer"] = per_field_analyzer
|
|
4287
4421
|
if not __body:
|
|
4288
4422
|
__body = None # type: ignore[assignment]
|
|
4289
4423
|
__headers = {"accept": "application/json"}
|
|
@@ -4294,7 +4428,15 @@ class Elasticsearch(BaseClient):
|
|
|
4294
4428
|
)
|
|
4295
4429
|
|
|
4296
4430
|
@_rewrite_parameters(
|
|
4297
|
-
body_fields=
|
|
4431
|
+
body_fields=(
|
|
4432
|
+
"detect_noop",
|
|
4433
|
+
"doc",
|
|
4434
|
+
"doc_as_upsert",
|
|
4435
|
+
"script",
|
|
4436
|
+
"scripted_upsert",
|
|
4437
|
+
"source",
|
|
4438
|
+
"upsert",
|
|
4439
|
+
),
|
|
4298
4440
|
parameter_aliases={
|
|
4299
4441
|
"_source": "source",
|
|
4300
4442
|
"_source_excludes": "source_excludes",
|
|
@@ -4332,11 +4474,12 @@ class Elasticsearch(BaseClient):
|
|
|
4332
4474
|
wait_for_active_shards: t.Optional[
|
|
4333
4475
|
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
|
|
4334
4476
|
] = None,
|
|
4477
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4335
4478
|
) -> ObjectApiResponse[t.Any]:
|
|
4336
4479
|
"""
|
|
4337
4480
|
Updates a document with a script or partial document.
|
|
4338
4481
|
|
|
4339
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4482
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-update.html>`_
|
|
4340
4483
|
|
|
4341
4484
|
:param index: The name of the index
|
|
4342
4485
|
:param id: Document ID
|
|
@@ -4379,14 +4522,8 @@ class Elasticsearch(BaseClient):
|
|
|
4379
4522
|
if id in SKIP_IN_PATH:
|
|
4380
4523
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
4381
4524
|
__path = f"/{_quote(index)}/_update/{_quote(id)}"
|
|
4382
|
-
__body: t.Dict[str, t.Any] = {}
|
|
4383
4525
|
__query: t.Dict[str, t.Any] = {}
|
|
4384
|
-
if
|
|
4385
|
-
__body["detect_noop"] = detect_noop
|
|
4386
|
-
if doc is not None:
|
|
4387
|
-
__body["doc"] = doc
|
|
4388
|
-
if doc_as_upsert is not None:
|
|
4389
|
-
__body["doc_as_upsert"] = doc_as_upsert
|
|
4526
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
4390
4527
|
if error_trace is not None:
|
|
4391
4528
|
__query["error_trace"] = error_trace
|
|
4392
4529
|
if filter_path is not None:
|
|
@@ -4409,29 +4546,36 @@ class Elasticsearch(BaseClient):
|
|
|
4409
4546
|
__query["retry_on_conflict"] = retry_on_conflict
|
|
4410
4547
|
if routing is not None:
|
|
4411
4548
|
__query["routing"] = routing
|
|
4412
|
-
if script is not None:
|
|
4413
|
-
__body["script"] = script
|
|
4414
|
-
if scripted_upsert is not None:
|
|
4415
|
-
__body["scripted_upsert"] = scripted_upsert
|
|
4416
|
-
if source is not None:
|
|
4417
|
-
__body["_source"] = source
|
|
4418
4549
|
if source_excludes is not None:
|
|
4419
4550
|
__query["_source_excludes"] = source_excludes
|
|
4420
4551
|
if source_includes is not None:
|
|
4421
4552
|
__query["_source_includes"] = source_includes
|
|
4422
4553
|
if timeout is not None:
|
|
4423
4554
|
__query["timeout"] = timeout
|
|
4424
|
-
if upsert is not None:
|
|
4425
|
-
__body["upsert"] = upsert
|
|
4426
4555
|
if wait_for_active_shards is not None:
|
|
4427
4556
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
4557
|
+
if not __body:
|
|
4558
|
+
if detect_noop is not None:
|
|
4559
|
+
__body["detect_noop"] = detect_noop
|
|
4560
|
+
if doc is not None:
|
|
4561
|
+
__body["doc"] = doc
|
|
4562
|
+
if doc_as_upsert is not None:
|
|
4563
|
+
__body["doc_as_upsert"] = doc_as_upsert
|
|
4564
|
+
if script is not None:
|
|
4565
|
+
__body["script"] = script
|
|
4566
|
+
if scripted_upsert is not None:
|
|
4567
|
+
__body["scripted_upsert"] = scripted_upsert
|
|
4568
|
+
if source is not None:
|
|
4569
|
+
__body["_source"] = source
|
|
4570
|
+
if upsert is not None:
|
|
4571
|
+
__body["upsert"] = upsert
|
|
4428
4572
|
__headers = {"accept": "application/json", "content-type": "application/json"}
|
|
4429
4573
|
return self.perform_request( # type: ignore[return-value]
|
|
4430
4574
|
"POST", __path, params=__query, headers=__headers, body=__body
|
|
4431
4575
|
)
|
|
4432
4576
|
|
|
4433
4577
|
@_rewrite_parameters(
|
|
4434
|
-
body_fields=
|
|
4578
|
+
body_fields=("conflicts", "max_docs", "query", "script", "slice"),
|
|
4435
4579
|
parameter_aliases={"from": "from_"},
|
|
4436
4580
|
)
|
|
4437
4581
|
def update_by_query(
|
|
@@ -4488,12 +4632,13 @@ class Elasticsearch(BaseClient):
|
|
|
4488
4632
|
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
|
|
4489
4633
|
] = None,
|
|
4490
4634
|
wait_for_completion: t.Optional[bool] = None,
|
|
4635
|
+
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4491
4636
|
) -> ObjectApiResponse[t.Any]:
|
|
4492
4637
|
"""
|
|
4493
4638
|
Performs an update on every document in the index without changing the source,
|
|
4494
4639
|
for example to pick up a mapping change.
|
|
4495
4640
|
|
|
4496
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4641
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-update-by-query.html>`_
|
|
4497
4642
|
|
|
4498
4643
|
:param index: Comma-separated list of data streams, indices, and aliases to search.
|
|
4499
4644
|
Supports wildcards (`*`). To search all data streams or indices, omit this
|
|
@@ -4569,7 +4714,7 @@ class Elasticsearch(BaseClient):
|
|
|
4569
4714
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
4570
4715
|
__path = f"/{_quote(index)}/_update_by_query"
|
|
4571
4716
|
__query: t.Dict[str, t.Any] = {}
|
|
4572
|
-
__body: t.Dict[str, t.Any] = {}
|
|
4717
|
+
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
4573
4718
|
# The 'sort' parameter with a colon can't be encoded to the body.
|
|
4574
4719
|
if sort is not None and (
|
|
4575
4720
|
(isinstance(sort, str) and ":" in sort)
|
|
@@ -4587,8 +4732,6 @@ class Elasticsearch(BaseClient):
|
|
|
4587
4732
|
__query["analyze_wildcard"] = analyze_wildcard
|
|
4588
4733
|
if analyzer is not None:
|
|
4589
4734
|
__query["analyzer"] = analyzer
|
|
4590
|
-
if conflicts is not None:
|
|
4591
|
-
__body["conflicts"] = conflicts
|
|
4592
4735
|
if default_operator is not None:
|
|
4593
4736
|
__query["default_operator"] = default_operator
|
|
4594
4737
|
if df is not None:
|
|
@@ -4607,16 +4750,12 @@ class Elasticsearch(BaseClient):
|
|
|
4607
4750
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
4608
4751
|
if lenient is not None:
|
|
4609
4752
|
__query["lenient"] = lenient
|
|
4610
|
-
if max_docs is not None:
|
|
4611
|
-
__body["max_docs"] = max_docs
|
|
4612
4753
|
if pipeline is not None:
|
|
4613
4754
|
__query["pipeline"] = pipeline
|
|
4614
4755
|
if preference is not None:
|
|
4615
4756
|
__query["preference"] = preference
|
|
4616
4757
|
if pretty is not None:
|
|
4617
4758
|
__query["pretty"] = pretty
|
|
4618
|
-
if query is not None:
|
|
4619
|
-
__body["query"] = query
|
|
4620
4759
|
if refresh is not None:
|
|
4621
4760
|
__query["refresh"] = refresh
|
|
4622
4761
|
if request_cache is not None:
|
|
@@ -4625,8 +4764,6 @@ class Elasticsearch(BaseClient):
|
|
|
4625
4764
|
__query["requests_per_second"] = requests_per_second
|
|
4626
4765
|
if routing is not None:
|
|
4627
4766
|
__query["routing"] = routing
|
|
4628
|
-
if script is not None:
|
|
4629
|
-
__body["script"] = script
|
|
4630
4767
|
if scroll is not None:
|
|
4631
4768
|
__query["scroll"] = scroll
|
|
4632
4769
|
if scroll_size is not None:
|
|
@@ -4635,8 +4772,6 @@ class Elasticsearch(BaseClient):
|
|
|
4635
4772
|
__query["search_timeout"] = search_timeout
|
|
4636
4773
|
if search_type is not None:
|
|
4637
4774
|
__query["search_type"] = search_type
|
|
4638
|
-
if slice is not None:
|
|
4639
|
-
__body["slice"] = slice
|
|
4640
4775
|
if slices is not None:
|
|
4641
4776
|
__query["slices"] = slices
|
|
4642
4777
|
if sort is not None:
|
|
@@ -4655,6 +4790,17 @@ class Elasticsearch(BaseClient):
|
|
|
4655
4790
|
__query["wait_for_active_shards"] = wait_for_active_shards
|
|
4656
4791
|
if wait_for_completion is not None:
|
|
4657
4792
|
__query["wait_for_completion"] = wait_for_completion
|
|
4793
|
+
if not __body:
|
|
4794
|
+
if conflicts is not None:
|
|
4795
|
+
__body["conflicts"] = conflicts
|
|
4796
|
+
if max_docs is not None:
|
|
4797
|
+
__body["max_docs"] = max_docs
|
|
4798
|
+
if query is not None:
|
|
4799
|
+
__body["query"] = query
|
|
4800
|
+
if script is not None:
|
|
4801
|
+
__body["script"] = script
|
|
4802
|
+
if slice is not None:
|
|
4803
|
+
__body["slice"] = slice
|
|
4658
4804
|
if not __body:
|
|
4659
4805
|
__body = None # type: ignore[assignment]
|
|
4660
4806
|
__headers = {"accept": "application/json"}
|
|
@@ -4678,7 +4824,7 @@ class Elasticsearch(BaseClient):
|
|
|
4678
4824
|
"""
|
|
4679
4825
|
Changes the number of requests per second for a particular Update By Query operation.
|
|
4680
4826
|
|
|
4681
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.
|
|
4827
|
+
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/docs-update-by-query.html>`_
|
|
4682
4828
|
|
|
4683
4829
|
:param task_id: The ID for the task.
|
|
4684
4830
|
:param requests_per_second: The throttle for this request in sub-requests per
|