diff --git a/docs/search_dsl.rst b/docs/search_dsl.rst index 83756f97f..e19043100 100644 --- a/docs/search_dsl.rst +++ b/docs/search_dsl.rst @@ -98,6 +98,7 @@ explicitly: Delete By Query ~~~~~~~~~~~~~~~ + You can delete the documents matching a search by calling ``delete`` on the ``Search`` object instead of ``execute`` like this: @@ -106,6 +107,14 @@ You can delete the documents matching a search by calling ``delete`` on the ``Se s = Search(index='i').query("match", title="python") response = s.delete() +To pass deletion parameters in your query, you can add them by calling ``params`` on the ``Search`` object before +``delete`` like this: + +.. code:: python + + s = Search(index='i').query("match", title="python") + s = s.params(ignore_unavailable=False, wait_for_completion=True) + response = s.delete() Queries diff --git a/elasticsearch_dsl/_async/search.py b/elasticsearch_dsl/_async/search.py index 94fbe2897..1de216db6 100644 --- a/elasticsearch_dsl/_async/search.py +++ b/elasticsearch_dsl/_async/search.py @@ -106,9 +106,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. @@ -123,6 +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/async.html#elasticsearch.AsyncElasticsearch.delete_by_query """ es = get_connection(self._using) diff --git a/elasticsearch_dsl/_sync/search.py b/elasticsearch_dsl/_sync/search.py index f3906f59f..7e2470f37 100644 --- a/elasticsearch_dsl/_sync/search.py +++ b/elasticsearch_dsl/_sync/search.py @@ -95,9 +95,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. @@ -109,7 +109,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) diff --git a/elasticsearch_dsl/faceted_search_base.py b/elasticsearch_dsl/faceted_search_base.py index 45e00a00f..efc7815ec 100644 --- a/elasticsearch_dsl/faceted_search_base.py +++ b/elasticsearch_dsl/faceted_search_base.py @@ -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)