elasticsearch9 9.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. elasticsearch9/__init__.py +98 -0
  2. elasticsearch9/_async/__init__.py +16 -0
  3. elasticsearch9/_async/client/__init__.py +6531 -0
  4. elasticsearch9/_async/client/_base.py +430 -0
  5. elasticsearch9/_async/client/async_search.py +637 -0
  6. elasticsearch9/_async/client/autoscaling.py +252 -0
  7. elasticsearch9/_async/client/cat.py +2995 -0
  8. elasticsearch9/_async/client/ccr.py +1043 -0
  9. elasticsearch9/_async/client/cluster.py +1223 -0
  10. elasticsearch9/_async/client/connector.py +1978 -0
  11. elasticsearch9/_async/client/dangling_indices.py +192 -0
  12. elasticsearch9/_async/client/enrich.py +291 -0
  13. elasticsearch9/_async/client/eql.py +359 -0
  14. elasticsearch9/_async/client/esql.py +490 -0
  15. elasticsearch9/_async/client/features.py +130 -0
  16. elasticsearch9/_async/client/fleet.py +658 -0
  17. elasticsearch9/_async/client/graph.py +113 -0
  18. elasticsearch9/_async/client/ilm.py +668 -0
  19. elasticsearch9/_async/client/indices.py +5582 -0
  20. elasticsearch9/_async/client/inference.py +2247 -0
  21. elasticsearch9/_async/client/ingest.py +766 -0
  22. elasticsearch9/_async/client/license.py +400 -0
  23. elasticsearch9/_async/client/logstash.py +176 -0
  24. elasticsearch9/_async/client/migration.py +160 -0
  25. elasticsearch9/_async/client/ml.py +5835 -0
  26. elasticsearch9/_async/client/monitoring.py +100 -0
  27. elasticsearch9/_async/client/nodes.py +543 -0
  28. elasticsearch9/_async/client/query_rules.py +485 -0
  29. elasticsearch9/_async/client/rollup.py +616 -0
  30. elasticsearch9/_async/client/search_application.py +574 -0
  31. elasticsearch9/_async/client/searchable_snapshots.py +313 -0
  32. elasticsearch9/_async/client/security.py +4688 -0
  33. elasticsearch9/_async/client/shutdown.py +268 -0
  34. elasticsearch9/_async/client/simulate.py +145 -0
  35. elasticsearch9/_async/client/slm.py +559 -0
  36. elasticsearch9/_async/client/snapshot.py +1338 -0
  37. elasticsearch9/_async/client/sql.py +469 -0
  38. elasticsearch9/_async/client/ssl.py +76 -0
  39. elasticsearch9/_async/client/synonyms.py +413 -0
  40. elasticsearch9/_async/client/tasks.py +295 -0
  41. elasticsearch9/_async/client/text_structure.py +664 -0
  42. elasticsearch9/_async/client/transform.py +922 -0
  43. elasticsearch9/_async/client/utils.py +48 -0
  44. elasticsearch9/_async/client/watcher.py +894 -0
  45. elasticsearch9/_async/client/xpack.py +134 -0
  46. elasticsearch9/_async/helpers.py +596 -0
  47. elasticsearch9/_otel.py +110 -0
  48. elasticsearch9/_sync/__init__.py +16 -0
  49. elasticsearch9/_sync/client/__init__.py +6529 -0
  50. elasticsearch9/_sync/client/_base.py +430 -0
  51. elasticsearch9/_sync/client/async_search.py +637 -0
  52. elasticsearch9/_sync/client/autoscaling.py +252 -0
  53. elasticsearch9/_sync/client/cat.py +2995 -0
  54. elasticsearch9/_sync/client/ccr.py +1043 -0
  55. elasticsearch9/_sync/client/cluster.py +1223 -0
  56. elasticsearch9/_sync/client/connector.py +1978 -0
  57. elasticsearch9/_sync/client/dangling_indices.py +192 -0
  58. elasticsearch9/_sync/client/enrich.py +291 -0
  59. elasticsearch9/_sync/client/eql.py +359 -0
  60. elasticsearch9/_sync/client/esql.py +490 -0
  61. elasticsearch9/_sync/client/features.py +130 -0
  62. elasticsearch9/_sync/client/fleet.py +658 -0
  63. elasticsearch9/_sync/client/graph.py +113 -0
  64. elasticsearch9/_sync/client/ilm.py +668 -0
  65. elasticsearch9/_sync/client/indices.py +5582 -0
  66. elasticsearch9/_sync/client/inference.py +2247 -0
  67. elasticsearch9/_sync/client/ingest.py +766 -0
  68. elasticsearch9/_sync/client/license.py +400 -0
  69. elasticsearch9/_sync/client/logstash.py +176 -0
  70. elasticsearch9/_sync/client/migration.py +160 -0
  71. elasticsearch9/_sync/client/ml.py +5835 -0
  72. elasticsearch9/_sync/client/monitoring.py +100 -0
  73. elasticsearch9/_sync/client/nodes.py +543 -0
  74. elasticsearch9/_sync/client/query_rules.py +485 -0
  75. elasticsearch9/_sync/client/rollup.py +616 -0
  76. elasticsearch9/_sync/client/search_application.py +574 -0
  77. elasticsearch9/_sync/client/searchable_snapshots.py +313 -0
  78. elasticsearch9/_sync/client/security.py +4688 -0
  79. elasticsearch9/_sync/client/shutdown.py +268 -0
  80. elasticsearch9/_sync/client/simulate.py +145 -0
  81. elasticsearch9/_sync/client/slm.py +559 -0
  82. elasticsearch9/_sync/client/snapshot.py +1338 -0
  83. elasticsearch9/_sync/client/sql.py +469 -0
  84. elasticsearch9/_sync/client/ssl.py +76 -0
  85. elasticsearch9/_sync/client/synonyms.py +413 -0
  86. elasticsearch9/_sync/client/tasks.py +295 -0
  87. elasticsearch9/_sync/client/text_structure.py +664 -0
  88. elasticsearch9/_sync/client/transform.py +922 -0
  89. elasticsearch9/_sync/client/utils.py +475 -0
  90. elasticsearch9/_sync/client/watcher.py +894 -0
  91. elasticsearch9/_sync/client/xpack.py +134 -0
  92. elasticsearch9/_utils.py +34 -0
  93. elasticsearch9/_version.py +18 -0
  94. elasticsearch9/client.py +126 -0
  95. elasticsearch9/compat.py +79 -0
  96. elasticsearch9/dsl/__init__.py +203 -0
  97. elasticsearch9/dsl/_async/__init__.py +16 -0
  98. elasticsearch9/dsl/_async/document.py +522 -0
  99. elasticsearch9/dsl/_async/faceted_search.py +50 -0
  100. elasticsearch9/dsl/_async/index.py +639 -0
  101. elasticsearch9/dsl/_async/mapping.py +49 -0
  102. elasticsearch9/dsl/_async/search.py +237 -0
  103. elasticsearch9/dsl/_async/update_by_query.py +47 -0
  104. elasticsearch9/dsl/_sync/__init__.py +16 -0
  105. elasticsearch9/dsl/_sync/document.py +514 -0
  106. elasticsearch9/dsl/_sync/faceted_search.py +50 -0
  107. elasticsearch9/dsl/_sync/index.py +597 -0
  108. elasticsearch9/dsl/_sync/mapping.py +49 -0
  109. elasticsearch9/dsl/_sync/search.py +230 -0
  110. elasticsearch9/dsl/_sync/update_by_query.py +45 -0
  111. elasticsearch9/dsl/aggs.py +3734 -0
  112. elasticsearch9/dsl/analysis.py +341 -0
  113. elasticsearch9/dsl/async_connections.py +37 -0
  114. elasticsearch9/dsl/connections.py +142 -0
  115. elasticsearch9/dsl/document.py +20 -0
  116. elasticsearch9/dsl/document_base.py +444 -0
  117. elasticsearch9/dsl/exceptions.py +32 -0
  118. elasticsearch9/dsl/faceted_search.py +28 -0
  119. elasticsearch9/dsl/faceted_search_base.py +489 -0
  120. elasticsearch9/dsl/field.py +4392 -0
  121. elasticsearch9/dsl/function.py +180 -0
  122. elasticsearch9/dsl/index.py +23 -0
  123. elasticsearch9/dsl/index_base.py +178 -0
  124. elasticsearch9/dsl/mapping.py +19 -0
  125. elasticsearch9/dsl/mapping_base.py +219 -0
  126. elasticsearch9/dsl/query.py +2822 -0
  127. elasticsearch9/dsl/response/__init__.py +388 -0
  128. elasticsearch9/dsl/response/aggs.py +100 -0
  129. elasticsearch9/dsl/response/hit.py +53 -0
  130. elasticsearch9/dsl/search.py +20 -0
  131. elasticsearch9/dsl/search_base.py +1053 -0
  132. elasticsearch9/dsl/serializer.py +34 -0
  133. elasticsearch9/dsl/types.py +6453 -0
  134. elasticsearch9/dsl/update_by_query.py +19 -0
  135. elasticsearch9/dsl/update_by_query_base.py +149 -0
  136. elasticsearch9/dsl/utils.py +687 -0
  137. elasticsearch9/dsl/wrappers.py +144 -0
  138. elasticsearch9/exceptions.py +133 -0
  139. elasticsearch9/helpers/__init__.py +41 -0
  140. elasticsearch9/helpers/actions.py +875 -0
  141. elasticsearch9/helpers/errors.py +40 -0
  142. elasticsearch9/helpers/vectorstore/__init__.py +62 -0
  143. elasticsearch9/helpers/vectorstore/_async/__init__.py +16 -0
  144. elasticsearch9/helpers/vectorstore/_async/_utils.py +39 -0
  145. elasticsearch9/helpers/vectorstore/_async/embedding_service.py +89 -0
  146. elasticsearch9/helpers/vectorstore/_async/strategies.py +487 -0
  147. elasticsearch9/helpers/vectorstore/_async/vectorstore.py +421 -0
  148. elasticsearch9/helpers/vectorstore/_sync/__init__.py +16 -0
  149. elasticsearch9/helpers/vectorstore/_sync/_utils.py +39 -0
  150. elasticsearch9/helpers/vectorstore/_sync/embedding_service.py +89 -0
  151. elasticsearch9/helpers/vectorstore/_sync/strategies.py +487 -0
  152. elasticsearch9/helpers/vectorstore/_sync/vectorstore.py +421 -0
  153. elasticsearch9/helpers/vectorstore/_utils.py +116 -0
  154. elasticsearch9/py.typed +0 -0
  155. elasticsearch9/serializer.py +250 -0
  156. elasticsearch9-9.0.0.dist-info/METADATA +175 -0
  157. elasticsearch9-9.0.0.dist-info/RECORD +160 -0
  158. elasticsearch9-9.0.0.dist-info/WHEEL +4 -0
  159. elasticsearch9-9.0.0.dist-info/licenses/LICENSE +176 -0
  160. elasticsearch9-9.0.0.dist-info/licenses/NOTICE +2 -0
@@ -0,0 +1,658 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ import typing as t
19
+
20
+ from elastic_transport import ObjectApiResponse
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import (
24
+ SKIP_IN_PATH,
25
+ Stability,
26
+ _quote,
27
+ _rewrite_parameters,
28
+ _stability_warning,
29
+ )
30
+
31
+
32
+ class FleetClient(NamespacedClient):
33
+
34
+ @_rewrite_parameters()
35
+ def global_checkpoints(
36
+ self,
37
+ *,
38
+ index: str,
39
+ checkpoints: t.Optional[t.Sequence[int]] = None,
40
+ error_trace: t.Optional[bool] = None,
41
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
42
+ human: t.Optional[bool] = None,
43
+ pretty: t.Optional[bool] = None,
44
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
45
+ wait_for_advance: t.Optional[bool] = None,
46
+ wait_for_index: t.Optional[bool] = None,
47
+ ) -> ObjectApiResponse[t.Any]:
48
+ """
49
+ .. raw:: html
50
+
51
+ <p>Get global checkpoints.</p>
52
+ <p>Get the current global checkpoints for an index.
53
+ This API is designed for internal use by the Fleet server project.</p>
54
+
55
+
56
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/group/endpoint-fleet>`_
57
+
58
+ :param index: A single index or index alias that resolves to a single index.
59
+ :param checkpoints: A comma separated list of previous global checkpoints. When
60
+ used in combination with `wait_for_advance`, the API will only return once
61
+ the global checkpoints advances past the checkpoints. Providing an empty
62
+ list will cause Elasticsearch to immediately return the current global checkpoints.
63
+ :param timeout: Period to wait for a global checkpoints to advance past `checkpoints`.
64
+ :param wait_for_advance: A boolean value which controls whether to wait (until
65
+ the timeout) for the global checkpoints to advance past the provided `checkpoints`.
66
+ :param wait_for_index: A boolean value which controls whether to wait (until
67
+ the timeout) for the target index to exist and all primary shards be active.
68
+ Can only be true when `wait_for_advance` is true.
69
+ """
70
+ if index in SKIP_IN_PATH:
71
+ raise ValueError("Empty value passed for parameter 'index'")
72
+ __path_parts: t.Dict[str, str] = {"index": _quote(index)}
73
+ __path = f'/{__path_parts["index"]}/_fleet/global_checkpoints'
74
+ __query: t.Dict[str, t.Any] = {}
75
+ if checkpoints is not None:
76
+ __query["checkpoints"] = checkpoints
77
+ if error_trace is not None:
78
+ __query["error_trace"] = error_trace
79
+ if filter_path is not None:
80
+ __query["filter_path"] = filter_path
81
+ if human is not None:
82
+ __query["human"] = human
83
+ if pretty is not None:
84
+ __query["pretty"] = pretty
85
+ if timeout is not None:
86
+ __query["timeout"] = timeout
87
+ if wait_for_advance is not None:
88
+ __query["wait_for_advance"] = wait_for_advance
89
+ if wait_for_index is not None:
90
+ __query["wait_for_index"] = wait_for_index
91
+ __headers = {"accept": "application/json"}
92
+ return self.perform_request( # type: ignore[return-value]
93
+ "GET",
94
+ __path,
95
+ params=__query,
96
+ headers=__headers,
97
+ endpoint_id="fleet.global_checkpoints",
98
+ path_parts=__path_parts,
99
+ )
100
+
101
+ @_rewrite_parameters(
102
+ body_name="searches",
103
+ )
104
+ @_stability_warning(Stability.EXPERIMENTAL)
105
+ def msearch(
106
+ self,
107
+ *,
108
+ searches: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
109
+ body: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
110
+ index: t.Optional[str] = None,
111
+ allow_no_indices: t.Optional[bool] = None,
112
+ allow_partial_search_results: t.Optional[bool] = None,
113
+ ccs_minimize_roundtrips: t.Optional[bool] = None,
114
+ error_trace: t.Optional[bool] = None,
115
+ expand_wildcards: t.Optional[
116
+ t.Union[
117
+ t.Sequence[
118
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
119
+ ],
120
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
121
+ ]
122
+ ] = None,
123
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
124
+ human: t.Optional[bool] = None,
125
+ ignore_throttled: t.Optional[bool] = None,
126
+ ignore_unavailable: t.Optional[bool] = None,
127
+ max_concurrent_searches: t.Optional[int] = None,
128
+ max_concurrent_shard_requests: t.Optional[int] = None,
129
+ pre_filter_shard_size: t.Optional[int] = None,
130
+ pretty: t.Optional[bool] = None,
131
+ rest_total_hits_as_int: t.Optional[bool] = None,
132
+ search_type: t.Optional[
133
+ t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
134
+ ] = None,
135
+ typed_keys: t.Optional[bool] = None,
136
+ wait_for_checkpoints: t.Optional[t.Sequence[int]] = None,
137
+ ) -> ObjectApiResponse[t.Any]:
138
+ """
139
+ .. raw:: html
140
+
141
+ <p>Run multiple Fleet searches.
142
+ Run several Fleet searches with a single API request.
143
+ The API follows the same structure as the multi search API.
144
+ However, similar to the Fleet search API, it supports the <code>wait_for_checkpoints</code> parameter.</p>
145
+
146
+
147
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-fleet-msearch>`_
148
+
149
+ :param searches:
150
+ :param index: A single target to search. If the target is an index alias, it
151
+ must resolve to a single index.
152
+ :param allow_no_indices: If false, the request returns an error if any wildcard
153
+ expression, index alias, or _all value targets only missing or closed indices.
154
+ This behavior applies even if the request targets other open indices. For
155
+ example, a request targeting foo*,bar* returns an error if an index starts
156
+ with foo but no index starts with bar.
157
+ :param allow_partial_search_results: If true, returns partial results if there
158
+ are shard request timeouts or shard failures. If false, returns an error
159
+ with no partial results. Defaults to the configured cluster setting `search.default_allow_partial_results`,
160
+ which is true by default.
161
+ :param ccs_minimize_roundtrips: If true, network roundtrips between the coordinating
162
+ node and remote clusters are minimized for cross-cluster search requests.
163
+ :param expand_wildcards: Type of index that wildcard expressions can match. If
164
+ the request can target data streams, this argument determines whether wildcard
165
+ expressions match hidden data streams.
166
+ :param ignore_throttled: If true, concrete, expanded or aliased indices are ignored
167
+ when frozen.
168
+ :param ignore_unavailable: If true, missing or closed indices are not included
169
+ in the response.
170
+ :param max_concurrent_searches: Maximum number of concurrent searches the multi
171
+ search API can execute.
172
+ :param max_concurrent_shard_requests: Maximum number of concurrent shard requests
173
+ that each sub-search request executes per node.
174
+ :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
175
+ roundtrip to prefilter search shards based on query rewriting if the number
176
+ of shards the search request expands to exceeds the threshold. This filter
177
+ roundtrip can limit the number of shards significantly if for instance a
178
+ shard can not match any documents based on its rewrite method i.e., if date
179
+ filters are mandatory to match but the shard bounds and the query are disjoint.
180
+ :param rest_total_hits_as_int: If true, hits.total are returned as an integer
181
+ in the response. Defaults to false, which returns an object.
182
+ :param search_type: Indicates whether global term and document frequencies should
183
+ be used when scoring returned documents.
184
+ :param typed_keys: Specifies whether aggregation and suggester names should be
185
+ prefixed by their respective types in the response.
186
+ :param wait_for_checkpoints: A comma separated list of checkpoints. When configured,
187
+ the search API will only be executed on a shard after the relevant checkpoint
188
+ has become visible for search. Defaults to an empty list which will cause
189
+ Elasticsearch to immediately execute the search.
190
+ """
191
+ if searches is None and body is None:
192
+ raise ValueError(
193
+ "Empty value passed for parameters 'searches' and 'body', one of them should be set."
194
+ )
195
+ elif searches is not None and body is not None:
196
+ raise ValueError("Cannot set both 'searches' and 'body'")
197
+ __path_parts: t.Dict[str, str]
198
+ if index not in SKIP_IN_PATH:
199
+ __path_parts = {"index": _quote(index)}
200
+ __path = f'/{__path_parts["index"]}/_fleet/_fleet_msearch'
201
+ else:
202
+ __path_parts = {}
203
+ __path = "/_fleet/_fleet_msearch"
204
+ __query: t.Dict[str, t.Any] = {}
205
+ if allow_no_indices is not None:
206
+ __query["allow_no_indices"] = allow_no_indices
207
+ if allow_partial_search_results is not None:
208
+ __query["allow_partial_search_results"] = allow_partial_search_results
209
+ if ccs_minimize_roundtrips is not None:
210
+ __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips
211
+ if error_trace is not None:
212
+ __query["error_trace"] = error_trace
213
+ if expand_wildcards is not None:
214
+ __query["expand_wildcards"] = expand_wildcards
215
+ if filter_path is not None:
216
+ __query["filter_path"] = filter_path
217
+ if human is not None:
218
+ __query["human"] = human
219
+ if ignore_throttled is not None:
220
+ __query["ignore_throttled"] = ignore_throttled
221
+ if ignore_unavailable is not None:
222
+ __query["ignore_unavailable"] = ignore_unavailable
223
+ if max_concurrent_searches is not None:
224
+ __query["max_concurrent_searches"] = max_concurrent_searches
225
+ if max_concurrent_shard_requests is not None:
226
+ __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
227
+ if pre_filter_shard_size is not None:
228
+ __query["pre_filter_shard_size"] = pre_filter_shard_size
229
+ if pretty is not None:
230
+ __query["pretty"] = pretty
231
+ if rest_total_hits_as_int is not None:
232
+ __query["rest_total_hits_as_int"] = rest_total_hits_as_int
233
+ if search_type is not None:
234
+ __query["search_type"] = search_type
235
+ if typed_keys is not None:
236
+ __query["typed_keys"] = typed_keys
237
+ if wait_for_checkpoints is not None:
238
+ __query["wait_for_checkpoints"] = wait_for_checkpoints
239
+ __body = searches if searches is not None else body
240
+ __headers = {
241
+ "accept": "application/json",
242
+ "content-type": "application/x-ndjson",
243
+ }
244
+ return self.perform_request( # type: ignore[return-value]
245
+ "POST",
246
+ __path,
247
+ params=__query,
248
+ headers=__headers,
249
+ body=__body,
250
+ endpoint_id="fleet.msearch",
251
+ path_parts=__path_parts,
252
+ )
253
+
254
+ @_rewrite_parameters(
255
+ body_fields=(
256
+ "aggregations",
257
+ "aggs",
258
+ "collapse",
259
+ "docvalue_fields",
260
+ "explain",
261
+ "ext",
262
+ "fields",
263
+ "from_",
264
+ "highlight",
265
+ "indices_boost",
266
+ "min_score",
267
+ "pit",
268
+ "post_filter",
269
+ "profile",
270
+ "query",
271
+ "rescore",
272
+ "runtime_mappings",
273
+ "script_fields",
274
+ "search_after",
275
+ "seq_no_primary_term",
276
+ "size",
277
+ "slice",
278
+ "sort",
279
+ "source",
280
+ "stats",
281
+ "stored_fields",
282
+ "suggest",
283
+ "terminate_after",
284
+ "timeout",
285
+ "track_scores",
286
+ "track_total_hits",
287
+ "version",
288
+ ),
289
+ parameter_aliases={
290
+ "_source": "source",
291
+ "_source_excludes": "source_excludes",
292
+ "_source_includes": "source_includes",
293
+ "from": "from_",
294
+ },
295
+ )
296
+ @_stability_warning(Stability.EXPERIMENTAL)
297
+ def search(
298
+ self,
299
+ *,
300
+ index: str,
301
+ aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
302
+ aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
303
+ allow_no_indices: t.Optional[bool] = None,
304
+ allow_partial_search_results: t.Optional[bool] = None,
305
+ analyze_wildcard: t.Optional[bool] = None,
306
+ analyzer: t.Optional[str] = None,
307
+ batched_reduce_size: t.Optional[int] = None,
308
+ ccs_minimize_roundtrips: t.Optional[bool] = None,
309
+ collapse: t.Optional[t.Mapping[str, t.Any]] = None,
310
+ default_operator: t.Optional[t.Union[str, t.Literal["and", "or"]]] = None,
311
+ df: t.Optional[str] = None,
312
+ docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
313
+ error_trace: t.Optional[bool] = None,
314
+ expand_wildcards: t.Optional[
315
+ t.Union[
316
+ t.Sequence[
317
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
318
+ ],
319
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
320
+ ]
321
+ ] = None,
322
+ explain: t.Optional[bool] = None,
323
+ ext: t.Optional[t.Mapping[str, t.Any]] = None,
324
+ fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
325
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
326
+ from_: t.Optional[int] = None,
327
+ highlight: t.Optional[t.Mapping[str, t.Any]] = None,
328
+ human: t.Optional[bool] = None,
329
+ ignore_throttled: t.Optional[bool] = None,
330
+ ignore_unavailable: t.Optional[bool] = None,
331
+ indices_boost: t.Optional[t.Sequence[t.Mapping[str, float]]] = None,
332
+ lenient: t.Optional[bool] = None,
333
+ max_concurrent_shard_requests: t.Optional[int] = None,
334
+ min_score: t.Optional[float] = None,
335
+ pit: t.Optional[t.Mapping[str, t.Any]] = None,
336
+ post_filter: t.Optional[t.Mapping[str, t.Any]] = None,
337
+ pre_filter_shard_size: t.Optional[int] = None,
338
+ preference: t.Optional[str] = None,
339
+ pretty: t.Optional[bool] = None,
340
+ profile: t.Optional[bool] = None,
341
+ q: t.Optional[str] = None,
342
+ query: t.Optional[t.Mapping[str, t.Any]] = None,
343
+ request_cache: t.Optional[bool] = None,
344
+ rescore: t.Optional[
345
+ t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]]
346
+ ] = None,
347
+ rest_total_hits_as_int: t.Optional[bool] = None,
348
+ routing: t.Optional[str] = None,
349
+ runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
350
+ script_fields: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
351
+ scroll: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
352
+ search_after: t.Optional[
353
+ t.Sequence[t.Union[None, bool, float, int, str]]
354
+ ] = None,
355
+ search_type: t.Optional[
356
+ t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
357
+ ] = None,
358
+ seq_no_primary_term: t.Optional[bool] = None,
359
+ size: t.Optional[int] = None,
360
+ slice: t.Optional[t.Mapping[str, t.Any]] = None,
361
+ sort: t.Optional[
362
+ t.Union[
363
+ t.Sequence[t.Union[str, t.Mapping[str, t.Any]]],
364
+ t.Union[str, t.Mapping[str, t.Any]],
365
+ ]
366
+ ] = None,
367
+ source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None,
368
+ source_excludes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
369
+ source_includes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
370
+ stats: t.Optional[t.Sequence[str]] = None,
371
+ stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
372
+ suggest: t.Optional[t.Mapping[str, t.Any]] = None,
373
+ suggest_field: t.Optional[str] = None,
374
+ suggest_mode: t.Optional[
375
+ t.Union[str, t.Literal["always", "missing", "popular"]]
376
+ ] = None,
377
+ suggest_size: t.Optional[int] = None,
378
+ suggest_text: t.Optional[str] = None,
379
+ terminate_after: t.Optional[int] = None,
380
+ timeout: t.Optional[str] = None,
381
+ track_scores: t.Optional[bool] = None,
382
+ track_total_hits: t.Optional[t.Union[bool, int]] = None,
383
+ typed_keys: t.Optional[bool] = None,
384
+ version: t.Optional[bool] = None,
385
+ wait_for_checkpoints: t.Optional[t.Sequence[int]] = None,
386
+ body: t.Optional[t.Dict[str, t.Any]] = None,
387
+ ) -> ObjectApiResponse[t.Any]:
388
+ """
389
+ .. raw:: html
390
+
391
+ <p>Run a Fleet search.
392
+ The purpose of the Fleet search API is to provide an API where the search will be run only
393
+ after the provided checkpoint has been processed and is visible for searches inside of Elasticsearch.</p>
394
+
395
+
396
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-fleet-search>`_
397
+
398
+ :param index: A single target to search. If the target is an index alias, it
399
+ must resolve to a single index.
400
+ :param aggregations:
401
+ :param aggs:
402
+ :param allow_no_indices:
403
+ :param allow_partial_search_results: If true, returns partial results if there
404
+ are shard request timeouts or shard failures. If false, returns an error
405
+ with no partial results. Defaults to the configured cluster setting `search.default_allow_partial_results`,
406
+ which is true by default.
407
+ :param analyze_wildcard:
408
+ :param analyzer:
409
+ :param batched_reduce_size:
410
+ :param ccs_minimize_roundtrips:
411
+ :param collapse:
412
+ :param default_operator:
413
+ :param df:
414
+ :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc
415
+ values for field names matching these patterns in the hits.fields property
416
+ of the response.
417
+ :param expand_wildcards:
418
+ :param explain: If true, returns detailed information about score computation
419
+ as part of a hit.
420
+ :param ext: Configuration of search extensions defined by Elasticsearch plugins.
421
+ :param fields: Array of wildcard (*) patterns. The request returns values for
422
+ field names matching these patterns in the hits.fields property of the response.
423
+ :param from_: Starting document offset. By default, you cannot page through more
424
+ than 10,000 hits using the from and size parameters. To page through more
425
+ hits, use the search_after parameter.
426
+ :param highlight:
427
+ :param ignore_throttled:
428
+ :param ignore_unavailable:
429
+ :param indices_boost: Boosts the _score of documents from specified indices.
430
+ :param lenient:
431
+ :param max_concurrent_shard_requests:
432
+ :param min_score: Minimum _score for matching documents. Documents with a lower
433
+ _score are not included in search results and results collected by aggregations.
434
+ :param pit: Limits the search to a point in time (PIT). If you provide a PIT,
435
+ you cannot specify an <index> in the request path.
436
+ :param post_filter:
437
+ :param pre_filter_shard_size:
438
+ :param preference:
439
+ :param profile:
440
+ :param q:
441
+ :param query: Defines the search definition using the Query DSL.
442
+ :param request_cache:
443
+ :param rescore:
444
+ :param rest_total_hits_as_int:
445
+ :param routing:
446
+ :param runtime_mappings: Defines one or more runtime fields in the search request.
447
+ These fields take precedence over mapped fields with the same name.
448
+ :param script_fields: Retrieve a script evaluation (based on different fields)
449
+ for each hit.
450
+ :param scroll:
451
+ :param search_after:
452
+ :param search_type:
453
+ :param seq_no_primary_term: If true, returns sequence number and primary term
454
+ of the last modification of each hit. See Optimistic concurrency control.
455
+ :param size: The number of hits to return. By default, you cannot page through
456
+ more than 10,000 hits using the from and size parameters. To page through
457
+ more hits, use the search_after parameter.
458
+ :param slice:
459
+ :param sort:
460
+ :param source: Indicates which source fields are returned for matching documents.
461
+ These fields are returned in the hits._source property of the search response.
462
+ :param source_excludes:
463
+ :param source_includes:
464
+ :param stats: Stats groups to associate with the search. Each group maintains
465
+ a statistics aggregation for its associated searches. You can retrieve these
466
+ stats using the indices stats API.
467
+ :param stored_fields: List of stored fields to return as part of a hit. If no
468
+ fields are specified, no stored fields are included in the response. If this
469
+ field is specified, the _source parameter defaults to false. You can pass
470
+ _source: true to return both source fields and stored fields in the search
471
+ response.
472
+ :param suggest:
473
+ :param suggest_field: Specifies which field to use for suggestions.
474
+ :param suggest_mode:
475
+ :param suggest_size:
476
+ :param suggest_text: The source text for which the suggestions should be returned.
477
+ :param terminate_after: Maximum number of documents to collect for each shard.
478
+ If a query reaches this limit, Elasticsearch terminates the query early.
479
+ Elasticsearch collects documents before sorting. Defaults to 0, which does
480
+ not terminate query execution early.
481
+ :param timeout: Specifies the period of time to wait for a response from each
482
+ shard. If no response is received before the timeout expires, the request
483
+ fails and returns an error. Defaults to no timeout.
484
+ :param track_scores: If true, calculate and return document scores, even if the
485
+ scores are not used for sorting.
486
+ :param track_total_hits: Number of hits matching the query to count accurately.
487
+ If true, the exact number of hits is returned at the cost of some performance.
488
+ If false, the response does not include the total number of hits matching
489
+ the query. Defaults to 10,000 hits.
490
+ :param typed_keys:
491
+ :param version: If true, returns document version as part of a hit.
492
+ :param wait_for_checkpoints: A comma separated list of checkpoints. When configured,
493
+ the search API will only be executed on a shard after the relevant checkpoint
494
+ has become visible for search. Defaults to an empty list which will cause
495
+ Elasticsearch to immediately execute the search.
496
+ """
497
+ if index in SKIP_IN_PATH:
498
+ raise ValueError("Empty value passed for parameter 'index'")
499
+ __path_parts: t.Dict[str, str] = {"index": _quote(index)}
500
+ __path = f'/{__path_parts["index"]}/_fleet/_fleet_search'
501
+ __query: t.Dict[str, t.Any] = {}
502
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
503
+ # The 'sort' parameter with a colon can't be encoded to the body.
504
+ if sort is not None and (
505
+ (isinstance(sort, str) and ":" in sort)
506
+ or (
507
+ isinstance(sort, (list, tuple))
508
+ and all(isinstance(_x, str) for _x in sort)
509
+ and any(":" in _x for _x in sort)
510
+ )
511
+ ):
512
+ __query["sort"] = sort
513
+ sort = None
514
+ if allow_no_indices is not None:
515
+ __query["allow_no_indices"] = allow_no_indices
516
+ if allow_partial_search_results is not None:
517
+ __query["allow_partial_search_results"] = allow_partial_search_results
518
+ if analyze_wildcard is not None:
519
+ __query["analyze_wildcard"] = analyze_wildcard
520
+ if analyzer is not None:
521
+ __query["analyzer"] = analyzer
522
+ if batched_reduce_size is not None:
523
+ __query["batched_reduce_size"] = batched_reduce_size
524
+ if ccs_minimize_roundtrips is not None:
525
+ __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips
526
+ if default_operator is not None:
527
+ __query["default_operator"] = default_operator
528
+ if df is not None:
529
+ __query["df"] = df
530
+ if error_trace is not None:
531
+ __query["error_trace"] = error_trace
532
+ if expand_wildcards is not None:
533
+ __query["expand_wildcards"] = expand_wildcards
534
+ if filter_path is not None:
535
+ __query["filter_path"] = filter_path
536
+ if human is not None:
537
+ __query["human"] = human
538
+ if ignore_throttled is not None:
539
+ __query["ignore_throttled"] = ignore_throttled
540
+ if ignore_unavailable is not None:
541
+ __query["ignore_unavailable"] = ignore_unavailable
542
+ if lenient is not None:
543
+ __query["lenient"] = lenient
544
+ if max_concurrent_shard_requests is not None:
545
+ __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
546
+ if pre_filter_shard_size is not None:
547
+ __query["pre_filter_shard_size"] = pre_filter_shard_size
548
+ if preference is not None:
549
+ __query["preference"] = preference
550
+ if pretty is not None:
551
+ __query["pretty"] = pretty
552
+ if q is not None:
553
+ __query["q"] = q
554
+ if request_cache is not None:
555
+ __query["request_cache"] = request_cache
556
+ if rest_total_hits_as_int is not None:
557
+ __query["rest_total_hits_as_int"] = rest_total_hits_as_int
558
+ if routing is not None:
559
+ __query["routing"] = routing
560
+ if scroll is not None:
561
+ __query["scroll"] = scroll
562
+ if search_type is not None:
563
+ __query["search_type"] = search_type
564
+ if source_excludes is not None:
565
+ __query["_source_excludes"] = source_excludes
566
+ if source_includes is not None:
567
+ __query["_source_includes"] = source_includes
568
+ if suggest_field is not None:
569
+ __query["suggest_field"] = suggest_field
570
+ if suggest_mode is not None:
571
+ __query["suggest_mode"] = suggest_mode
572
+ if suggest_size is not None:
573
+ __query["suggest_size"] = suggest_size
574
+ if suggest_text is not None:
575
+ __query["suggest_text"] = suggest_text
576
+ if typed_keys is not None:
577
+ __query["typed_keys"] = typed_keys
578
+ if wait_for_checkpoints is not None:
579
+ __query["wait_for_checkpoints"] = wait_for_checkpoints
580
+ if not __body:
581
+ if aggregations is not None:
582
+ __body["aggregations"] = aggregations
583
+ if aggs is not None:
584
+ __body["aggs"] = aggs
585
+ if collapse is not None:
586
+ __body["collapse"] = collapse
587
+ if docvalue_fields is not None:
588
+ __body["docvalue_fields"] = docvalue_fields
589
+ if explain is not None:
590
+ __body["explain"] = explain
591
+ if ext is not None:
592
+ __body["ext"] = ext
593
+ if fields is not None:
594
+ __body["fields"] = fields
595
+ if from_ is not None:
596
+ __body["from"] = from_
597
+ if highlight is not None:
598
+ __body["highlight"] = highlight
599
+ if indices_boost is not None:
600
+ __body["indices_boost"] = indices_boost
601
+ if min_score is not None:
602
+ __body["min_score"] = min_score
603
+ if pit is not None:
604
+ __body["pit"] = pit
605
+ if post_filter is not None:
606
+ __body["post_filter"] = post_filter
607
+ if profile is not None:
608
+ __body["profile"] = profile
609
+ if query is not None:
610
+ __body["query"] = query
611
+ if rescore is not None:
612
+ __body["rescore"] = rescore
613
+ if runtime_mappings is not None:
614
+ __body["runtime_mappings"] = runtime_mappings
615
+ if script_fields is not None:
616
+ __body["script_fields"] = script_fields
617
+ if search_after is not None:
618
+ __body["search_after"] = search_after
619
+ if seq_no_primary_term is not None:
620
+ __body["seq_no_primary_term"] = seq_no_primary_term
621
+ if size is not None:
622
+ __body["size"] = size
623
+ if slice is not None:
624
+ __body["slice"] = slice
625
+ if sort is not None:
626
+ __body["sort"] = sort
627
+ if source is not None:
628
+ __body["_source"] = source
629
+ if stats is not None:
630
+ __body["stats"] = stats
631
+ if stored_fields is not None:
632
+ __body["stored_fields"] = stored_fields
633
+ if suggest is not None:
634
+ __body["suggest"] = suggest
635
+ if terminate_after is not None:
636
+ __body["terminate_after"] = terminate_after
637
+ if timeout is not None:
638
+ __body["timeout"] = timeout
639
+ if track_scores is not None:
640
+ __body["track_scores"] = track_scores
641
+ if track_total_hits is not None:
642
+ __body["track_total_hits"] = track_total_hits
643
+ if version is not None:
644
+ __body["version"] = version
645
+ if not __body:
646
+ __body = None # type: ignore[assignment]
647
+ __headers = {"accept": "application/json"}
648
+ if __body is not None:
649
+ __headers["content-type"] = "application/json"
650
+ return self.perform_request( # type: ignore[return-value]
651
+ "POST",
652
+ __path,
653
+ params=__query,
654
+ headers=__headers,
655
+ body=__body,
656
+ endpoint_id="fleet.search",
657
+ path_parts=__path_parts,
658
+ )