Skip to content

Commit 68df569

Browse files
Merge branch '9.0' into backport-2860-to-9.0
2 parents 5dc1f0b + 01893c8 commit 68df569

File tree

10 files changed

+25
-17
lines changed

10 files changed

+25
-17
lines changed

docs/reference/dsl_how_to_guides.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ s = Search(index='i').query(Match("title", "python"))
8484
response = s.delete()
8585
```
8686

87+
To pass [deletion parameters](https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query)
88+
in your query, you can add them by calling ``params`` on the ``Search`` object before ``delete`` like this:
89+
90+
```python
91+
s = Search(index='i').query("match", title="python")
92+
s = s.params(ignore_unavailable=False, wait_for_completion=True)
93+
response = s.delete()
94+
```
95+
8796

8897
#### Queries [_queries]
8998

elasticsearch/_async/client/_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ async def _perform_request(
298298
def mimetype_header_to_compat(header: str) -> None:
299299
# Converts all parts of a Accept/Content-Type headers
300300
# from application/X -> application/vnd.elasticsearch+X
301-
nonlocal request_headers
302301
mimetype = request_headers.get(header, None)
303302
if mimetype:
304303
request_headers[header] = _COMPAT_MIMETYPE_RE.sub(

elasticsearch/_async/helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def aiter(x: Union[Iterable[T], AsyncIterable[T]]) -> AsyncIterator[T]:
136136
return x.__aiter__()
137137

138138
async def f() -> AsyncIterable[T]:
139-
nonlocal x
140139
ix: Iterable[T] = x
141140
for item in ix:
142141
yield item

elasticsearch/_sync/client/_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ def _perform_request(
298298
def mimetype_header_to_compat(header: str) -> None:
299299
# Converts all parts of a Accept/Content-Type headers
300300
# from application/X -> application/vnd.elasticsearch+X
301-
nonlocal request_headers
302301
mimetype = request_headers.get(header, None)
303302
if mimetype:
304303
request_headers[header] = _COMPAT_MIMETYPE_RE.sub(

elasticsearch/_sync/client/utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def client_node_configs(
134134

135135
def apply_node_options(node_config: NodeConfig) -> NodeConfig:
136136
"""Needs special handling of headers since .replace() wipes out existing headers"""
137-
nonlocal node_options
138137
headers = node_config.headers.copy() # type: ignore[attr-defined]
139138

140139
headers_to_add = node_options.pop("headers", ())
@@ -306,8 +305,6 @@ def _rewrite_parameters(
306305
def wrapper(api: F) -> F:
307306
@wraps(api)
308307
def wrapped(*args: Any, **kwargs: Any) -> Any:
309-
nonlocal api, body_name, body_fields
310-
311308
# Let's give a nicer error message when users pass positional arguments.
312309
if len(args) >= 2:
313310
raise TypeError(

elasticsearch/dsl/_async/search.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ async def scan(self) -> AsyncIterator[_R]:
107107
Turn the search into a scan search and return a generator that will
108108
iterate over all the documents matching the query.
109109
110-
Use ``params`` method to specify any additional arguments you with to
110+
Use the ``params`` method to specify any additional arguments you wish to
111111
pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
112-
https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan
112+
https://elasticsearch-py.readthedocs.io/en/latest/helpers.html#scan
113113
114114
The ``iterate()`` method should be preferred, as it provides similar
115115
functionality using an Elasticsearch point in time.
@@ -123,7 +123,11 @@ async def scan(self) -> AsyncIterator[_R]:
123123

124124
async def delete(self) -> AttrDict[Any]:
125125
"""
126-
delete() executes the query by delegating to delete_by_query()
126+
``delete()`` executes the query by delegating to ``delete_by_query()``.
127+
128+
Use the ``params`` method to specify any additional arguments you wish to
129+
pass to the underlying ``delete_by_query`` helper from ``elasticsearch-py`` -
130+
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query
127131
"""
128132

129133
es = get_connection(self._using)

elasticsearch/dsl/_sync/search.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def scan(self) -> Iterator[_R]:
104104
Turn the search into a scan search and return a generator that will
105105
iterate over all the documents matching the query.
106106
107-
Use ``params`` method to specify any additional arguments you with to
107+
Use the ``params`` method to specify any additional arguments you wish to
108108
pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
109-
https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan
109+
https://elasticsearch-py.readthedocs.io/en/latest/helpers.html#scan
110110
111111
The ``iterate()`` method should be preferred, as it provides similar
112112
functionality using an Elasticsearch point in time.
@@ -118,7 +118,11 @@ def scan(self) -> Iterator[_R]:
118118

119119
def delete(self) -> AttrDict[Any]:
120120
"""
121-
delete() executes the query by delegating to delete_by_query()
121+
``delete()`` executes the query by delegating to ``delete_by_query()``.
122+
123+
Use the ``params`` method to specify any additional arguments you wish to
124+
pass to the underlying ``delete_by_query`` helper from ``elasticsearch-py`` -
125+
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query
122126
"""
123127

124128
es = get_connection(self._using)

elasticsearch/dsl/faceted_search_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def params(self, **kwargs: Any) -> None:
469469
"""
470470
Specify query params to be used when executing the search. All the
471471
keyword arguments will override the current values. See
472-
https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search
472+
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.search
473473
for all available parameters.
474474
"""
475475
self._s = self._s.params(**kwargs)

test_elasticsearch/test_server/test_rest_api_spec.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@ def run_catch(self, catch, exception):
280280
self.last_response = exception.body
281281

282282
def run_skip(self, skip):
283-
global IMPLEMENTED_FEATURES
284-
285283
if "features" in skip:
286284
features = skip["features"]
287285
if not isinstance(features, (tuple, list)):
@@ -437,7 +435,7 @@ def _lookup(self, path):
437435
return value
438436

439437
def _feature_enabled(self, name):
440-
global XPACK_FEATURES, IMPLEMENTED_FEATURES
438+
global XPACK_FEATURES
441439
if XPACK_FEATURES is None:
442440
try:
443441
xinfo = self.client.xpack.info()

utils/build-dists.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def set_tmp_dir():
4242

4343

4444
def run(*argv, expect_exit_code=0):
45-
global tmp_dir
4645
try:
4746
prev_dir = os.getcwd()
4847
if tmp_dir is None:

0 commit comments

Comments
 (0)