Skip to content

[Backport 9.0] [docs] Add param notes to DSL search.delete documentation, fix broken links #2869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/reference/dsl_how_to_guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ s = Search(index='i').query(Match("title", "python"))
response = s.delete()
```

To pass [deletion parameters](https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query)
in your query, you can add them by calling ``params`` on the ``Search`` object before ``delete`` like this:

```python
s = Search(index='i').query("match", title="python")
s = s.params(ignore_unavailable=False, wait_for_completion=True)
response = s.delete()
```


#### Queries [_queries]

Expand Down
10 changes: 7 additions & 3 deletions elasticsearch/dsl/_async/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ async def scan(self) -> AsyncIterator[_R]:
Turn the search into a scan search and return a generator that will
iterate over all the documents matching the query.

Use ``params`` method to specify any additional arguments you with to
Use the ``params`` method to specify any additional arguments you wish to
pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan
https://elasticsearch-py.readthedocs.io/en/latest/helpers.html#scan

The ``iterate()`` method should be preferred, as it provides similar
functionality using an Elasticsearch point in time.
Expand All @@ -123,7 +123,11 @@ async def scan(self) -> AsyncIterator[_R]:

async def delete(self) -> AttrDict[Any]:
"""
delete() executes the query by delegating to delete_by_query()
``delete()`` executes the query by delegating to ``delete_by_query()``.

Use the ``params`` method to specify any additional arguments you wish to
pass to the underlying ``delete_by_query`` helper from ``elasticsearch-py`` -
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query
"""

es = get_connection(self._using)
Expand Down
10 changes: 7 additions & 3 deletions elasticsearch/dsl/_sync/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def scan(self) -> Iterator[_R]:
Turn the search into a scan search and return a generator that will
iterate over all the documents matching the query.

Use ``params`` method to specify any additional arguments you with to
Use the ``params`` method to specify any additional arguments you wish to
pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan
https://elasticsearch-py.readthedocs.io/en/latest/helpers.html#scan

The ``iterate()`` method should be preferred, as it provides similar
functionality using an Elasticsearch point in time.
Expand All @@ -118,7 +118,11 @@ def scan(self) -> Iterator[_R]:

def delete(self) -> AttrDict[Any]:
"""
delete() executes the query by delegating to delete_by_query()
``delete()`` executes the query by delegating to ``delete_by_query()``.

Use the ``params`` method to specify any additional arguments you wish to
pass to the underlying ``delete_by_query`` helper from ``elasticsearch-py`` -
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query
"""

es = get_connection(self._using)
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/dsl/faceted_search_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def params(self, **kwargs: Any) -> None:
"""
Specify query params to be used when executing the search. All the
keyword arguments will override the current values. See
https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.search
https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.search
for all available parameters.
"""
self._s = self._s.params(**kwargs)
Expand Down
Loading