def get_paginated_entity_name_modtime(self, max_results=1000, start=0): """ Return a list of the name and metadata_modified s of indexed packages. """ query = "*: *" fq = "+site_id: \"%s\" " % config.get('ckan.site_id') fq += "+state: active " conn = make_connection() try: data = conn.search(query, fq=fq, rows=max_results, fields='name,metadata_modified', start=start, sort='metadata_created asc') except Exception as e: error = 'Error in GeoPackageSearchQuery.get_paginated_entity_name_modtime: {}'.format( e) log.error(error) print(error) return [{ 'name': r.get('name'), 'metadata_modified': r.get('metadata_modified') } for r in data.docs]
def setup_class(self): print ("") if not search.is_available(): raise Exception('Solr not reachable') self.solr_client = search.make_connection() self.fq = " +site_id:\"%s\" +md_author_names:[* TO *] +md_content_models:[* TO *] +md_organization_names:[* TO *] +res_format:[* TO *] " % config['ckan.site_id']
def setup_class(self): print("") if not search.is_available(): raise Exception('Solr not reachable') self.solr_client = search.make_connection() self.fq = " +site_id:\"%s\" +md_author_names:[* TO *] +md_content_models:[* TO *] +md_organization_names:[* TO *] +res_format:[* TO *] " % config[ 'ckan.site_id']
def test_solr_url_exists(self): if not is_search_supported(): from nose import SkipTest raise SkipTest("Search not supported") conn = search.make_connection() try: # solr.SolrConnection.query will throw a socket.error if it # can't connect to the SOLR instance q = conn.search(q="*:*", rows=1) except pysolr.SolrError, e: if not config.get('solr_url'): raise AssertionError("Config option 'solr_url' needs to be defined in this CKAN's development.ini. Default of %s didn't work: %s" % (search.DEFAULT_SOLR_URL, e)) else: raise AssertionError('SOLR connection problem. Connection defined in development.ini as: solr_url=%s Error: %s' % (config['solr_url'], e))
def get_count(self): """ Return the count of all indexed packages. """ query = "*:*" fq = "+site_id:\"%s\" " % config.get('ckan.site_id') fq += "+state:active " conn = make_connection() try: data = conn.search(query, fq=fq, rows=0) except Exception, e: error = 'Error in GeoPackageSearchQuery.get_count: {}'.format(e) log.error(error) print(error)
def setup_class(cls): cls.solr_client = search.make_connection() cls.fq = ' +site_id:"%s" ' % config["ckan.site_id"] cls.package_index = search.PackageSearchIndex() cls.base_package_dict = { "id": "test-index", "name": "monkey", "title": "Monkey", "state": "active", "private": False, "type": "dataset", "owner_org": None, "metadata_created": datetime.datetime.now().isoformat(), "metadata_modified": datetime.datetime.now().isoformat(), }
def setup_class(cls): if not search.is_available(): raise nose.SkipTest('Solr not reachable') cls.solr_client = search.make_connection() cls.fq = " +site_id:\"%s\" " % config['ckan.site_id'] cls.package_index = search.PackageSearchIndex() cls.base_package_dict = { 'id': 'test-index', 'name': 'monkey', 'title': 'Monkey', 'state': 'active', 'private': False, 'type': 'dataset', 'owner_org': None, 'metadata_created': datetime.datetime.now().isoformat(), 'metadata_modified': datetime.datetime.now().isoformat(), }
def setup_class(cls): setup_test_search_index() CreateTestData.create_search_test_data() cls.solr = search.make_connection() cls.fq = " +site_id:\"%s\" " % config['ckan.site_id'] search.rebuild()
def setup_class(cls): setup_test_search_index() CreateTestData.create() cls.solr = search.make_connection() cls.fq = " +site_id:\"%s\" " % config['ckan.site_id']
def setup_class(cls): setup_test_search_index() CreateTestData.create() cls.solr = search.make_connection() cls.fq = ' +site_id:"%s" ' % config["ckan.site_id"]
def initial_data(self, clean_db, clean_index): setup_test_search_index() CreateTestData.create_search_test_data() self.solr = search.make_connection() self.fq = ' +site_id:"%s" ' % config["ckan.site_id"] search.rebuild()