elasticsearch 9.1.3__py3-none-any.whl → 9.2.1__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 +91 -24
- elasticsearch/_async/client/async_search.py +7 -0
- elasticsearch/_async/client/autoscaling.py +7 -0
- elasticsearch/_async/client/cat.py +8 -1
- elasticsearch/_async/client/cluster.py +7 -7
- elasticsearch/_async/client/eql.py +7 -0
- elasticsearch/_async/client/esql.py +26 -3
- elasticsearch/_async/client/indices.py +153 -7
- elasticsearch/_async/client/inference.py +315 -42
- elasticsearch/_async/client/ingest.py +8 -0
- elasticsearch/_async/client/license.py +4 -2
- elasticsearch/_async/client/ml.py +2 -2
- elasticsearch/_async/client/nodes.py +2 -4
- elasticsearch/_async/client/project.py +68 -0
- elasticsearch/_async/client/security.py +39 -0
- elasticsearch/_async/client/shutdown.py +6 -0
- elasticsearch/_async/client/simulate.py +8 -0
- elasticsearch/_async/client/snapshot.py +20 -10
- elasticsearch/_async/client/sql.py +7 -0
- elasticsearch/_async/client/streams.py +2 -3
- elasticsearch/_async/helpers.py +28 -15
- elasticsearch/_sync/client/__init__.py +91 -24
- elasticsearch/_sync/client/async_search.py +7 -0
- elasticsearch/_sync/client/autoscaling.py +7 -0
- elasticsearch/_sync/client/cat.py +8 -1
- elasticsearch/_sync/client/cluster.py +7 -7
- elasticsearch/_sync/client/eql.py +7 -0
- elasticsearch/_sync/client/esql.py +26 -3
- elasticsearch/_sync/client/indices.py +153 -7
- elasticsearch/_sync/client/inference.py +315 -42
- elasticsearch/_sync/client/ingest.py +8 -0
- elasticsearch/_sync/client/license.py +4 -2
- elasticsearch/_sync/client/ml.py +2 -2
- elasticsearch/_sync/client/nodes.py +2 -4
- elasticsearch/_sync/client/project.py +68 -0
- elasticsearch/_sync/client/security.py +39 -0
- elasticsearch/_sync/client/shutdown.py +6 -0
- elasticsearch/_sync/client/simulate.py +8 -0
- elasticsearch/_sync/client/snapshot.py +20 -10
- elasticsearch/_sync/client/sql.py +7 -0
- elasticsearch/_sync/client/streams.py +2 -3
- elasticsearch/_version.py +2 -2
- elasticsearch/client.py +2 -0
- elasticsearch/compat.py +2 -15
- elasticsearch/dsl/_async/document.py +2 -1
- elasticsearch/dsl/_sync/document.py +2 -1
- elasticsearch/dsl/document_base.py +38 -13
- elasticsearch/dsl/field.py +8 -0
- elasticsearch/dsl/pydantic.py +152 -0
- elasticsearch/dsl/query.py +5 -1
- elasticsearch/dsl/search_base.py +5 -1
- elasticsearch/dsl/types.py +37 -9
- elasticsearch/esql/esql.py +331 -41
- elasticsearch/esql/functions.py +88 -0
- elasticsearch/helpers/actions.py +1 -1
- {elasticsearch-9.1.3.dist-info → elasticsearch-9.2.1.dist-info}/METADATA +26 -4
- {elasticsearch-9.1.3.dist-info → elasticsearch-9.2.1.dist-info}/RECORD +60 -57
- {elasticsearch-9.1.3.dist-info → elasticsearch-9.2.1.dist-info}/WHEEL +0 -0
- {elasticsearch-9.1.3.dist-info → elasticsearch-9.2.1.dist-info}/licenses/LICENSE +0 -0
- {elasticsearch-9.1.3.dist-info → elasticsearch-9.2.1.dist-info}/licenses/NOTICE +0 -0
|
@@ -104,8 +104,10 @@ class LicenseClient(NamespacedClient):
|
|
|
104
104
|
license types. If `false`, this parameter returns platinum for both platinum
|
|
105
105
|
and enterprise license types. This behavior is maintained for backwards compatibility.
|
|
106
106
|
This parameter is deprecated and will always be set to true in 8.x.
|
|
107
|
-
:param local: Specifies whether to retrieve local information.
|
|
108
|
-
is `
|
|
107
|
+
:param local: Specifies whether to retrieve local information. From 9.2 onwards
|
|
108
|
+
the default value is `true`, which means the information is retrieved from
|
|
109
|
+
the responding node. In earlier versions the default is `false`, which means
|
|
110
|
+
the information is retrieved from the elected master node.
|
|
109
111
|
"""
|
|
110
112
|
__path_parts: t.Dict[str, str] = {}
|
|
111
113
|
__path = "/_license"
|
|
@@ -2397,7 +2397,7 @@ class MlClient(NamespacedClient):
|
|
|
2397
2397
|
exclude_interim: t.Optional[bool] = None,
|
|
2398
2398
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2399
2399
|
human: t.Optional[bool] = None,
|
|
2400
|
-
overall_score: t.Optional[
|
|
2400
|
+
overall_score: t.Optional[float] = None,
|
|
2401
2401
|
pretty: t.Optional[bool] = None,
|
|
2402
2402
|
start: t.Optional[t.Union[str, t.Any]] = None,
|
|
2403
2403
|
top_n: t.Optional[int] = None,
|
|
@@ -5755,7 +5755,7 @@ class MlClient(NamespacedClient):
|
|
|
5755
5755
|
<p>Validate an anomaly detection job.</p>
|
|
5756
5756
|
|
|
5757
5757
|
|
|
5758
|
-
`<https://www.elastic.co/guide/en/machine-learning/9.
|
|
5758
|
+
`<https://www.elastic.co/guide/en/machine-learning/9.2/ml-jobs.html>`_
|
|
5759
5759
|
|
|
5760
5760
|
:param analysis_config:
|
|
5761
5761
|
:param analysis_limits:
|
|
@@ -368,9 +368,7 @@ class NodesClient(NamespacedClient):
|
|
|
368
368
|
human: t.Optional[bool] = None,
|
|
369
369
|
include_segment_file_sizes: t.Optional[bool] = None,
|
|
370
370
|
include_unloaded_segments: t.Optional[bool] = None,
|
|
371
|
-
level: t.Optional[
|
|
372
|
-
t.Union[str, t.Literal["cluster", "indices", "shards"]]
|
|
373
|
-
] = None,
|
|
371
|
+
level: t.Optional[t.Union[str, t.Literal["indices", "node", "shards"]]] = None,
|
|
374
372
|
pretty: t.Optional[bool] = None,
|
|
375
373
|
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
376
374
|
types: t.Optional[t.Sequence[str]] = None,
|
|
@@ -387,7 +385,7 @@ class NodesClient(NamespacedClient):
|
|
|
387
385
|
|
|
388
386
|
:param node_id: Comma-separated list of node IDs or names used to limit returned
|
|
389
387
|
information.
|
|
390
|
-
:param metric:
|
|
388
|
+
:param metric: Limits the information returned to the specific metrics.
|
|
391
389
|
:param index_metric: Limit the information returned for indices metric to the
|
|
392
390
|
specific index metrics. It can be used only if indices (or all) metric is
|
|
393
391
|
specified.
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
Stability,
|
|
25
|
+
_availability_warning,
|
|
26
|
+
_rewrite_parameters,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ProjectClient(NamespacedClient):
|
|
31
|
+
|
|
32
|
+
@_rewrite_parameters()
|
|
33
|
+
@_availability_warning(Stability.EXPERIMENTAL)
|
|
34
|
+
async def tags(
|
|
35
|
+
self,
|
|
36
|
+
*,
|
|
37
|
+
error_trace: t.Optional[bool] = None,
|
|
38
|
+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
39
|
+
human: t.Optional[bool] = None,
|
|
40
|
+
pretty: t.Optional[bool] = None,
|
|
41
|
+
) -> ObjectApiResponse[t.Any]:
|
|
42
|
+
"""
|
|
43
|
+
.. raw:: html
|
|
44
|
+
|
|
45
|
+
<p>Get tags.</p>
|
|
46
|
+
<p>Get the tags that are defined for the project.</p>
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
__path_parts: t.Dict[str, str] = {}
|
|
50
|
+
__path = "/_project/tags"
|
|
51
|
+
__query: t.Dict[str, t.Any] = {}
|
|
52
|
+
if error_trace is not None:
|
|
53
|
+
__query["error_trace"] = error_trace
|
|
54
|
+
if filter_path is not None:
|
|
55
|
+
__query["filter_path"] = filter_path
|
|
56
|
+
if human is not None:
|
|
57
|
+
__query["human"] = human
|
|
58
|
+
if pretty is not None:
|
|
59
|
+
__query["pretty"] = pretty
|
|
60
|
+
__headers = {"accept": "application/json"}
|
|
61
|
+
return await self.perform_request( # type: ignore[return-value]
|
|
62
|
+
"GET",
|
|
63
|
+
__path,
|
|
64
|
+
params=__query,
|
|
65
|
+
headers=__headers,
|
|
66
|
+
endpoint_id="project.tags",
|
|
67
|
+
path_parts=__path_parts,
|
|
68
|
+
)
|
|
@@ -2052,6 +2052,45 @@ class SecurityClient(NamespacedClient):
|
|
|
2052
2052
|
path_parts=__path_parts,
|
|
2053
2053
|
)
|
|
2054
2054
|
|
|
2055
|
+
@_rewrite_parameters()
|
|
2056
|
+
async def get_stats(
|
|
2057
|
+
self,
|
|
2058
|
+
*,
|
|
2059
|
+
error_trace: t.Optional[bool] = None,
|
|
2060
|
+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2061
|
+
human: t.Optional[bool] = None,
|
|
2062
|
+
pretty: t.Optional[bool] = None,
|
|
2063
|
+
) -> ObjectApiResponse[t.Any]:
|
|
2064
|
+
"""
|
|
2065
|
+
.. raw:: html
|
|
2066
|
+
|
|
2067
|
+
<p>Get security stats.</p>
|
|
2068
|
+
<p>Gather security usage statistics from all node(s) within the cluster.</p>
|
|
2069
|
+
|
|
2070
|
+
|
|
2071
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-stats>`_
|
|
2072
|
+
"""
|
|
2073
|
+
__path_parts: t.Dict[str, str] = {}
|
|
2074
|
+
__path = "/_security/stats"
|
|
2075
|
+
__query: t.Dict[str, t.Any] = {}
|
|
2076
|
+
if error_trace is not None:
|
|
2077
|
+
__query["error_trace"] = error_trace
|
|
2078
|
+
if filter_path is not None:
|
|
2079
|
+
__query["filter_path"] = filter_path
|
|
2080
|
+
if human is not None:
|
|
2081
|
+
__query["human"] = human
|
|
2082
|
+
if pretty is not None:
|
|
2083
|
+
__query["pretty"] = pretty
|
|
2084
|
+
__headers = {"accept": "application/json"}
|
|
2085
|
+
return await self.perform_request( # type: ignore[return-value]
|
|
2086
|
+
"GET",
|
|
2087
|
+
__path,
|
|
2088
|
+
params=__query,
|
|
2089
|
+
headers=__headers,
|
|
2090
|
+
endpoint_id="security.get_stats",
|
|
2091
|
+
path_parts=__path_parts,
|
|
2092
|
+
)
|
|
2093
|
+
|
|
2055
2094
|
@_rewrite_parameters(
|
|
2056
2095
|
body_fields=(
|
|
2057
2096
|
"grant_type",
|
|
@@ -22,6 +22,9 @@ from elastic_transport import ObjectApiResponse
|
|
|
22
22
|
from ._base import NamespacedClient
|
|
23
23
|
from .utils import (
|
|
24
24
|
SKIP_IN_PATH,
|
|
25
|
+
Stability,
|
|
26
|
+
Visibility,
|
|
27
|
+
_availability_warning,
|
|
25
28
|
_quote,
|
|
26
29
|
_rewrite_parameters,
|
|
27
30
|
)
|
|
@@ -30,6 +33,7 @@ from .utils import (
|
|
|
30
33
|
class ShutdownClient(NamespacedClient):
|
|
31
34
|
|
|
32
35
|
@_rewrite_parameters()
|
|
36
|
+
@_availability_warning(Stability.STABLE, Visibility.PRIVATE)
|
|
33
37
|
async def delete_node(
|
|
34
38
|
self,
|
|
35
39
|
*,
|
|
@@ -90,6 +94,7 @@ class ShutdownClient(NamespacedClient):
|
|
|
90
94
|
)
|
|
91
95
|
|
|
92
96
|
@_rewrite_parameters()
|
|
97
|
+
@_availability_warning(Stability.STABLE, Visibility.PRIVATE)
|
|
93
98
|
async def get_node(
|
|
94
99
|
self,
|
|
95
100
|
*,
|
|
@@ -149,6 +154,7 @@ class ShutdownClient(NamespacedClient):
|
|
|
149
154
|
@_rewrite_parameters(
|
|
150
155
|
body_fields=("reason", "type", "allocation_delay", "target_node_name"),
|
|
151
156
|
)
|
|
157
|
+
@_availability_warning(Stability.STABLE, Visibility.PRIVATE)
|
|
152
158
|
async def put_node(
|
|
153
159
|
self,
|
|
154
160
|
*,
|
|
@@ -56,6 +56,7 @@ class SimulateClient(NamespacedClient):
|
|
|
56
56
|
t.Mapping[str, t.Mapping[str, t.Any]]
|
|
57
57
|
] = None,
|
|
58
58
|
mapping_addition: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
59
|
+
merge_type: t.Optional[t.Union[str, t.Literal["index", "template"]]] = None,
|
|
59
60
|
pipeline: t.Optional[str] = None,
|
|
60
61
|
pipeline_substitutions: t.Optional[
|
|
61
62
|
t.Mapping[str, t.Mapping[str, t.Any]]
|
|
@@ -93,6 +94,11 @@ class SimulateClient(NamespacedClient):
|
|
|
93
94
|
:param index_template_substitutions: A map of index template names to substitute
|
|
94
95
|
index template definition objects.
|
|
95
96
|
:param mapping_addition:
|
|
97
|
+
:param merge_type: The mapping merge type if mapping overrides are being provided
|
|
98
|
+
in mapping_addition. The allowed values are one of index or template. The
|
|
99
|
+
index option merges mappings the way they would be merged into an existing
|
|
100
|
+
index. The template option merges mappings the way they would be merged into
|
|
101
|
+
a template.
|
|
96
102
|
:param pipeline: The pipeline to use as the default pipeline. This value can
|
|
97
103
|
be used to override the default pipeline of the index.
|
|
98
104
|
:param pipeline_substitutions: Pipelines to test. If you don’t specify the `pipeline`
|
|
@@ -116,6 +122,8 @@ class SimulateClient(NamespacedClient):
|
|
|
116
122
|
__query["filter_path"] = filter_path
|
|
117
123
|
if human is not None:
|
|
118
124
|
__query["human"] = human
|
|
125
|
+
if merge_type is not None:
|
|
126
|
+
__query["merge_type"] = merge_type
|
|
119
127
|
if pipeline is not None:
|
|
120
128
|
__query["pipeline"] = pipeline
|
|
121
129
|
if pretty is not None:
|
|
@@ -872,35 +872,40 @@ class SnapshotClient(NamespacedClient):
|
|
|
872
872
|
|
|
873
873
|
:param name: The name of the repository.
|
|
874
874
|
:param blob_count: The total number of blobs to write to the repository during
|
|
875
|
-
the test. For realistic experiments,
|
|
875
|
+
the test. For realistic experiments, set this parameter to at least `2000`.
|
|
876
876
|
:param concurrency: The number of operations to run concurrently during the test.
|
|
877
|
+
For realistic experiments, leave this parameter unset.
|
|
877
878
|
:param detailed: Indicates whether to return detailed results, including timing
|
|
878
879
|
information for every operation performed during the analysis. If false,
|
|
879
880
|
it returns only a summary of the analysis.
|
|
880
881
|
:param early_read_node_count: The number of nodes on which to perform an early
|
|
881
882
|
read operation while writing each blob. Early read operations are only rarely
|
|
882
|
-
performed.
|
|
883
|
+
performed. For realistic experiments, leave this parameter unset.
|
|
883
884
|
:param max_blob_size: The maximum size of a blob to be written during the test.
|
|
884
|
-
For realistic experiments,
|
|
885
|
+
For realistic experiments, set this parameter to at least `2gb`.
|
|
885
886
|
:param max_total_data_size: An upper limit on the total size of all the blobs
|
|
886
|
-
written during the test. For realistic experiments,
|
|
887
|
+
written during the test. For realistic experiments, set this parameter to
|
|
887
888
|
at least `1tb`.
|
|
888
889
|
:param rare_action_probability: The probability of performing a rare action such
|
|
889
|
-
as an early read, an overwrite, or an aborted write on each blob.
|
|
890
|
+
as an early read, an overwrite, or an aborted write on each blob. For realistic
|
|
891
|
+
experiments, leave this parameter unset.
|
|
890
892
|
:param rarely_abort_writes: Indicates whether to rarely cancel writes before
|
|
891
|
-
they complete.
|
|
893
|
+
they complete. For realistic experiments, leave this parameter unset.
|
|
892
894
|
:param read_node_count: The number of nodes on which to read a blob after writing.
|
|
895
|
+
For realistic experiments, leave this parameter unset.
|
|
893
896
|
:param register_operation_count: The minimum number of linearizable register
|
|
894
|
-
operations to perform in total. For realistic experiments,
|
|
895
|
-
|
|
897
|
+
operations to perform in total. For realistic experiments, set this parameter
|
|
898
|
+
to at least `100`.
|
|
896
899
|
:param seed: The seed for the pseudo-random number generator used to generate
|
|
897
900
|
the list of operations performed during the test. To repeat the same set
|
|
898
901
|
of operations in multiple experiments, use the same seed in each experiment.
|
|
899
902
|
Note that the operations are performed concurrently so might not always happen
|
|
900
|
-
in the same order on each run.
|
|
903
|
+
in the same order on each run. For realistic experiments, leave this parameter
|
|
904
|
+
unset.
|
|
901
905
|
:param timeout: The period of time to wait for the test to complete. If no response
|
|
902
906
|
is received before the timeout expires, the test is cancelled and returns
|
|
903
|
-
an error.
|
|
907
|
+
an error. For realistic experiments, set this parameter sufficiently long
|
|
908
|
+
to allow the test to complete.
|
|
904
909
|
"""
|
|
905
910
|
if name in SKIP_IN_PATH:
|
|
906
911
|
raise ValueError("Empty value passed for parameter 'name'")
|
|
@@ -1266,6 +1271,11 @@ class SnapshotClient(NamespacedClient):
|
|
|
1266
1271
|
<p>If you omit the <code><snapshot></code> request path parameter, the request retrieves information only for currently running snapshots.
|
|
1267
1272
|
This usage is preferred.
|
|
1268
1273
|
If needed, you can specify <code><repository></code> and <code><snapshot></code> to retrieve information for specific snapshots, even if they're not currently running.</p>
|
|
1274
|
+
<p>Note that the stats will not be available for any shard snapshots in an ongoing snapshot completed by a node that (even momentarily) left the cluster.
|
|
1275
|
+
Loading the stats from the repository is an expensive operation (see the WARNING below).
|
|
1276
|
+
Therefore the stats values for such shards will be -1 even though the "stage" value will be "DONE", in order to minimize latency.
|
|
1277
|
+
A "description" field will be present for a shard snapshot completed by a departed node explaining why the shard snapshot's stats results are invalid.
|
|
1278
|
+
Consequently, the total stats for the index will be less than expected due to the missing values from these shards.</p>
|
|
1269
1279
|
<p>WARNING: Using the API to return the status of any snapshots other than currently running snapshots can be expensive.
|
|
1270
1280
|
The API requires a read from the repository for each shard in each snapshot.
|
|
1271
1281
|
For example, if you have 100 snapshots with 1,000 shards each, an API request that includes all snapshots will require 100,000 reads (100 snapshots x 1,000 shards).</p>
|
|
@@ -285,6 +285,7 @@ class SqlClient(NamespacedClient):
|
|
|
285
285
|
page_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
286
286
|
params: t.Optional[t.Sequence[t.Any]] = None,
|
|
287
287
|
pretty: t.Optional[bool] = None,
|
|
288
|
+
project_routing: t.Optional[str] = None,
|
|
288
289
|
query: t.Optional[str] = None,
|
|
289
290
|
request_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
290
291
|
runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
|
|
@@ -332,6 +333,10 @@ class SqlClient(NamespacedClient):
|
|
|
332
333
|
is no longer available. Subsequent scroll requests prolong the lifetime of
|
|
333
334
|
the scroll cursor by the duration of `page_timeout` in the scroll request.
|
|
334
335
|
:param params: The values for parameters in the query.
|
|
336
|
+
:param project_routing: Specifies a subset of projects to target for the search
|
|
337
|
+
using project metadata tags in a subset of Lucene query syntax. Allowed Lucene
|
|
338
|
+
queries: the _alias tag and a single value (possibly wildcarded). Examples:
|
|
339
|
+
_alias:my-project _alias:_origin _alias:*pr* Supported in serverless only.
|
|
335
340
|
:param query: The SQL query to run.
|
|
336
341
|
:param request_timeout: The timeout before the request fails.
|
|
337
342
|
:param runtime_mappings: One or more runtime fields for the search request. These
|
|
@@ -357,6 +362,8 @@ class SqlClient(NamespacedClient):
|
|
|
357
362
|
__query["human"] = human
|
|
358
363
|
if pretty is not None:
|
|
359
364
|
__query["pretty"] = pretty
|
|
365
|
+
if project_routing is not None:
|
|
366
|
+
__query["project_routing"] = project_routing
|
|
360
367
|
if not __body:
|
|
361
368
|
if allow_partial_search_results is not None:
|
|
362
369
|
__body["allow_partial_search_results"] = allow_partial_search_results
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
# specific language governing permissions and limitations
|
|
16
16
|
# under the License.
|
|
17
17
|
|
|
18
|
+
|
|
18
19
|
import typing as t
|
|
19
20
|
|
|
20
21
|
from elastic_transport import ObjectApiResponse, TextApiResponse
|
|
@@ -144,9 +145,7 @@ class StreamsClient(NamespacedClient):
|
|
|
144
145
|
error_trace: t.Optional[bool] = None,
|
|
145
146
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
146
147
|
human: t.Optional[bool] = None,
|
|
147
|
-
master_timeout: t.Optional[
|
|
148
|
-
t.Union[str, t.Literal["d", "h", "m", "micros", "ms", "nanos", "s"]]
|
|
149
|
-
] = None,
|
|
148
|
+
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
150
149
|
pretty: t.Optional[bool] = None,
|
|
151
150
|
) -> ObjectApiResponse[t.Any]:
|
|
152
151
|
"""
|
elasticsearch/_async/helpers.py
CHANGED
|
@@ -33,7 +33,9 @@ from typing import (
|
|
|
33
33
|
Union,
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
import sniffio
|
|
37
|
+
from anyio import create_memory_object_stream, create_task_group, move_on_after
|
|
38
|
+
|
|
37
39
|
from ..exceptions import ApiError, NotFoundError, TransportError
|
|
38
40
|
from ..helpers.actions import (
|
|
39
41
|
_TYPE_BULK_ACTION,
|
|
@@ -57,6 +59,15 @@ logger = logging.getLogger("elasticsearch.helpers")
|
|
|
57
59
|
T = TypeVar("T")
|
|
58
60
|
|
|
59
61
|
|
|
62
|
+
async def _sleep(seconds: float) -> None:
|
|
63
|
+
if sniffio.current_async_library() == "trio":
|
|
64
|
+
import trio
|
|
65
|
+
|
|
66
|
+
await trio.sleep(seconds)
|
|
67
|
+
else:
|
|
68
|
+
await asyncio.sleep(seconds)
|
|
69
|
+
|
|
70
|
+
|
|
60
71
|
async def _chunk_actions(
|
|
61
72
|
actions: AsyncIterable[_TYPE_BULK_ACTION_HEADER_WITH_META_AND_BODY],
|
|
62
73
|
chunk_size: int,
|
|
@@ -82,32 +93,36 @@ async def _chunk_actions(
|
|
|
82
93
|
chunk_size=chunk_size, max_chunk_bytes=max_chunk_bytes, serializer=serializer
|
|
83
94
|
)
|
|
84
95
|
|
|
96
|
+
action: _TYPE_BULK_ACTION_WITH_META
|
|
97
|
+
data: _TYPE_BULK_ACTION_BODY
|
|
85
98
|
if not flush_after_seconds:
|
|
86
99
|
async for action, data in actions:
|
|
87
100
|
ret = chunker.feed(action, data)
|
|
88
101
|
if ret:
|
|
89
102
|
yield ret
|
|
90
103
|
else:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
104
|
+
sender, receiver = create_memory_object_stream[
|
|
105
|
+
_TYPE_BULK_ACTION_HEADER_WITH_META_AND_BODY
|
|
106
|
+
]()
|
|
94
107
|
|
|
95
108
|
async def get_items() -> None:
|
|
96
109
|
try:
|
|
97
110
|
async for item in actions:
|
|
98
|
-
await
|
|
111
|
+
await sender.send(item)
|
|
99
112
|
finally:
|
|
100
|
-
await
|
|
113
|
+
await sender.send((BulkMeta.done, None))
|
|
114
|
+
|
|
115
|
+
async with create_task_group() as tg:
|
|
116
|
+
tg.start_soon(get_items)
|
|
101
117
|
|
|
102
|
-
async with safe_task(get_items()):
|
|
103
118
|
timeout: Optional[float] = flush_after_seconds
|
|
104
119
|
while True:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
)
|
|
120
|
+
action = {}
|
|
121
|
+
data = None
|
|
122
|
+
with move_on_after(timeout) as scope:
|
|
123
|
+
action, data = await receiver.receive()
|
|
109
124
|
timeout = flush_after_seconds
|
|
110
|
-
|
|
125
|
+
if scope.cancelled_caught:
|
|
111
126
|
action, data = BulkMeta.flush, None
|
|
112
127
|
timeout = None
|
|
113
128
|
|
|
@@ -294,9 +309,7 @@ async def async_streaming_bulk(
|
|
|
294
309
|
]
|
|
295
310
|
] = []
|
|
296
311
|
if attempt:
|
|
297
|
-
await
|
|
298
|
-
min(max_backoff, initial_backoff * 2 ** (attempt - 1))
|
|
299
|
-
)
|
|
312
|
+
await _sleep(min(max_backoff, initial_backoff * 2 ** (attempt - 1)))
|
|
300
313
|
|
|
301
314
|
try:
|
|
302
315
|
data: Union[
|