File tree 2 files changed +3
-1
lines changed
2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -326,7 +326,7 @@ def __getitem__(self, n):
326
326
raise ValueError ("Search does not support negative slicing." )
327
327
# Elasticsearch won't get all results so we default to size: 10 if
328
328
# stop not given.
329
- s ._extra ['from' ] = n .start or 0
329
+ s ._extra ['from' ] = ( n .start or 0 ) + s . _extra . get ( 'from' , 0 )
330
330
s ._extra ['size' ] = n .stop - (n .start or 0 ) if n .stop is not None else 10
331
331
return s
332
332
else : # This is an index lookup, equivalent to slicing by [n:n+1].
Original file line number Diff line number Diff line change @@ -246,6 +246,8 @@ def test_slice():
246
246
assert {'query' : {'match_all' : {}}, 'from' : 0 , 'size' : 5 } == s [:5 ].to_dict ()
247
247
assert {'query' : {'match_all' : {}}, 'from' : 3 , 'size' : 10 } == s [3 :].to_dict ()
248
248
assert {'query' : {'match_all' : {}}, 'from' : 0 , 'size' : 0 } == s [0 :0 ].to_dict ()
249
+ assert {'query' : {'match_all' : {}}, 'from' : 10 , 'size' : 5 } == s [10 :][:5 ].to_dict ()
250
+ assert {'query' : {'match_all' : {}}, 'from' : 15 , 'size' : 10 } == s [10 :][:5 ][5 :].to_dict ()
249
251
250
252
def test_index ():
251
253
s = search .Search ()
You can’t perform that action at this time.
0 commit comments