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,637 @@
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 SKIP_IN_PATH, _quote, _rewrite_parameters
24
+
25
+
26
+ class AsyncSearchClient(NamespacedClient):
27
+
28
+ @_rewrite_parameters()
29
+ async def delete(
30
+ self,
31
+ *,
32
+ id: str,
33
+ error_trace: t.Optional[bool] = None,
34
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
35
+ human: t.Optional[bool] = None,
36
+ pretty: t.Optional[bool] = None,
37
+ ) -> ObjectApiResponse[t.Any]:
38
+ """
39
+ .. raw:: html
40
+
41
+ <p>Delete an async search.</p>
42
+ <p>If the asynchronous search is still running, it is cancelled.
43
+ Otherwise, the saved search results are deleted.
44
+ If the Elasticsearch security features are enabled, the deletion of a specific async search is restricted to: the authenticated user that submitted the original search request; users that have the <code>cancel_task</code> cluster privilege.</p>
45
+
46
+
47
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-async-search-submit>`_
48
+
49
+ :param id: A unique identifier for the async search.
50
+ """
51
+ if id in SKIP_IN_PATH:
52
+ raise ValueError("Empty value passed for parameter 'id'")
53
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
54
+ __path = f'/_async_search/{__path_parts["id"]}'
55
+ __query: t.Dict[str, t.Any] = {}
56
+ if error_trace is not None:
57
+ __query["error_trace"] = error_trace
58
+ if filter_path is not None:
59
+ __query["filter_path"] = filter_path
60
+ if human is not None:
61
+ __query["human"] = human
62
+ if pretty is not None:
63
+ __query["pretty"] = pretty
64
+ __headers = {"accept": "application/json"}
65
+ return await self.perform_request( # type: ignore[return-value]
66
+ "DELETE",
67
+ __path,
68
+ params=__query,
69
+ headers=__headers,
70
+ endpoint_id="async_search.delete",
71
+ path_parts=__path_parts,
72
+ )
73
+
74
+ @_rewrite_parameters()
75
+ async def get(
76
+ self,
77
+ *,
78
+ id: str,
79
+ error_trace: t.Optional[bool] = None,
80
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
81
+ human: t.Optional[bool] = None,
82
+ keep_alive: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
83
+ pretty: t.Optional[bool] = None,
84
+ typed_keys: t.Optional[bool] = None,
85
+ wait_for_completion_timeout: t.Optional[
86
+ t.Union[str, t.Literal[-1], t.Literal[0]]
87
+ ] = None,
88
+ ) -> ObjectApiResponse[t.Any]:
89
+ """
90
+ .. raw:: html
91
+
92
+ <p>Get async search results.</p>
93
+ <p>Retrieve the results of a previously submitted asynchronous search request.
94
+ If the Elasticsearch security features are enabled, access to the results of a specific async search is restricted to the user or API key that submitted it.</p>
95
+
96
+
97
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-async-search-submit>`_
98
+
99
+ :param id: A unique identifier for the async search.
100
+ :param keep_alive: The length of time that the async search should be available
101
+ in the cluster. When not specified, the `keep_alive` set with the corresponding
102
+ submit async request will be used. Otherwise, it is possible to override
103
+ the value and extend the validity of the request. When this period expires,
104
+ the search, if still running, is cancelled. If the search is completed, its
105
+ saved results are deleted.
106
+ :param typed_keys: Specify whether aggregation and suggester names should be
107
+ prefixed by their respective types in the response
108
+ :param wait_for_completion_timeout: Specifies to wait for the search to be completed
109
+ up until the provided timeout. Final results will be returned if available
110
+ before the timeout expires, otherwise the currently available results will
111
+ be returned once the timeout expires. By default no timeout is set meaning
112
+ that the currently available results will be returned without any additional
113
+ wait.
114
+ """
115
+ if id in SKIP_IN_PATH:
116
+ raise ValueError("Empty value passed for parameter 'id'")
117
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
118
+ __path = f'/_async_search/{__path_parts["id"]}'
119
+ __query: t.Dict[str, t.Any] = {}
120
+ if error_trace is not None:
121
+ __query["error_trace"] = error_trace
122
+ if filter_path is not None:
123
+ __query["filter_path"] = filter_path
124
+ if human is not None:
125
+ __query["human"] = human
126
+ if keep_alive is not None:
127
+ __query["keep_alive"] = keep_alive
128
+ if pretty is not None:
129
+ __query["pretty"] = pretty
130
+ if typed_keys is not None:
131
+ __query["typed_keys"] = typed_keys
132
+ if wait_for_completion_timeout is not None:
133
+ __query["wait_for_completion_timeout"] = wait_for_completion_timeout
134
+ __headers = {"accept": "application/json"}
135
+ return await self.perform_request( # type: ignore[return-value]
136
+ "GET",
137
+ __path,
138
+ params=__query,
139
+ headers=__headers,
140
+ endpoint_id="async_search.get",
141
+ path_parts=__path_parts,
142
+ )
143
+
144
+ @_rewrite_parameters()
145
+ async def status(
146
+ self,
147
+ *,
148
+ id: str,
149
+ error_trace: t.Optional[bool] = None,
150
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
151
+ human: t.Optional[bool] = None,
152
+ keep_alive: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
153
+ pretty: t.Optional[bool] = None,
154
+ ) -> ObjectApiResponse[t.Any]:
155
+ """
156
+ .. raw:: html
157
+
158
+ <p>Get the async search status.</p>
159
+ <p>Get the status of a previously submitted async search request given its identifier, without retrieving search results.
160
+ If the Elasticsearch security features are enabled, the access to the status of a specific async search is restricted to:</p>
161
+ <ul>
162
+ <li>The user or API key that submitted the original async search request.</li>
163
+ <li>Users that have the <code>monitor</code> cluster privilege or greater privileges.</li>
164
+ </ul>
165
+
166
+
167
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-async-search-submit>`_
168
+
169
+ :param id: A unique identifier for the async search.
170
+ :param keep_alive: The length of time that the async search needs to be available.
171
+ Ongoing async searches and any saved search results are deleted after this
172
+ period.
173
+ """
174
+ if id in SKIP_IN_PATH:
175
+ raise ValueError("Empty value passed for parameter 'id'")
176
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
177
+ __path = f'/_async_search/status/{__path_parts["id"]}'
178
+ __query: t.Dict[str, t.Any] = {}
179
+ if error_trace is not None:
180
+ __query["error_trace"] = error_trace
181
+ if filter_path is not None:
182
+ __query["filter_path"] = filter_path
183
+ if human is not None:
184
+ __query["human"] = human
185
+ if keep_alive is not None:
186
+ __query["keep_alive"] = keep_alive
187
+ if pretty is not None:
188
+ __query["pretty"] = pretty
189
+ __headers = {"accept": "application/json"}
190
+ return await self.perform_request( # type: ignore[return-value]
191
+ "GET",
192
+ __path,
193
+ params=__query,
194
+ headers=__headers,
195
+ endpoint_id="async_search.status",
196
+ path_parts=__path_parts,
197
+ )
198
+
199
+ @_rewrite_parameters(
200
+ body_fields=(
201
+ "aggregations",
202
+ "aggs",
203
+ "collapse",
204
+ "docvalue_fields",
205
+ "explain",
206
+ "ext",
207
+ "fields",
208
+ "from_",
209
+ "highlight",
210
+ "indices_boost",
211
+ "knn",
212
+ "min_score",
213
+ "pit",
214
+ "post_filter",
215
+ "profile",
216
+ "query",
217
+ "rescore",
218
+ "runtime_mappings",
219
+ "script_fields",
220
+ "search_after",
221
+ "seq_no_primary_term",
222
+ "size",
223
+ "slice",
224
+ "sort",
225
+ "source",
226
+ "stats",
227
+ "stored_fields",
228
+ "suggest",
229
+ "terminate_after",
230
+ "timeout",
231
+ "track_scores",
232
+ "track_total_hits",
233
+ "version",
234
+ ),
235
+ parameter_aliases={
236
+ "_source": "source",
237
+ "_source_excludes": "source_excludes",
238
+ "_source_includes": "source_includes",
239
+ "from": "from_",
240
+ },
241
+ )
242
+ async def submit(
243
+ self,
244
+ *,
245
+ index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
246
+ aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
247
+ aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
248
+ allow_no_indices: t.Optional[bool] = None,
249
+ allow_partial_search_results: t.Optional[bool] = None,
250
+ analyze_wildcard: t.Optional[bool] = None,
251
+ analyzer: t.Optional[str] = None,
252
+ batched_reduce_size: t.Optional[int] = None,
253
+ ccs_minimize_roundtrips: t.Optional[bool] = None,
254
+ collapse: t.Optional[t.Mapping[str, t.Any]] = None,
255
+ default_operator: t.Optional[t.Union[str, t.Literal["and", "or"]]] = None,
256
+ df: t.Optional[str] = None,
257
+ docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
258
+ error_trace: t.Optional[bool] = None,
259
+ expand_wildcards: t.Optional[
260
+ t.Union[
261
+ t.Sequence[
262
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
263
+ ],
264
+ t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
265
+ ]
266
+ ] = None,
267
+ explain: t.Optional[bool] = None,
268
+ ext: t.Optional[t.Mapping[str, t.Any]] = None,
269
+ fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
270
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
271
+ from_: t.Optional[int] = None,
272
+ highlight: t.Optional[t.Mapping[str, t.Any]] = None,
273
+ human: t.Optional[bool] = None,
274
+ ignore_throttled: t.Optional[bool] = None,
275
+ ignore_unavailable: t.Optional[bool] = None,
276
+ indices_boost: t.Optional[t.Sequence[t.Mapping[str, float]]] = None,
277
+ keep_alive: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
278
+ keep_on_completion: t.Optional[bool] = None,
279
+ knn: t.Optional[
280
+ t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]]
281
+ ] = None,
282
+ lenient: t.Optional[bool] = None,
283
+ max_concurrent_shard_requests: t.Optional[int] = None,
284
+ min_score: t.Optional[float] = None,
285
+ pit: t.Optional[t.Mapping[str, t.Any]] = None,
286
+ post_filter: t.Optional[t.Mapping[str, t.Any]] = None,
287
+ preference: t.Optional[str] = None,
288
+ pretty: t.Optional[bool] = None,
289
+ profile: t.Optional[bool] = None,
290
+ q: t.Optional[str] = None,
291
+ query: t.Optional[t.Mapping[str, t.Any]] = None,
292
+ request_cache: t.Optional[bool] = None,
293
+ rescore: t.Optional[
294
+ t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]]
295
+ ] = None,
296
+ rest_total_hits_as_int: t.Optional[bool] = None,
297
+ routing: t.Optional[str] = None,
298
+ runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
299
+ script_fields: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
300
+ search_after: t.Optional[
301
+ t.Sequence[t.Union[None, bool, float, int, str]]
302
+ ] = None,
303
+ search_type: t.Optional[
304
+ t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
305
+ ] = None,
306
+ seq_no_primary_term: t.Optional[bool] = None,
307
+ size: t.Optional[int] = None,
308
+ slice: t.Optional[t.Mapping[str, t.Any]] = None,
309
+ sort: t.Optional[
310
+ t.Union[
311
+ t.Sequence[t.Union[str, t.Mapping[str, t.Any]]],
312
+ t.Union[str, t.Mapping[str, t.Any]],
313
+ ]
314
+ ] = None,
315
+ source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None,
316
+ source_excludes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
317
+ source_includes: t.Optional[t.Union[str, t.Sequence[str]]] = None,
318
+ stats: t.Optional[t.Sequence[str]] = None,
319
+ stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
320
+ suggest: t.Optional[t.Mapping[str, t.Any]] = None,
321
+ suggest_field: t.Optional[str] = None,
322
+ suggest_mode: t.Optional[
323
+ t.Union[str, t.Literal["always", "missing", "popular"]]
324
+ ] = None,
325
+ suggest_size: t.Optional[int] = None,
326
+ suggest_text: t.Optional[str] = None,
327
+ terminate_after: t.Optional[int] = None,
328
+ timeout: t.Optional[str] = None,
329
+ track_scores: t.Optional[bool] = None,
330
+ track_total_hits: t.Optional[t.Union[bool, int]] = None,
331
+ typed_keys: t.Optional[bool] = None,
332
+ version: t.Optional[bool] = None,
333
+ wait_for_completion_timeout: t.Optional[
334
+ t.Union[str, t.Literal[-1], t.Literal[0]]
335
+ ] = None,
336
+ body: t.Optional[t.Dict[str, t.Any]] = None,
337
+ ) -> ObjectApiResponse[t.Any]:
338
+ """
339
+ .. raw:: html
340
+
341
+ <p>Run an async search.</p>
342
+ <p>When the primary sort of the results is an indexed field, shards get sorted based on minimum and maximum value that they hold for that field. Partial results become available following the sort criteria that was requested.</p>
343
+ <p>Warning: Asynchronous search does not support scroll or search requests that include only the suggest section.</p>
344
+ <p>By default, Elasticsearch does not allow you to store an async search response larger than 10Mb and an attempt to do this results in an error.
345
+ The maximum allowed size for a stored async search response can be set by changing the <code>search.max_async_search_response_size</code> cluster level setting.</p>
346
+
347
+
348
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-async-search-submit>`_
349
+
350
+ :param index: A comma-separated list of index names to search; use `_all` or
351
+ empty string to perform the operation on all indices
352
+ :param aggregations:
353
+ :param aggs:
354
+ :param allow_no_indices: Whether to ignore if a wildcard indices expression resolves
355
+ into no concrete indices. (This includes `_all` string or when no indices
356
+ have been specified)
357
+ :param allow_partial_search_results: Indicate if an error should be returned
358
+ if there is a partial search failure or timeout
359
+ :param analyze_wildcard: Specify whether wildcard and prefix queries should be
360
+ analyzed (default: false)
361
+ :param analyzer: The analyzer to use for the query string
362
+ :param batched_reduce_size: Affects how often partial results become available,
363
+ which happens whenever shard results are reduced. A partial reduction is
364
+ performed every time the coordinating node has received a certain number
365
+ of new shard responses (5 by default).
366
+ :param ccs_minimize_roundtrips: The default value is the only supported value.
367
+ :param collapse:
368
+ :param default_operator: The default operator for query string query (AND or
369
+ OR)
370
+ :param df: The field to use as default where no field prefix is given in the
371
+ query string
372
+ :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc
373
+ values for field names matching these patterns in the hits.fields property
374
+ of the response.
375
+ :param expand_wildcards: Whether to expand wildcard expression to concrete indices
376
+ that are open, closed or both.
377
+ :param explain: If true, returns detailed information about score computation
378
+ as part of a hit.
379
+ :param ext: Configuration of search extensions defined by Elasticsearch plugins.
380
+ :param fields: Array of wildcard (*) patterns. The request returns values for
381
+ field names matching these patterns in the hits.fields property of the response.
382
+ :param from_: Starting document offset. By default, you cannot page through more
383
+ than 10,000 hits using the from and size parameters. To page through more
384
+ hits, use the search_after parameter.
385
+ :param highlight:
386
+ :param ignore_throttled: Whether specified concrete, expanded or aliased indices
387
+ should be ignored when throttled
388
+ :param ignore_unavailable: Whether specified concrete indices should be ignored
389
+ when unavailable (missing or closed)
390
+ :param indices_boost: Boosts the _score of documents from specified indices.
391
+ :param keep_alive: Specifies how long the async search needs to be available.
392
+ Ongoing async searches and any saved search results are deleted after this
393
+ period.
394
+ :param keep_on_completion: If `true`, results are stored for later retrieval
395
+ when the search completes within the `wait_for_completion_timeout`.
396
+ :param knn: Defines the approximate kNN search to run.
397
+ :param lenient: Specify whether format-based query failures (such as providing
398
+ text to a numeric field) should be ignored
399
+ :param max_concurrent_shard_requests: The number of concurrent shard requests
400
+ per node this search executes concurrently. This value should be used to
401
+ limit the impact of the search on the cluster in order to limit the number
402
+ of concurrent shard requests
403
+ :param min_score: Minimum _score for matching documents. Documents with a lower
404
+ _score are not included in search results and results collected by aggregations.
405
+ :param pit: Limits the search to a point in time (PIT). If you provide a PIT,
406
+ you cannot specify an <index> in the request path.
407
+ :param post_filter:
408
+ :param preference: Specify the node or shard the operation should be performed
409
+ on (default: random)
410
+ :param profile:
411
+ :param q: Query in the Lucene query string syntax
412
+ :param query: Defines the search definition using the Query DSL.
413
+ :param request_cache: Specify if request cache should be used for this request
414
+ or not, defaults to true
415
+ :param rescore:
416
+ :param rest_total_hits_as_int: Indicates whether hits.total should be rendered
417
+ as an integer or an object in the rest search response
418
+ :param routing: A comma-separated list of specific routing values
419
+ :param runtime_mappings: Defines one or more runtime fields in the search request.
420
+ These fields take precedence over mapped fields with the same name.
421
+ :param script_fields: Retrieve a script evaluation (based on different fields)
422
+ for each hit.
423
+ :param search_after:
424
+ :param search_type: Search operation type
425
+ :param seq_no_primary_term: If true, returns sequence number and primary term
426
+ of the last modification of each hit. See Optimistic concurrency control.
427
+ :param size: The number of hits to return. By default, you cannot page through
428
+ more than 10,000 hits using the from and size parameters. To page through
429
+ more hits, use the search_after parameter.
430
+ :param slice:
431
+ :param sort:
432
+ :param source: Indicates which source fields are returned for matching documents.
433
+ These fields are returned in the hits._source property of the search response.
434
+ :param source_excludes: A list of fields to exclude from the returned _source
435
+ field
436
+ :param source_includes: A list of fields to extract and return from the _source
437
+ field
438
+ :param stats: Stats groups to associate with the search. Each group maintains
439
+ a statistics aggregation for its associated searches. You can retrieve these
440
+ stats using the indices stats API.
441
+ :param stored_fields: List of stored fields to return as part of a hit. If no
442
+ fields are specified, no stored fields are included in the response. If this
443
+ field is specified, the _source parameter defaults to false. You can pass
444
+ _source: true to return both source fields and stored fields in the search
445
+ response.
446
+ :param suggest:
447
+ :param suggest_field: Specifies which field to use for suggestions.
448
+ :param suggest_mode: Specify suggest mode
449
+ :param suggest_size: How many suggestions to return in response
450
+ :param suggest_text: The source text for which the suggestions should be returned.
451
+ :param terminate_after: Maximum number of documents to collect for each shard.
452
+ If a query reaches this limit, Elasticsearch terminates the query early.
453
+ Elasticsearch collects documents before sorting. Defaults to 0, which does
454
+ not terminate query execution early.
455
+ :param timeout: Specifies the period of time to wait for a response from each
456
+ shard. If no response is received before the timeout expires, the request
457
+ fails and returns an error. Defaults to no timeout.
458
+ :param track_scores: If true, calculate and return document scores, even if the
459
+ scores are not used for sorting.
460
+ :param track_total_hits: Number of hits matching the query to count accurately.
461
+ If true, the exact number of hits is returned at the cost of some performance.
462
+ If false, the response does not include the total number of hits matching
463
+ the query. Defaults to 10,000 hits.
464
+ :param typed_keys: Specify whether aggregation and suggester names should be
465
+ prefixed by their respective types in the response
466
+ :param version: If true, returns document version as part of a hit.
467
+ :param wait_for_completion_timeout: Blocks and waits until the search is completed
468
+ up to a certain timeout. When the async search completes within the timeout,
469
+ the response won’t include the ID as the results are not stored in the cluster.
470
+ """
471
+ __path_parts: t.Dict[str, str]
472
+ if index not in SKIP_IN_PATH:
473
+ __path_parts = {"index": _quote(index)}
474
+ __path = f'/{__path_parts["index"]}/_async_search'
475
+ else:
476
+ __path_parts = {}
477
+ __path = "/_async_search"
478
+ __query: t.Dict[str, t.Any] = {}
479
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
480
+ # The 'sort' parameter with a colon can't be encoded to the body.
481
+ if sort is not None and (
482
+ (isinstance(sort, str) and ":" in sort)
483
+ or (
484
+ isinstance(sort, (list, tuple))
485
+ and all(isinstance(_x, str) for _x in sort)
486
+ and any(":" in _x for _x in sort)
487
+ )
488
+ ):
489
+ __query["sort"] = sort
490
+ sort = None
491
+ if allow_no_indices is not None:
492
+ __query["allow_no_indices"] = allow_no_indices
493
+ if allow_partial_search_results is not None:
494
+ __query["allow_partial_search_results"] = allow_partial_search_results
495
+ if analyze_wildcard is not None:
496
+ __query["analyze_wildcard"] = analyze_wildcard
497
+ if analyzer is not None:
498
+ __query["analyzer"] = analyzer
499
+ if batched_reduce_size is not None:
500
+ __query["batched_reduce_size"] = batched_reduce_size
501
+ if ccs_minimize_roundtrips is not None:
502
+ __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips
503
+ if default_operator is not None:
504
+ __query["default_operator"] = default_operator
505
+ if df is not None:
506
+ __query["df"] = df
507
+ if error_trace is not None:
508
+ __query["error_trace"] = error_trace
509
+ if expand_wildcards is not None:
510
+ __query["expand_wildcards"] = expand_wildcards
511
+ if filter_path is not None:
512
+ __query["filter_path"] = filter_path
513
+ if human is not None:
514
+ __query["human"] = human
515
+ if ignore_throttled is not None:
516
+ __query["ignore_throttled"] = ignore_throttled
517
+ if ignore_unavailable is not None:
518
+ __query["ignore_unavailable"] = ignore_unavailable
519
+ if keep_alive is not None:
520
+ __query["keep_alive"] = keep_alive
521
+ if keep_on_completion is not None:
522
+ __query["keep_on_completion"] = keep_on_completion
523
+ if lenient is not None:
524
+ __query["lenient"] = lenient
525
+ if max_concurrent_shard_requests is not None:
526
+ __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
527
+ if preference is not None:
528
+ __query["preference"] = preference
529
+ if pretty is not None:
530
+ __query["pretty"] = pretty
531
+ if q is not None:
532
+ __query["q"] = q
533
+ if request_cache is not None:
534
+ __query["request_cache"] = request_cache
535
+ if rest_total_hits_as_int is not None:
536
+ __query["rest_total_hits_as_int"] = rest_total_hits_as_int
537
+ if routing is not None:
538
+ __query["routing"] = routing
539
+ if search_type is not None:
540
+ __query["search_type"] = search_type
541
+ if source_excludes is not None:
542
+ __query["_source_excludes"] = source_excludes
543
+ if source_includes is not None:
544
+ __query["_source_includes"] = source_includes
545
+ if suggest_field is not None:
546
+ __query["suggest_field"] = suggest_field
547
+ if suggest_mode is not None:
548
+ __query["suggest_mode"] = suggest_mode
549
+ if suggest_size is not None:
550
+ __query["suggest_size"] = suggest_size
551
+ if suggest_text is not None:
552
+ __query["suggest_text"] = suggest_text
553
+ if typed_keys is not None:
554
+ __query["typed_keys"] = typed_keys
555
+ if wait_for_completion_timeout is not None:
556
+ __query["wait_for_completion_timeout"] = wait_for_completion_timeout
557
+ if not __body:
558
+ if aggregations is not None:
559
+ __body["aggregations"] = aggregations
560
+ if aggs is not None:
561
+ __body["aggs"] = aggs
562
+ if collapse is not None:
563
+ __body["collapse"] = collapse
564
+ if docvalue_fields is not None:
565
+ __body["docvalue_fields"] = docvalue_fields
566
+ if explain is not None:
567
+ __body["explain"] = explain
568
+ if ext is not None:
569
+ __body["ext"] = ext
570
+ if fields is not None:
571
+ __body["fields"] = fields
572
+ if from_ is not None:
573
+ __body["from"] = from_
574
+ if highlight is not None:
575
+ __body["highlight"] = highlight
576
+ if indices_boost is not None:
577
+ __body["indices_boost"] = indices_boost
578
+ if knn is not None:
579
+ __body["knn"] = knn
580
+ if min_score is not None:
581
+ __body["min_score"] = min_score
582
+ if pit is not None:
583
+ __body["pit"] = pit
584
+ if post_filter is not None:
585
+ __body["post_filter"] = post_filter
586
+ if profile is not None:
587
+ __body["profile"] = profile
588
+ if query is not None:
589
+ __body["query"] = query
590
+ if rescore is not None:
591
+ __body["rescore"] = rescore
592
+ if runtime_mappings is not None:
593
+ __body["runtime_mappings"] = runtime_mappings
594
+ if script_fields is not None:
595
+ __body["script_fields"] = script_fields
596
+ if search_after is not None:
597
+ __body["search_after"] = search_after
598
+ if seq_no_primary_term is not None:
599
+ __body["seq_no_primary_term"] = seq_no_primary_term
600
+ if size is not None:
601
+ __body["size"] = size
602
+ if slice is not None:
603
+ __body["slice"] = slice
604
+ if sort is not None:
605
+ __body["sort"] = sort
606
+ if source is not None:
607
+ __body["_source"] = source
608
+ if stats is not None:
609
+ __body["stats"] = stats
610
+ if stored_fields is not None:
611
+ __body["stored_fields"] = stored_fields
612
+ if suggest is not None:
613
+ __body["suggest"] = suggest
614
+ if terminate_after is not None:
615
+ __body["terminate_after"] = terminate_after
616
+ if timeout is not None:
617
+ __body["timeout"] = timeout
618
+ if track_scores is not None:
619
+ __body["track_scores"] = track_scores
620
+ if track_total_hits is not None:
621
+ __body["track_total_hits"] = track_total_hits
622
+ if version is not None:
623
+ __body["version"] = version
624
+ if not __body:
625
+ __body = None # type: ignore[assignment]
626
+ __headers = {"accept": "application/json"}
627
+ if __body is not None:
628
+ __headers["content-type"] = "application/json"
629
+ return await self.perform_request( # type: ignore[return-value]
630
+ "POST",
631
+ __path,
632
+ params=__query,
633
+ headers=__headers,
634
+ body=__body,
635
+ endpoint_id="async_search.submit",
636
+ path_parts=__path_parts,
637
+ )