Skip to content

Commit 7bdf7dc

Browse files
another batch of review updates
1 parent d06d804 commit 7bdf7dc

File tree

7 files changed

+63
-49
lines changed

7 files changed

+63
-49
lines changed

docs/api.rst

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,77 +4,47 @@ API Documentation
44
=================
55

66
Below please find the documentation for the public classes and functions of ``elasticsearch_dsl``.
7+
The :ref:`Asynchronous API <async_api>` classes are documented separately.
78

89
.. py:module:: elasticsearch_dsl
910
1011
Search
1112
------
1213

1314
.. autoclass:: Search
14-
:inherited-members:
1515
:members:
1616

1717
.. autoclass:: MultiSearch
18-
:inherited-members:
19-
:members:
20-
21-
.. autoclass:: AsyncSearch
22-
:inherited-members:
23-
:members:
24-
25-
.. autoclass:: AsyncMultiSearch
26-
:inherited-members:
2718
:members:
2819

2920
Document
3021
--------
3122

3223
.. autoclass:: Document
33-
:inherited-members:
34-
:members:
35-
36-
.. autoclass:: AsyncDocument
37-
:inherited-members:
3824
:members:
3925

4026
Index
4127
-----
4228

4329
.. autoclass:: Index
44-
:inherited-members:
45-
:members:
46-
47-
.. autoclass:: AsyncIndex
48-
:inherited-members:
4930
:members:
5031

5132
Faceted Search
5233
--------------
5334

5435
.. autoclass:: FacetedSearch
55-
:inherited-members:
56-
:members:
57-
58-
.. autoclass:: AsyncFacetedSearch
59-
:inherited-members:
6036
:members:
6137

6238
Update By Query
6339
----------------
64-
6540
.. autoclass:: UpdateByQuery
66-
:inherited-members:
67-
:members:
68-
69-
.. autoclass:: AsyncUpdateByQuery
70-
:inherited-members:
71-
:members:
41+
:members:
7242

7343
Mappings
7444
--------
7545

76-
If you wish to create mappings manually you can use the ``Mapping`` or ``AsyncMapping``
77-
classes, for more advanced use cases, however, we recommend you use the :ref:`doc_type`
46+
If you wish to create mappings manually you can use the ``Mapping`` class, for
47+
more advanced use cases, however, we recommend you use the :ref:`doc_type`
7848
abstraction in combination with :ref:`index` (or :ref:`index-template`) to define
7949
index-level settings and properties. The mapping definition follows a similar
8050
pattern to the query dsl:
@@ -139,5 +109,3 @@ Common field options:
139109

140110
``required``
141111
Indicates if a field requires a value for the document to be valid.
142-
143-

docs/async_api.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _async_api:
2+
3+
Asynchronous API
4+
================
5+
6+
Below please find the documentation for the asychronous classes of ``elasticsearch_dsl``.
7+
8+
.. py:module:: elasticsearch_dsl
9+
:no-index:
10+
11+
Search
12+
------
13+
14+
.. autoclass:: AsyncSearch
15+
:inherited-members:
16+
:members:
17+
18+
.. autoclass:: AsyncMultiSearch
19+
:inherited-members:
20+
:members:
21+
22+
Document
23+
--------
24+
25+
.. autoclass:: AsyncDocument
26+
:inherited-members:
27+
:members:
28+
29+
Index
30+
-----
31+
32+
.. autoclass:: AsyncIndex
33+
:inherited-members:
34+
:members:
35+
36+
Faceted Search
37+
--------------
38+
39+
.. autoclass:: AsyncFacetedSearch
40+
:inherited-members:
41+
:members:
42+
43+
Update By Query
44+
----------------
45+
46+
.. autoclass:: AsyncUpdateByQuery
47+
:inherited-members:
48+
:members:

docs/asyncio.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.. _asyncio:
22

3-
Using Asyncio with Elasticsearch DSL
3+
Using asyncio with Elasticsearch DSL
44
====================================
55

6-
The ``elasticsearch-dsl`` package supports async/await with `Asyncio <https://docs.python.org/3/library/asyncio.html>`__.
6+
The ``elasticsearch-dsl`` package supports async/await with `asyncio <https://docs.python.org/3/library/asyncio.html>`__.
77
To ensure that you have all the required dependencies, install the ``[async]`` extra:
88

99
.. code:: bash
@@ -88,5 +88,7 @@ synchronous versions, but any methods that perform I/O are defined as coroutines
8888
Auxiliary classes that do not perform I/O do not have asynchronous versions. The
8989
same classes can be used in synchronous and asynchronous applications.
9090

91-
You can consult the :ref:`api` section for details about each specific
92-
method.
91+
When using a :ref:`custom analyzer <Analysis>` in an asynchronous application, use
92+
the ``async_simulate()`` method to invoke the Analyze API on it.
93+
94+
Consult the :ref:`api` section for details about each specific method.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,6 @@ Contents
353353
update_by_query
354354
asyncio
355355
api
356+
async_api
356357
CONTRIBUTING
357358
Changelog

elasticsearch_dsl/search_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def index(self, *index):
159159
"""
160160
Set the index for the search. If called empty it will remove all information.
161161
162-
Example:
162+
Example::
163163
164164
s = Search()
165165
s = s.index('twitter-2015.01.01', 'twitter-2015.01.02')
@@ -560,6 +560,7 @@ def rank(self, rrf=None):
560560
:arg rrf: Set to ``True`` or an options dictionary to set the rank method to reciprocal rank fusion (RRF).
561561
562562
Example::
563+
563564
s = Search()
564565
s = s.query('match', content='search text')
565566
s = s.knn(field='embedding', k=5, num_candidates=10, query_vector=vector)

tests/_async/test_search.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ async def test_iter_iterates_over_hits():
5050
s = AsyncSearch()
5151
s._response = [1, 2, 3]
5252

53-
r = []
54-
async for hit in s:
55-
r.append(hit)
56-
assert [1, 2, 3] == r
53+
assert [1, 2, 3] == [hit async for hit in s]
5754

5855

5956
def test_cache_isnt_cloned():

tests/_sync/test_search.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ def test_iter_iterates_over_hits():
5050
s = Search()
5151
s._response = [1, 2, 3]
5252

53-
r = []
54-
for hit in s:
55-
r.append(hit)
56-
assert [1, 2, 3] == r
53+
assert [1, 2, 3] == [hit for hit in s]
5754

5855

5956
def test_cache_isnt_cloned():

0 commit comments

Comments
 (0)