Skip to content

Commit

Permalink
Slice 0:0 should set size: 0
Browse files Browse the repository at this point in the history
Fixes #148 Thanks for the report dblado.
  • Loading branch information
honzakral committed May 1, 2015
1 parent 703015e commit 32c1749
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elasticsearch_dsl/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __getitem__(self, n):
# Elasticsearch won't get all results so we default to size: 10 if
# stop not given.
s._extra['from'] = n.start or 0
s._extra['size'] = n.stop - (n.start or 0) if n.stop else 10
s._extra['size'] = n.stop - (n.start or 0) if n.stop is not None else 10
return s
else: # This is an index lookup, equivalent to slicing by [n:n+1].
# If negative index, abort.
Expand Down
1 change: 1 addition & 0 deletions test_elasticsearch_dsl/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def test_slice():
assert {'query': {'match_all': {}}, 'from': 3, 'size': 7} == s[3:10].to_dict()
assert {'query': {'match_all': {}}, 'from': 0, 'size': 5} == s[:5].to_dict()
assert {'query': {'match_all': {}}, 'from': 3, 'size': 10} == s[3:].to_dict()
assert {'query': {'match_all': {}}, 'from': 0, 'size': 0} == s[0:0].to_dict()

def test_index():
s = search.Search()
Expand Down

0 comments on commit 32c1749

Please sign in to comment.