Skip to content

Commit 0074785

Browse files
add more slicing examples to documentation
1 parent 9725e54 commit 0074785

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/search_dsl.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,25 @@ To specify the from/size parameters, use the Python slicing API:
410410

411411
.. code:: python
412412
413-
s = s[10:20]
414-
# {"from": 10, "size": 10}
413+
s = s[10:20]
414+
# {"from": 10, "size": 10}
415+
416+
s = s[:20]
417+
# {"size": 20}
418+
419+
s = s[10:]
420+
# {"from": 10}
421+
422+
s = s[10:20][2:]
423+
# {"from": 12, "size": 8}
415424
416425
If you want to access all the documents matched by your query you can use the
417426
``scan`` method which uses the scan/scroll elasticsearch API:
418427

419428
.. code:: python
420429
421-
for hit in s.scan():
422-
print(hit.title)
430+
for hit in s.scan():
431+
print(hit.title)
423432
424433
Note that in this case the results won't be sorted.
425434

0 commit comments

Comments
 (0)