bulk_index helper to easily load docs into ES

This commit is contained in:
Honza Kral
2013-08-01 14:48:39 +02:00
parent fae0fdb254
commit 5b1a2fd650
2 changed files with 41 additions and 0 deletions
@@ -0,0 +1,13 @@
from elasticsearch import helpers
from . import ElasticTestCase
class TestBulkIndex(ElasticTestCase):
def test_all_documents_get_inserted(self):
docs = [{"answer": x} for x in range(100)]
success, failed = helpers.bulk_index(self.client, docs, index='test-index', doc_type='answers', refresh=True)
self.assertEquals(len(success), len(docs))
self.assertFalse(failed)
self.assertEquals(len(docs), self.client.count(index='test-index', doc_type='answers')['count'])