Add offset when getting single item. Fixes #1271

This commit is contained in:
Karl Hobley 2015-05-05 16:45:26 +01:00
parent 375b25c1e5
commit fcec9936ad
2 changed files with 2 additions and 3 deletions

View file

@ -155,8 +155,8 @@ class BaseSearchResults(object):
if self._results_cache is not None:
return self._results_cache[key]
new.start = key
new.stop = key + 1
new.start = self.start + key
new.stop = self.start + key + 1
return list(new)[0]
def __iter__(self):

View file

@ -454,7 +454,6 @@ class TestElasticSearchResults(TestCase):
size=10
)
@unittest.expectedFailure # 1271
@mock.patch('elasticsearch.Elasticsearch.search')
def test_slice_results_and_get_item(self, search):
# Need to return something to prevent index error