def test_get_connection(self): conn = solr.get_connection() conn = solr.get_connection() self.mock_solr.assert_called_once_with('http://localhost:8983/solr', http_user=None, http_pass=None) assert conn == self.mock_solr.return_value
def test_get_connection(self): conn = solr.get_connection() conn = solr.get_connection() self.mock_solr.assert_called_once_with( 'http://localhost:8983/solr', http_user=None, http_pass=None) assert conn == self.mock_solr.return_value
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')
def search(self): solrargs = dict(request.params) rows = min(1000, request.params.get('rows', 10)) q = request.params.get('q', '*:*') solrargs['q'] = amend_query(q) solrargs['rows'] = rows solrargs['wt'] = 'json' if 'callback' in solrargs and not 'json.wrf' in solrargs: solrargs['json.wrf'] = solrargs['callback'] if not 'sort' in solrargs: solrargs['sort'] = 'score desc,amount desc' query = solr.get_connection().raw_query(**solrargs) response.content_type = 'application/json' return query
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')
def search(self): solrargs = dict(request.params) rows = min(1000, int(request.params.get('rows', 10))) q = request.params.get('q', '*:*') solrargs['q'] = q solrargs['rows'] = rows solrargs['wt'] = 'json' datasets = model.Dataset.all_by_account(c.account) fq = ' OR '.join(map(lambda d: '+dataset:"%s"' % d.name, datasets)) solrargs['fq'] = '(%s)' % fq if 'callback' in solrargs and not 'json.wrf' in solrargs: solrargs['json.wrf'] = solrargs['callback'] if not 'sort' in solrargs: solrargs['sort'] = 'score desc,amount desc' try: query = solr.get_connection().raw_query(**solrargs) except solr.SolrException, se: response.status_int = se.httpcode return se.body
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 skip_if_stubbed_solr(): if type(_solr.get_connection()) == _solr._Stub: skip("Not running test with stubbed Solr.")
def clean_solr(): '''Clean all entries from Solr.''' s = _solr.get_connection() s.delete_query('*:*') s.commit()
def clean(): s = solr.get_connection() s.delete_query('*:*') s.commit() return 0
def clean_solr(): '''Clean all entries from Solr.''' s = solr.get_connection() s.delete_query('*:*') s.commit()
def query(self): data = solr.get_connection().raw_query(**_build_query(self.params)) return json.loads(data)
def skip_if_stubbed_solr(): from openspending.lib.solr_util import get_connection, _Stub if type(get_connection()) == _Stub: skip("Not running test with stubbed Solr.")
def optimize(): solr.get_connection().optimize() return 0
def clean_solr(): """Clean all entries from Solr.""" s = solr.get_connection() s.delete_query("*:*") s.commit()
def _query(self, **kwargs): kwargs.update({'wt': 'json'}) data = solr.get_connection().raw_query(**kwargs) return json.loads(data)
def clean_solr(): '''Clean all entries from Solr.''' from openspending.lib.solr_util import get_connection solr = get_connection() solr.delete_query('*:*') solr.commit()