def build_indices(self): if self.dry_run or not self.do_build_indices: return False log.info("Building search indices") solr.drop_index(self.model['dataset']['name']) solr.build_index(self.model['dataset']['name'])
def delete(self, dataset): self._get_dataset(dataset) require.dataset.delete(c.dataset) c.dataset.drop() solr.drop_index(c.dataset.name) db.session.delete(c.dataset) db.session.commit() h.flash_success(_("The dataset has been deleted.")) redirect(h.url_for(controller='dataset', action='index'))
def drop(self, dataset): self._get_dataset(dataset) require.dataset.update(c.dataset) c.dataset.drop() solr.drop_index(c.dataset.name) c.dataset.init() c.dataset.generate() AggregationCache(c.dataset).invalidate() db.session.commit() h.flash_success(_("The dataset has been cleared.")) redirect(h.url_for(controller='editor', action='index', dataset=c.dataset.name))
def drop(self, dataset): self._get_dataset(dataset) require.dataset.update(c.dataset) c.dataset.updated_at = datetime.utcnow() c.dataset.drop() solr.drop_index(c.dataset.name) c.dataset.init() c.dataset.generate() AggregationCache(c.dataset).invalidate() db.session.commit() h.flash_success(_("The dataset has been cleared.")) redirect( h.url_for(controller='editor', action='index', dataset=c.dataset.name))
def drop(self, dataset): self._get_dataset(dataset) require.dataset.update(c.dataset) c.dataset.updated_at = datetime.utcnow() c.dataset.drop() solr.drop_index(c.dataset.name) c.dataset.init() c.dataset.generate() AggregationCache(c.dataset).invalidate() # For every source in the dataset we set the status to removed for source in c.dataset.sources: for run in source.runs: run.status = Run.STATUS_REMOVED db.session.commit() h.flash_success(_("The dataset has been cleared.")) redirect(h.url_for(controller='editor', action='index', dataset=c.dataset.name))
def command(self): super(SolrCommand, self).command() if len(self.args) < 1: SolrCommand.parser.print_help() return 1 cmd = self.args[0] from openspending.lib import solr_util as solr if cmd == 'load': solr.build_index(self.args[1]) elif cmd == 'delete': solr.drop_index(self.args[1]) elif cmd == 'optimize': solr.optimize() elif cmd == 'clean': s = solr.get_connection() s.delete_query('*:*') s.commit() else: raise self.BadCommand("Subcommand '%s' not recognized " \ "by 'solr' command!" % cmd)
def delete(dataset): solr.drop_index(dataset) return 0
def test_drop_index(self): solr.drop_index('foo') self.mock_solr.return_value.delete_query.assert_called_once_with('dataset:foo') self.mock_solr.return_value.commit.assert_called_once()
def test_drop_index(self): solr.drop_index('foo') self.mock_solr.return_value.delete_query.assert_called_once_with( 'dataset:foo') self.mock_solr.return_value.commit.assert_called_once()