本文整理汇总了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
示例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
示例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))
示例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))
示例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)
示例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))