Esempio n. 1
0
    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'])
Esempio n. 2
0
    def setup(self):
        h.skip_if_stubbed_solr()

        super(TestApiSearch, self).setup()
        h.load_fixture('cra')
        solr.drop('*:*')
        solr.build_index(dataset_name='cra')
Esempio n. 3
0
    def setup(self):
        h.skip_if_stubbed_solr()

        super(TestApiSearch, self).setup()
        h.load_fixture("cra")
        solr.drop("*:*")
        solr.build_index(dataset_name="cra")
Esempio n. 4
0
def clean_and_reindex_solr():
    '''Clean Solr and reindex all entries in the database.'''
    clean_solr()
    from openspending.lib.solr_util import build_index
    from openspending.model import Dataset
    dataset_names = Dataset.c.distinct('name')
    for name in dataset_names:
        build_index(name)
Esempio n. 5
0
    def test_build_index_batch(self, mock_ee, mock_ds):
        ds = mock_ds.by_name.return_value
        ds.entries.return_value = [{'foo': 'bar'}] * 2500

        solr.build_index('mydataset')
        conn = self.mock_solr.return_value
        assert conn.add_many.call_count == 3
        assert conn.commit.call_count == 3
Esempio n. 6
0
    def test_build_index_batch(self, mock_ee, mock_ds):
        ds = mock_ds.by_name.return_value
        ds.entries.return_value = [{'foo': 'bar'}] * 2500

        solr.build_index('mydataset')
        conn = self.mock_solr.return_value
        h.assert_equal(conn.add_many.call_count, 3)
        h.assert_equal(conn.commit.call_count, 3)
Esempio n. 7
0
    def test_build_index(self, mock_ee, mock_ds):
        ds = mock_ds.by_name.return_value
        ds.entries.return_value = [{'foo': 123}, {'foo': 456}, {'foo': 789}]

        mock_ee.side_effect = lambda e, d: e['foo']

        solr.build_index('mydataset')
        conn = self.mock_solr.return_value
        conn.add_many.assert_called_once_with([123, 456, 789])
        conn.commit.assert_called_once()
Esempio n. 8
0
    def test_build_index(self, mock_ee, mock_ds):
        ds = mock_ds.by_name.return_value
        ds.entries.return_value = [{'foo': 123}, {'foo': 456}, {'foo': 789}]

        mock_ee.side_effect = lambda e, d: e['foo']

        solr.build_index('mydataset')
        conn = self.mock_solr.return_value
        conn.add_many.assert_called_once_with([123, 456, 789])
        conn.commit.assert_called_once()
Esempio n. 9
0
    def setup(self):
        h.skip_if_stubbed_solr()

        super(TestSearch, self).setup()
        h.load_fixture('cra')

        ourdict = {'_id': 'myspecialid', 'cofog1_ws': 'foobar'}

        self.solr = solr.get_connection()
        self.solr.add(**ourdict)
        self.solr.commit()

        solr.build_index(dataset_name='cra')
Esempio n. 10
0
    def setup(self):
        h.skip_if_stubbed_solr()

        super(TestSearch, self).setup()
        h.load_fixture('cra')

        ourdict = {
            '_id': 'myspecialid',
            'cofog1_ws': 'foobar'
        }

        self.solr = solr.get_connection()
        self.solr.add(**ourdict)
        self.solr.commit()

        solr.build_index(dataset_name='cra')
Esempio n. 11
0
    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)
Esempio n. 12
0
def index_dataset(dataset_name):
    from openspending.lib.solr_util import build_index
    build_index(dataset_name)
Esempio n. 13
0
def index_dataset(dataset_name):
    from openspending.lib.solr_util import build_index
    build_index(dataset_name)
Esempio n. 14
0
def load(dataset):
    solr.build_index(dataset)
    return 0
Esempio n. 15
0
def clean_and_reindex_solr():
    '''Clean Solr and reindex all entries in the database.'''
    clean_solr()
    for dataset in db.session.query(Dataset):
        _solr.build_index(dataset.name)
Esempio n. 16
0
def load(dataset):
    solr.build_index(dataset)
    return 0
Esempio n. 17
0
    def setup(self):
        h.skip_if_stubbed_solr()

        super(TestApiSearch, self).setup()
        h.load_fixture('cra')
        solr.build_index(dataset_name='cra')
Esempio n. 18
0
def clean_and_reindex_solr():
    '''Clean Solr and reindex all entries in the database.'''
    clean_solr()
    for dataset in db.session.query(Dataset):
        solr.build_index(dataset.name)
Esempio n. 19
0
def clean_and_reindex_solr():
    '''Clean Solr and reindex all entries in the database.'''
    clean_solr()
    dataset_names = _model.dataset.distinct('name')
    for name in dataset_names:
        _solr.build_index(name)