File tree Expand file tree Collapse file tree 2 files changed +2
-1
lines changed Expand file tree Collapse file tree 2 files changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -344,7 +344,7 @@ def __getitem__(self, n):
344
344
# Elasticsearch won't get all results so we default to size: 10 if
345
345
# stop not given.
346
346
s ._extra ['from' ] = n .start or 0
347
- s ._extra ['size' ] = n .stop - (n .start or 0 ) if n .stop is not None else 10
347
+ s ._extra ['size' ] = max ( 0 , n .stop - (n .start or 0 ) if n .stop is not None else 10 )
348
348
return s
349
349
else : # This is an index lookup, equivalent to slicing by [n:n+1].
350
350
# If negative index, abort.
Original file line number Diff line number Diff line change @@ -237,6 +237,7 @@ def test_slice():
237
237
assert {'from' : 0 , 'size' : 5 } == s [:5 ].to_dict ()
238
238
assert {'from' : 3 , 'size' : 10 } == s [3 :].to_dict ()
239
239
assert {'from' : 0 , 'size' : 0 } == s [0 :0 ].to_dict ()
240
+ assert {'from' : 20 , 'size' : 0 } == s [20 :0 ].to_dict ()
240
241
241
242
def test_index ():
242
243
s = search .Search ()
You can’t perform that action at this time.
0 commit comments