Tests for reindex accepting a query
This commit is contained in:
@@ -165,13 +165,25 @@ class TestScan(ElasticsearchTestCase):
|
||||
self.assertEquals(set(range(100)), set(d['_source']['answer'] for d in docs))
|
||||
|
||||
class TestReindex(ElasticsearchTestCase):
|
||||
def test_all_documents_get_moved(self):
|
||||
def setUp(self):
|
||||
super(TestReindex, self).setUp()
|
||||
bulk = []
|
||||
for x in range(100):
|
||||
bulk.append({"index": {"_index": "test_index", "_type": "answers" if x % 2 == 0 else "questions", "_id": x}})
|
||||
bulk.append({"answer": x, "correct": x == 42})
|
||||
self.client.bulk(bulk, refresh=True)
|
||||
|
||||
def test_reindex_accepts_a_query(self):
|
||||
helpers.reindex(self.client, "test_index", "prod_index", query={"query": {"filtered": {"filter": {"term": {"_type": "answers"}}}}})
|
||||
self.client.indices.refresh()
|
||||
|
||||
self.assertTrue(self.client.indices.exists("prod_index"))
|
||||
self.assertFalse(self.client.indices.exists_type(index='prod_index', doc_type='questions'))
|
||||
self.assertEquals(50, self.client.count(index='prod_index', doc_type='answers')['count'])
|
||||
|
||||
self.assertEquals({"answer": 42, "correct": True}, self.client.get(index="prod_index", doc_type="answers", id=42)['_source'])
|
||||
|
||||
def test_all_documents_get_moved(self):
|
||||
helpers.reindex(self.client, "test_index", "prod_index")
|
||||
self.client.indices.refresh()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user