当前位置: 首页>>代码示例>>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;未经允许,请勿转载。