Skip to content

Commit b6d1211

Browse files
lunalucadouLuna Lucadoumiguelgrinberg
authored
[docs] Add param notes to DSL search.delete documentation, fix broken links (#2861)
* Add param notes to DSL search.delete documentation, fix broken links The preferred way of passing parameters to the DSL `Search.delete` appears to be calling `Search.params` first, but this is only ever discussed in GitHub issues like elastic/elasticsearch-dsl-py#1115 and elastic/elasticsearch-dsl-py#1395. To help anyone else who has stumbled across this, I added a note about this to the documentation. I also went ahead and updated the links for the `Search.scan` and `FacetedSearch.params` methods to the most recent versions since they were 404ing. * make sync and async changes the same --------- Co-authored-by: Luna Lucadou <[email protected]> Co-authored-by: Miguel Grinberg <[email protected]>
1 parent 83025a6 commit b6d1211

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

Diff for: docs/reference/dsl_how_to_guides.md

+9
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

Diff for: elasticsearch/dsl/_async/search.py

+7-3
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)

Diff for: elasticsearch/dsl/_sync/search.py

+7-3
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)

Diff for: elasticsearch/dsl/faceted_search_base.py

+1-1
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)

0 commit comments

Comments
 (0)