def handle(self, *args, **options): if not hasattr(settings, 'SEARCH'): raise CommandError('Django settings must include SEARCH dictionary setting') if options['verbosity'] > 0: self.stdout.write('Rebuilding search indices') result = rebuild_indices(settings.SEARCH, verbosity=options['verbosity']) for key, value in result.items(): count_value = value[0] if isinstance(value, tuple) else '?' self.stdout.write("Reindexed {} '{}' documents".format(count_value, key))
def test_rebuild_indices(self): result = rebuild_indices(self.SEARCH) self.assertIsNotNone(result) self.assertIsInstance(result, dict) self.index.refresh() expected_index_count = self.published_entry_count + self.published_project_count if not self.PUBLISH_FILTER_ENABLED: expected_index_count += self.unpublished_entry_count + self.unpublished_project_count self.assertEqual(expected_index_count, self.search.count())
def test_rebuild_indices_using_subtasks(self): result = rebuild_indices(self.SEARCH, subtask_indexing=True) get_worker().work(burst=True) self.assertIsNotNone(result) self.assertIsInstance(result, dict) self.index.refresh() expected_index_count = self.published_entry_count + self.published_project_count if not self.PUBLISH_FILTER_ENABLED: expected_index_count += self.unpublished_entry_count + self.unpublished_project_count self.assertEqual(expected_index_count, self.search.count())
def handle(self, *args, **options): if not hasattr(settings, 'SEARCH'): raise CommandError( 'Django settings must include SEARCH dictionary setting') if options['verbosity'] > 0: self.stdout.write('Rebuilding search indices') result = rebuild_indices(settings.SEARCH, verbosity=options['verbosity']) for key, value in result.items(): count_value = value[0] if isinstance(value, tuple) else '?' self.stdout.write("Reindexed {} '{}' documents".format( count_value, key))