Skip to content

Commit

Permalink
add more slicing examples to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed May 16, 2024
1 parent 908cd40 commit 863f033
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions docs/search_dsl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,25 @@ To specify the from/size parameters, use the Python slicing API:

.. code:: python
s = s[10:20]
# {"from": 10, "size": 10}
s = s[10:20]
# {"from": 10, "size": 10}
s = s[:20]
# {"size": 20}
s = s[10:]
# {"from": 10}
s = s[10:20][2:]
# {"from": 12, "size": 8}
If you want to access all the documents matched by your query you can use the
``scan`` method which uses the scan/scroll elasticsearch API:

.. code:: python
for hit in s.scan():
print(hit.title)
for hit in s.scan():
print(hit.title)
Note that in this case the results won't be sorted.

Expand Down

0 comments on commit 863f033

Please sign in to comment.