Skip to content

Commit d2c644a

Browse files
Luna LucadouLuna Lucadou
authored andcommitted
Add param passing notes to documentation on Search.delete, fix broken links
The preferred way of passing parameters to `Search.delete` appears to be calling `Search.params` first, but this is only ever discussed in GitHub issues like #1115 and #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.
1 parent c063cfa commit d2c644a

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

docs/search_dsl.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ explicitly:
9898
9999
Delete By Query
100100
~~~~~~~~~~~~~~~
101+
101102
You can delete the documents matching a search by calling ``delete`` on the ``Search`` object instead of
102103
``execute`` like this:
103104

@@ -106,6 +107,14 @@ You can delete the documents matching a search by calling ``delete`` on the ``Se
106107
s = Search(index='i').query("match", title="python")
107108
response = s.delete()
108109
110+
To pass deletion parameters in your query, you can add them by calling ``params`` on the ``Search`` object before
111+
``delete`` like this:
112+
113+
.. code:: python
114+
115+
s = Search(index='i').query("match", title="python")
116+
s = s.params(ignore_unavailable=False, wait_for_completion=True)
117+
response = s.delete()
109118
110119
111120
Queries

elasticsearch_dsl/_async/search.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ async def scan(self) -> AsyncIterator[_R]:
106106
Turn the search into a scan search and return a generator that will
107107
iterate over all the documents matching the query.
108108
109-
Use ``params`` method to specify any additional arguments you with to
109+
Use the ``params`` method to specify any additional arguments you wish to
110110
pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
111-
https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan
111+
https://elasticsearch-py.readthedocs.io/en/latest/helpers.html#scan
112112
113113
The ``iterate()`` method should be preferred, as it provides similar
114114
functionality using an Elasticsearch point in time.
@@ -123,6 +123,11 @@ async def scan(self) -> AsyncIterator[_R]:
123123
async def delete(self) -> AttrDict[Any]:
124124
"""
125125
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/async.html#elasticsearch.AsyncElasticsearch.delete_by_query
126131
"""
127132

128133
es = get_connection(self._using)

elasticsearch_dsl/_sync/search.py

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

110110
def delete(self) -> AttrDict[Any]:
111111
"""
112-
delete() executes the query by delegating to delete_by_query()
112+
``delete()`` executes the query by delegating to ``delete_by_query()``.
113+
114+
Use the ``params`` method to specify any additional arguments you wish to
115+
pass to the underlying ``delete_by_query`` helper from ``elasticsearch-py`` -
116+
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query
113117
"""
114118

115119
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)

0 commit comments

Comments
 (0)