本文整理汇总了Python中collective.solr.solr.SolrConnection.search方法的典型用法代码示例。如果您正苦于以下问题:Python SolrConnection.search方法的具体用法?Python SolrConnection.search怎么用?Python SolrConnection.search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collective.solr.solr.SolrConnection
的用法示例。
在下文中一共展示了SolrConnection.search方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import search [as 别名]
def test_search(self):
search_request = getData('search_request.txt')
search_response = getData('search_response.txt')
c = SolrConnection(host='localhost:8983', persistent=True)
output = fakehttp(c, search_response)
res = c.search(q='+id:[* TO *]', wt='xml', rows='10', indent='on')
res = fromstring(res.read())
self.failUnlessEqual(str(output), search_request)
self.failUnless(res.find(('.//doc')))
示例2: test_search
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import search [as 别名]
def test_search(self):
search_request = getData('search_request.txt')
search_response = getData('search_response.txt')
c = SolrConnection(host='localhost:8983', persistent=True)
output = fakehttp(c, search_response)
res = c.search(q='+id:[* TO *]', fl='* score', wt='xml', rows='10', indent='on')
res = fromstring(res.read())
normalize = lambda x: sorted(x.split('&')) # sort request params
self.assertEqual(normalize(output.get()), normalize(search_request))
self.failUnless(res.find(('.//doc')))
示例3: test_search
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import search [as 别名]
def test_search(self):
# XXX: Solr 7 has a new query param 'q.op' which can not be passed to
# the search method in Python.
# This is why we have commented out code here.
search_request = getData('search_request.txt').rstrip('\n')
search_response = getData('search_response.txt')
c = SolrConnection(host='localhost:8983', persistent=True)
output = fakehttp(c, search_response)
parameters = {'q': '+id:[* TO *]',
'fl': '* score',
'wt': 'xml',
'rows': '10',
'indent': 'on',
'q.op': 'AND',
'lowercaseOperators': 'true',
'sow': 'true'}
res = c.search(**parameters)
res = fromstring(res.read())
normalize = lambda x: sorted(x.split('&')) # sort request params
self.assertEqual(normalize(output.get()), normalize(search_request))
self.failUnless(res.find(('.//doc')))
示例4: test_search_with_custom_request_handler
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import search [as 别名]
def test_search_with_custom_request_handler(self):
search_response = getData('search_response.txt')
c = SolrConnection(host='localhost:8983', persistent=True)
fakehttp(c, search_response)
c.search(request_handler='custom', q='+id:[* TO *]')
self.assertEqual('/solr/custom', c.conn.url)