Add an option to use scan helper without search_type=scan, use with caution

Fixes #160
This commit is contained in:
Honza Král
2014-12-15 15:15:03 +01:00
parent a23772ba27
commit 9b5d2c062e
2 changed files with 28 additions and 4 deletions
@@ -138,6 +138,19 @@ class TestBulk(ElasticsearchTestCase):
class TestScan(ElasticsearchTestCase):
def test_order_can_be_preserved(self):
bulk = []
for x in range(100):
bulk.append({"index": {"_index": "test_index", "_type": "answers", "_id": x}})
bulk.append({"answer": x, "correct": x == 42})
self.client.bulk(bulk, refresh=True)
docs = list(helpers.scan(self.client, index="test_index", doc_type="answers", size=2, query={"sort": ["answer"]}, preserve_order=True))
self.assertEquals(100, len(docs))
self.assertEquals(list(map(str, range(100))), list(d['_id'] for d in docs))
self.assertEquals(list(range(100)), list(d['_source']['answer'] for d in docs))
def test_all_documents_are_read(self):
bulk = []
for x in range(100):