Skip to content

Commit a39466a

Browse files
committed
Update APIs+transport to 8.0.0-SNAPSHOT
1 parent d4c7bc1 commit a39466a

27 files changed

+446
-228
lines changed

docs/guide/configuration.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ es.options(retry_on_timeout=False).info()
207207
[discrete]
208208
==== Retrying status codes
209209

210-
By default if retries are enabled `retry_on_status` is set to `(429, 502, 503, 504)`. This parameter can be set on the client constructor or via the client `.options()` method. Setting this value to `False` or `()` will disable the default behavior.
210+
By default if retries are enabled `retry_on_status` is set to `(429, 502, 503, 504)`. This parameter can be set on the client constructor or via the client `.options()` method. Setting this value to `()` will disable the default behavior.
211211

212212
[source,python]
213213
------------------------------------
214214
es = Elasticsearch(
215215
...,
216-
retry_on_status=False
216+
retry_on_status=()
217217
)
218218
219219
# Retry this API on '500 Internal Error' statuses
@@ -265,12 +265,12 @@ IMPORTANT: When using an HTTP load balancer or proxy you cannot use sniffing fun
265265
[discrete]
266266
==== Waiting between sniffing attempts
267267

268-
To avoid needlessly sniffing too often there is a delay between attempts to discover new nodes. This value can be controlled via the `min_wait_between_sniffing` parameter.
268+
To avoid needlessly sniffing too often there is a delay between attempts to discover new nodes. This value can be controlled via the `min_delay_between_sniffing` parameter.
269269

270270
[discrete]
271271
==== Filtering nodes which are sniffed
272272

273-
By default nodes which are marked with only a `master` role will not be used. To change the behavior the parameter `sniff_filter`
273+
By default nodes which are marked with only a `master` role will not be used. To change the behavior the parameter `sniff_node_filter`
274274

275275

276276
[discrete]

docs/guide/connecting.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ from elasticsearch import Elasticsearch
126126
127127
# Adds the HTTP header 'Authorization: Bearer token-value'
128128
es = Elasticsearch(
129-
bearer_token="token-value"
129+
bearer_auth="token-value"
130130
)
131131
----------------------------
132132

elasticsearch/_async/client/__init__.py

Lines changed: 35 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -104,103 +104,6 @@ class AsyncElasticsearch(BaseClient):
104104
105105
# Set 'api_key' per request
106106
client.options(api_key=("id", "api_key")).search(...)
107-
108-
If you want to turn on :ref:`sniffing` you have several options (described
109-
in :class:`~elastic_transport.Transport`):
110-
111-
.. code-block:: python
112-
113-
# create connection that will automatically inspect the cluster to get
114-
# the list of active nodes. Start with nodes running on 'esnode1' and
115-
# 'esnode2'
116-
es = Elasticsearch(
117-
['esnode1', 'esnode2'],
118-
# sniff before doing anything
119-
sniff_on_start=True,
120-
# refresh nodes after a node fails to respond
121-
sniff_on_connection_fail=True,
122-
# and also every 60 seconds
123-
sniffer_timeout=60
124-
)
125-
126-
Different hosts can have different parameters, use a dictionary per node to
127-
specify those::
128-
129-
# connect to localhost directly and another node using SSL on port 443
130-
# and an url_prefix. Note that ``port`` needs to be an int.
131-
es = Elasticsearch([
132-
{'host': 'localhost'},
133-
{'host': 'othernode', 'port': 443, 'url_prefix': 'es', 'use_ssl': True},
134-
])
135-
136-
If using TLS/SSL, there are several parameters that control how we deal with
137-
certificates (see :class:`~elasticsearch.Urllib3HttpConnection` for
138-
detailed description of the options)::
139-
140-
es = Elasticsearch(
141-
['https://localhost:443', 'https://other_host:443'],
142-
# turn on SSL
143-
use_ssl=True,
144-
# make sure we verify SSL certificates
145-
verify_certs=True,
146-
# provide a path to CA certs on disk
147-
ca_certs='/path/to/CA_certs'
148-
)
149-
150-
If using SSL, but don't verify the certs, a warning message is showed
151-
optionally (see :class:`~elasticsearch.Urllib3HttpConnection` for
152-
detailed description of the options)::
153-
154-
es = Elasticsearch(
155-
['https://localhost:443', 'https://other_host:443'],
156-
# no verify SSL certificates
157-
verify_certs=False,
158-
# don't show warnings about ssl certs verification
159-
ssl_show_warn=False
160-
)
161-
162-
SSL client authentication is supported
163-
(see :class:`~elasticsearch.Urllib3HttpConnection` for
164-
detailed description of the options)::
165-
166-
es = Elasticsearch(
167-
['https://localhost:443', 'https://other_host:443'],
168-
# make sure we verify SSL certificates
169-
verify_certs=True,
170-
# provide a path to CA certs on disk
171-
ca_certs='/path/to/CA_certs',
172-
# PEM formatted SSL client certificate
173-
client_cert='/path/to/clientcert.pem',
174-
# PEM formatted SSL client key
175-
client_key='/path/to/clientkey.pem'
176-
)
177-
178-
Alternatively you can use RFC-1738 formatted URLs, as long as they are not
179-
in conflict with other options::
180-
181-
es = Elasticsearch(
182-
[
183-
'http://user:secret@localhost:9200/',
184-
'https://user:secret@other_host:443/production'
185-
],
186-
verify_certs=True
187-
)
188-
189-
By default, ``JsonSerializer`` is used to encode all outgoing requests.
190-
However, you can implement your own custom serializer::
191-
192-
from elasticsearch.serializer import JsonSerializer
193-
194-
class SetEncoder(JsonSerializer):
195-
def default(self, obj):
196-
if isinstance(obj, set):
197-
return list(obj)
198-
if isinstance(obj, Something):
199-
return 'CustomSomethingRepresentation'
200-
return JsonSerializer.default(self, obj)
201-
202-
es = Elasticsearch(serializer=SetEncoder())
203-
204107
"""
205108

206109
def __init__(
@@ -233,8 +136,8 @@ def __init__(
233136
node_pool_class=DEFAULT,
234137
randomize_nodes_in_pool=DEFAULT,
235138
node_selector_class=DEFAULT,
236-
dead_backoff_factor=DEFAULT,
237-
max_dead_backoff=DEFAULT,
139+
dead_node_backoff_factor=DEFAULT,
140+
max_dead_node_backoff=DEFAULT,
238141
serializers=DEFAULT,
239142
default_mimetype="application/json",
240143
max_retries=DEFAULT,
@@ -292,10 +195,10 @@ def __init__(
292195
transport_kwargs["randomize_nodes_in_pool"] = randomize_nodes_in_pool
293196
if node_selector_class is not DEFAULT:
294197
transport_kwargs["node_selector_class"] = node_selector_class
295-
if dead_backoff_factor is not DEFAULT:
296-
transport_kwargs["dead_backoff_factor"] = dead_backoff_factor
297-
if max_dead_backoff is not DEFAULT:
298-
transport_kwargs["max_dead_backoff"] = max_dead_backoff
198+
if dead_node_backoff_factor is not DEFAULT:
199+
transport_kwargs["dead_node_backoff_factor"] = dead_node_backoff_factor
200+
if max_dead_node_backoff is not DEFAULT:
201+
transport_kwargs["max_dead_node_backoff"] = max_dead_node_backoff
299202
if meta_header is not DEFAULT:
300203
transport_kwargs["meta_header"] = meta_header
301204
if serializers is DEFAULT:
@@ -2330,3 +2233,32 @@ async def search_mvt(
23302233
headers=headers,
23312234
body=body,
23322235
)
2236+
2237+
@query_params("routing")
2238+
async def knn_search(self, index, body=None, params=None, headers=None):
2239+
"""
2240+
Performs a kNN search.
2241+
2242+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html>`_
2243+
2244+
.. warning::
2245+
2246+
This API is **experimental** so may include breaking changes
2247+
or be removed in a future version
2248+
2249+
:arg index: A comma-separated list of index names to search; use
2250+
`_all` or empty string to perform the operation on all indices
2251+
:arg body: The search definition
2252+
:arg routing: A comma-separated list of specific routing values
2253+
"""
2254+
client, params = _deprecated_options(self, params)
2255+
if index in SKIP_IN_PATH:
2256+
raise ValueError("Empty value passed for a required argument 'index'.")
2257+
2258+
return await client._perform_request(
2259+
"POST",
2260+
_make_path(index, "_knn_search"),
2261+
params=params,
2262+
headers=headers,
2263+
body=body,
2264+
)

elasticsearch/_async/client/__init__.pyi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,3 +1176,22 @@ class AsyncElasticsearch(BaseClient):
11761176
params: Optional[MutableMapping[str, Any]] = ...,
11771177
headers: Optional[MutableMapping[str, str]] = ...,
11781178
) -> bytes: ...
1179+
async def knn_search(
1180+
self,
1181+
index: Any,
1182+
*,
1183+
body: Optional[Any] = ...,
1184+
routing: Optional[Any] = ...,
1185+
pretty: Optional[bool] = ...,
1186+
human: Optional[bool] = ...,
1187+
error_trace: Optional[bool] = ...,
1188+
format: Optional[str] = ...,
1189+
filter_path: Optional[Union[str, Collection[str]]] = ...,
1190+
request_timeout: Optional[Union[int, float]] = ...,
1191+
ignore: Optional[Union[int, Collection[int]]] = ...,
1192+
opaque_id: Optional[str] = ...,
1193+
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
1194+
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
1195+
params: Optional[MutableMapping[str, Any]] = ...,
1196+
headers: Optional[MutableMapping[str, str]] = ...,
1197+
) -> Any: ...

elasticsearch/_async/client/cluster.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ClusterClient(NamespacedClient):
2626
"level",
2727
"local",
2828
"master_timeout",
29+
"return_200_for_cluster_health_timeout",
2930
"timeout",
3031
"wait_for_active_shards",
3132
"wait_for_events",
@@ -50,6 +51,9 @@ async def health(self, index=None, params=None, headers=None):
5051
from master node (default: false)
5152
:arg master_timeout: Explicit operation timeout for connection
5253
to master node
54+
:arg return_200_for_cluster_health_timeout: Whether to return
55+
HTTP 200 instead of 408 in case of a cluster health timeout from the
56+
server side
5357
:arg timeout: Explicit operation timeout
5458
:arg wait_for_active_shards: Wait until the specified number of
5559
shards is active

elasticsearch/_async/client/cluster.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ClusterClient(NamespacedClient):
2828
level: Optional[Any] = ...,
2929
local: Optional[Any] = ...,
3030
master_timeout: Optional[Any] = ...,
31+
return_200_for_cluster_health_timeout: Optional[Any] = ...,
3132
timeout: Optional[Any] = ...,
3233
wait_for_active_shards: Optional[Any] = ...,
3334
wait_for_events: Optional[Any] = ...,

elasticsearch/_async/client/fleet.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,70 @@ async def global_checkpoints(self, index, params=None, headers=None):
4747
params=params,
4848
headers=headers,
4949
)
50+
51+
@query_params()
52+
async def msearch(self, body, index=None, params=None, headers=None):
53+
"""
54+
Multi Search API where the search will only be executed after specified
55+
checkpoints are available due to a refresh. This API is designed for internal
56+
use by the fleet server project.
57+
58+
.. warning::
59+
60+
This API is **experimental** so may include breaking changes
61+
or be removed in a future version
62+
63+
:arg body: The request definitions (metadata-fleet search
64+
request definition pairs), separated by newlines
65+
:arg index: The index name to use as the default
66+
"""
67+
client, params = _deprecated_options(self, params)
68+
if body in SKIP_IN_PATH:
69+
raise ValueError("Empty value passed for a required argument 'body'.")
70+
71+
headers["content-type"] = "application/x-ndjson"
72+
return await client._perform_request(
73+
"POST",
74+
_make_path(index, "_fleet", "_msearch"),
75+
params=params,
76+
headers=headers,
77+
body=body,
78+
)
79+
80+
@query_params(
81+
"allow_partial_search_results",
82+
"wait_for_checkpoints",
83+
"wait_for_checkpoints_timeout",
84+
)
85+
async def search(self, index, body=None, params=None, headers=None):
86+
"""
87+
Search API where the search will only be executed after specified checkpoints
88+
are available due to a refresh. This API is designed for internal use by the
89+
fleet server project.
90+
91+
.. warning::
92+
93+
This API is **experimental** so may include breaking changes
94+
or be removed in a future version
95+
96+
:arg index: The index name to search.
97+
:arg body: The search definition using the Query DSL
98+
:arg allow_partial_search_results: Indicate if an error should
99+
be returned if there is a partial search failure or timeout Default:
100+
True
101+
:arg wait_for_checkpoints: Comma separated list of checkpoints,
102+
one per shard
103+
:arg wait_for_checkpoints_timeout: Explicit wait_for_checkpoints
104+
timeout
105+
"""
106+
client, params = _deprecated_options(self, params)
107+
if index in SKIP_IN_PATH:
108+
raise ValueError("Empty value passed for a required argument 'index'.")
109+
110+
return await client._perform_request(
111+
"POST",
112+
_make_path(index, "_fleet", "_search"),
113+
params=params,
114+
headers=headers,
115+
body=body,
116+
)

elasticsearch/_async/client/fleet.pyi

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,42 @@ class FleetClient(NamespacedClient):
4141
params: Optional[MutableMapping[str, Any]] = ...,
4242
headers: Optional[MutableMapping[str, str]] = ...,
4343
) -> Any: ...
44+
async def msearch(
45+
self,
46+
*,
47+
body: Any,
48+
index: Optional[Any] = ...,
49+
pretty: Optional[bool] = ...,
50+
human: Optional[bool] = ...,
51+
error_trace: Optional[bool] = ...,
52+
format: Optional[str] = ...,
53+
filter_path: Optional[Union[str, Collection[str]]] = ...,
54+
request_timeout: Optional[Union[int, float]] = ...,
55+
ignore: Optional[Union[int, Collection[int]]] = ...,
56+
opaque_id: Optional[str] = ...,
57+
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
58+
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
59+
params: Optional[MutableMapping[str, Any]] = ...,
60+
headers: Optional[MutableMapping[str, str]] = ...,
61+
) -> Any: ...
62+
async def search(
63+
self,
64+
index: Any,
65+
*,
66+
body: Optional[Any] = ...,
67+
allow_partial_search_results: Optional[Any] = ...,
68+
wait_for_checkpoints: Optional[Any] = ...,
69+
wait_for_checkpoints_timeout: Optional[Any] = ...,
70+
pretty: Optional[bool] = ...,
71+
human: Optional[bool] = ...,
72+
error_trace: Optional[bool] = ...,
73+
format: Optional[str] = ...,
74+
filter_path: Optional[Union[str, Collection[str]]] = ...,
75+
request_timeout: Optional[Union[int, float]] = ...,
76+
ignore: Optional[Union[int, Collection[int]]] = ...,
77+
opaque_id: Optional[str] = ...,
78+
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
79+
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
80+
params: Optional[MutableMapping[str, Any]] = ...,
81+
headers: Optional[MutableMapping[str, str]] = ...,
82+
) -> Any: ...

elasticsearch/_async/client/indices.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,3 +1670,20 @@ async def field_usage_stats(self, index, params=None, headers=None):
16701670
params=params,
16711671
headers=headers,
16721672
)
1673+
1674+
@query_params()
1675+
async def modify_data_stream(self, body, params=None, headers=None):
1676+
"""
1677+
Modifies a data stream
1678+
1679+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html>`_
1680+
1681+
:arg body: The data stream modifications
1682+
"""
1683+
client, params = _deprecated_options(self, params)
1684+
if body in SKIP_IN_PATH:
1685+
raise ValueError("Empty value passed for a required argument 'body'.")
1686+
1687+
return await client._perform_request(
1688+
"POST", "/_data_stream/_modify", params=params, headers=headers, body=body
1689+
)

0 commit comments

Comments
 (0)