refactor(search/elastic): Removed CRUD methods from rebuilder classes

The .start() method now returns an ElasticSearchIndex object that you should perform CRUD operations against instead

This commit removes a nice test that will be reintroduced later
pull/2064/merge
Karl Hobley 2015-12-17 15:36:31 +00:00 zatwierdzone przez Matt Westcott
rodzic 4441232fe3
commit 27f50a527c
3 zmienionych plików z 6 dodań i 32 usunięć

Wyświetl plik

@ -540,11 +540,7 @@ class ElasticSearchIndexRebuilder(object):
# Reset the index
self.reset_index()
def add_model(self, model):
self.index.add_model(model)
def add_items(self, model, obj_list):
self.index.add_items(model, obj_list)
return self.index
def finish(self):
self.index.refresh()
@ -573,6 +569,8 @@ class ElasticSearchAtomicIndexRebuilder(ElasticSearchIndexRebuilder):
# Create the new index
self.index.put()
return self.index
def finish(self):
self.index.refresh()

Wyświetl plik

@ -32,7 +32,7 @@ class Command(BaseCommand):
# Start rebuild
self.stdout.write(backend_name + ": Starting rebuild")
rebuilder.start()
index = rebuilder.start()
for model, queryset in object_list:
self.stdout.write(backend_name + ": Indexing model '%s.%s'" % (
@ -41,12 +41,12 @@ class Command(BaseCommand):
))
# Add model
rebuilder.add_model(model)
index.add_model(model)
# Add items (1000 at a time)
count = 0
for chunk in self.print_iter_progress(self.queryset_chunks(queryset)):
rebuilder.add_items(model, chunk)
index.add_items(model, chunk)
count += len(chunk)
self.stdout.write("Indexed %d %s" % (

Wyświetl plik

@ -997,30 +997,6 @@ class TestRebuilder(TestCase):
self.es.indices.exists_alias(name='this_index_should_be_deleted', index=self.backend.index_name)
)
def test_add_model(self):
self.rebuilder.start()
# Add model
self.rebuilder.add_model(models.SearchTest)
# Check the mapping went into Elasticsearch correctly
mapping = ElasticSearch.mapping_class(models.SearchTest)
response = self.es.indices.get_mapping(self.backend.index_name, mapping.get_document_type())
# Make some minor tweaks to the mapping so it matches what is in ES
# These are generally minor issues with the way Wagtail is
# generating the mapping that are being cleaned up by Elasticsearch
# TODO: Would be nice to fix these
expected_mapping = mapping.get_mapping()
expected_mapping['searchtests_searchtest']['properties']['pk']['store'] = True
expected_mapping['searchtests_searchtest']['properties']['live_filter'].pop('index')
expected_mapping['searchtests_searchtest']['properties']['live_filter'].pop('include_in_all')
expected_mapping['searchtests_searchtest']['properties']['published_date_filter']['format'] = \
'dateOptionalTime'
expected_mapping['searchtests_searchtest']['properties']['published_date_filter'].pop('index')
self.assertDictEqual(expected_mapping, response[self.backend.index_name]['mappings'])
@unittest.skipUnless(os.environ.get('ELASTICSEARCH_URL', False), "ELASTICSEARCH_URL not set")
class TestAtomicRebuilder(TestCase):