本文整理汇总了Python中boto.cloudsearch.search.SearchConnection.search方法的典型用法代码示例。如果您正苦于以下问题:Python SearchConnection.search方法的具体用法?Python SearchConnection.search怎么用?Python SearchConnection.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.cloudsearch.search.SearchConnection
的用法示例。
在下文中一共展示了SearchConnection.search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CloudSearchConnectionTest
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
class CloudSearchConnectionTest(unittest.TestCase):
cloudsearch = True
def setUp(self):
super(CloudSearchConnectionTest, self).setUp()
self.conn = SearchConnection(
endpoint='test-domain.cloudsearch.amazonaws.com'
)
def test_expose_additional_error_info(self):
mpo = mock.patch.object
fake = FakeResponse()
fake.content = b'Nopenopenope'
# First, in the case of a non-JSON, non-403 error.
with mpo(requests, 'get', return_value=fake) as mock_request:
with self.assertRaises(SearchServiceException) as cm:
self.conn.search(q='not_gonna_happen')
self.assertTrue('non-json response' in str(cm.exception))
self.assertTrue('Nopenopenope' in str(cm.exception))
# Then with JSON & an 'error' key within.
fake.content = json.dumps({
'error': "Something went wrong. Oops."
}).encode('utf-8')
with mpo(requests, 'get', return_value=fake) as mock_request:
with self.assertRaises(SearchServiceException) as cm:
self.conn.search(q='no_luck_here')
self.assertTrue('Unknown error' in str(cm.exception))
self.assertTrue('went wrong. Oops' in str(cm.exception))
示例2: test_cloudsearch_top_n_single
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_top_n_single(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', facet_top_n={'author': 5})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'facet-author-top-n'], [b'5'])
示例3: test_cloudsearch_facet_sort_single
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_facet_sort_single(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', facet_sort={'author': 'alpha'})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'facet-author-sort'], [b'alpha'])
示例4: test_cloudsearch_t_field_single
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_t_field_single(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', t={'year': '2001..2007'})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b't-year'], [b'2001..2007'])
示例5: test_cloudsearch_facet_multiple
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_facet_multiple(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', facet=["author", "cat"])
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'facet'], [b"author,cat"])
示例6: test_cloudsearch_bqsearch
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_bqsearch(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(bq="'Test'")
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'bq'], [b"'Test'"])
示例7: test_cloudsearch_facet_single
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_facet_single(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', facet=["Author"])
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args['facet'], ["Author"])
示例8: test_cloudsearch_result_fields_multiple
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_result_fields_multiple(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', return_fields=['author', 'title'])
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'return-fields'], [b'author,title'])
示例9: test_cloudsearch_rank_multiple
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_rank_multiple(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', rank=["date", "score"])
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'rank'], [b'date,score'])
示例10: test_cloudsearch_t_field_multiple
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_t_field_multiple(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', t={'year':'2001..2007', 'score':'10..50'})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args['t-year'], ['2001..2007'])
self.assertEqual(args['t-score'], ['10..50'])
示例11: test_cloudsearch_top_n_multiple
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_top_n_multiple(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', facet_top_n={'author': 5, 'cat': 10})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args['facet-author-top-n'], ['5'])
self.assertEqual(args['facet-cat-top-n'], ['10'])
示例12: test_cloudsearch_search_details
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_search_details(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test', size=50, start=20)
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'q'], [b"Test"])
self.assertEqual(args[b'size'], [b"50"])
self.assertEqual(args[b'start'], [b"20"])
示例13: test_cloudsearch_qsearch
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_qsearch(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(q='Test')
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'q'], [b"Test"])
self.assertEqual(args[b'start'], [b"0"])
self.assertEqual(args[b'size'], [b"10"])
示例14: test_cloudsearch_facet_constraint_single
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_facet_constraint_single(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(
q='Test',
facet_constraints={'author': "'John Smith','Mark Smith'"})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args[b'facet-author-constraints'],
[b"'John Smith','Mark Smith'"])
示例15: test_cloudsearch_facet_constraint_multiple
# 需要导入模块: from boto.cloudsearch.search import SearchConnection [as 别名]
# 或者: from boto.cloudsearch.search.SearchConnection import search [as 别名]
def test_cloudsearch_facet_constraint_multiple(self):
search = SearchConnection(endpoint=HOSTNAME)
search.search(
q='Test',
facet_constraints={'author': "'John Smith','Mark Smith'",
'category': "'News','Reviews'"})
args = self.get_args(HTTPretty.last_request.raw_requestline)
self.assertEqual(args['facet-author-constraints'],
["'John Smith','Mark Smith'"])
self.assertEqual(args['facet-category-constraints'],
["'News','Reviews'"])