當前位置: 首頁>>代碼示例>>Python>>正文


Python pysolr.SolrError方法代碼示例

本文整理匯總了Python中pysolr.SolrError方法的典型用法代碼示例。如果您正苦於以下問題:Python pysolr.SolrError方法的具體用法?Python pysolr.SolrError怎麽用?Python pysolr.SolrError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pysolr的用法示例。


在下文中一共展示了pysolr.SolrError方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: solr_counts

# 需要導入模塊: import pysolr [as 別名]
# 或者: from pysolr import SolrError [as 別名]
def solr_counts():
    total_q = SearchQuerySet()
    latest_q = total_q.filter(latest=True)
    registrations_q = latest_q.filter(category="entity_status::ACT")
    last_24h = datetime.now() - timedelta(days=1)
    last_week = datetime.now() - timedelta(days=7)
    last_month = datetime.now() - timedelta(days=30)
    last_24h_q = total_q.filter(create_timestamp__gte=last_24h)
    last_week_q = total_q.filter(create_timestamp__gte=last_week)
    last_month_q = total_q.filter(create_timestamp__gte=last_month)
    try:
        return {
            "total_indexed_items": total_q.count(),
            "active": latest_q.count(),
            "registrations": registrations_q.count(),
            "last_month": last_month_q.count(),
            "last_week": last_week_q.count(),
            "last_24h": last_24h_q.count(),
        }
    except SolrError:
        LOGGER.exception("Error when retrieving quickload counts from Solr")
        return False 
開發者ID:bcgov,項目名稱:aries-vcr,代碼行數:24,代碼來源:utils.py

示例2: solr_counts

# 需要導入模塊: import pysolr [as 別名]
# 或者: from pysolr import SolrError [as 別名]
def solr_counts():
    total_q = SearchQuerySet()
    latest_q = total_q.filter(latest=True)
    registrations_q = latest_q.filter(category="entity_status::ACT")
    last_24h = datetime.now() - timedelta(days=1)
    last_week = datetime.now() - timedelta(days=7)
    last_month = datetime.now() - timedelta(days=30)
    last_24h_q = total_q.filter(create_timestamp__gte=last_24h)
    last_week_q = total_q.filter(create_timestamp__gte=last_week)
    last_month_q = total_q.filter(create_timestamp__gte=last_month)
    try:
        return {
            "total": total_q.count(),
            "active": latest_q.count(),
            "registrations": registrations_q.count(),
            "last_month": last_month_q.count(),
            "last_week": last_week_q.count(),
            "last_24h": last_24h_q.count(),
        }
    except SolrError:
        LOGGER.exception("Error when retrieving quickload counts from Solr")
        return False 
開發者ID:bcgov,項目名稱:TheOrgBook,代碼行數:24,代碼來源:utils.py

示例3: test_solr_url_exists

# 需要導入模塊: import pysolr [as 別名]
# 或者: from pysolr import SolrError [as 別名]
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)) 
開發者ID:italia,項目名稱:daf-recipes,代碼行數:17,代碼來源:test_solr_search_index.py

示例4: get_index

# 需要導入模塊: import pysolr [as 別名]
# 或者: from pysolr import SolrError [as 別名]
def get_index(self,reference):
        query = {
            'rows': 1,
            'q': 'name:"%s" OR id:"%s"' % (reference,reference),
            'wt': 'json',
            'fq': 'site_id:"%s"' % config.get('ckan.site_id')}

        conn = make_connection(decode_dates=False)
        log.debug('Package query: %r' % query)
        try:
            solr_response = conn.search(**query)
        except pysolr.SolrError, e:
            raise SearchError('SOLR returned an error running query: %r Error: %r' %
                              (query, e)) 
開發者ID:italia,項目名稱:daf-recipes,代碼行數:16,代碼來源:query.py

示例5: test_solr_404

# 需要導入模塊: import pysolr [as 別名]
# 或者: from pysolr import SolrError [as 別名]
def test_solr_404():
    q = GolrSearchQuery("abnormal")
    q.update_solr_url("https://httpbin.org/status/404")
    pytest.raises(pysolr.SolrError, q.search) 
開發者ID:biolink,項目名稱:ontobio,代碼行數:6,代碼來源:test_golr_search.py

示例6: search

# 需要導入模塊: import pysolr [as 別名]
# 或者: from pysolr import SolrError [as 別名]
def search(q, short_timeout=False, ignore_errors=True, **kw):
    q = inject_user(q)
    try:
        if short_timeout:
            return g.solr_short_timeout.search(q, **kw)
        else:
            return g.solr.search(q, **kw)
    except (SolrError, socket.error) as e:
        log.exception('Error in solr search')
        if not ignore_errors:
            match = re.search(r'<pre>(.*)</pre>', six.text_type(e))
            raise SearchError('Error running search query: %s' %
                              (match.group(1) if match else e)) 
開發者ID:apache,項目名稱:allura,代碼行數:15,代碼來源:search.py


注:本文中的pysolr.SolrError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。