本文整理匯總了Python中haystack.backends.BaseSearchBackend方法的典型用法代碼示例。如果您正苦於以下問題:Python backends.BaseSearchBackend方法的具體用法?Python backends.BaseSearchBackend怎麽用?Python backends.BaseSearchBackend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類haystack.backends
的用法示例。
在下文中一共展示了backends.BaseSearchBackend方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_build_search_kwargs_all_qs_with_filter
# 需要導入模塊: from haystack import backends [as 別名]
# 或者: from haystack.backends import BaseSearchBackend [as 別名]
def test_build_search_kwargs_all_qs_with_filter(self):
with patch.object(BaseSearchBackend, 'build_models_list', return_value=['course_metadata.course']):
kwargs = self.backend.build_search_kwargs(self.all_query_string)
self.assertIsNone(kwargs['query'].get('query_string'))
self.assertIsNone(kwargs['query']['filtered']['query'].get('query_string'))
示例2: test_build_search_kwargs_specific_qs_with_filter
# 需要導入模塊: from haystack import backends [as 別名]
# 或者: from haystack.backends import BaseSearchBackend [as 別名]
def test_build_search_kwargs_specific_qs_with_filter(self):
with patch.object(BaseSearchBackend, 'build_models_list', return_value=['course_metadata.course']):
kwargs = self.backend.build_search_kwargs(self.specific_query_string)
self.assertIsNone(kwargs['query'].get('query_string'))
self.assertDictEqual(kwargs['query']['filtered'].get('query'), self._default_function_score())
示例3: test_build_search_kwargs_all_qs_no_filter
# 需要導入模塊: from haystack import backends [as 別名]
# 或者: from haystack.backends import BaseSearchBackend [as 別名]
def test_build_search_kwargs_all_qs_no_filter(self):
with patch.object(BaseSearchBackend, 'build_models_list', return_value=[]):
kwargs = self.backend.build_search_kwargs(self.all_query_string)
self.assertIsNone(kwargs['query'].get('filtered'))
self.assertIsNone(kwargs['query'].get('query_string'))
示例4: test_build_search_kwargs_specific_qs_no_filter
# 需要導入模塊: from haystack import backends [as 別名]
# 或者: from haystack.backends import BaseSearchBackend [as 別名]
def test_build_search_kwargs_specific_qs_no_filter(self):
with patch.object(BaseSearchBackend, 'build_models_list', return_value=[]):
kwargs = self.backend.build_search_kwargs(self.specific_query_string)
self.assertIsNone(kwargs['query'].get('filtered'))
self.assertDictEqual(kwargs['query'], self._default_function_score())
示例5: test_build_search_kwargs_function_score
# 需要導入模塊: from haystack import backends [as 別名]
# 或者: from haystack.backends import BaseSearchBackend [as 別名]
def test_build_search_kwargs_function_score(self):
test_elasticsearch_boost_config = {
'function_score': {
'functions': [
{
'filter': {
'term': {
'type': 'micromasters'
}
},
'weight': 10.0
}
],
'boost': 5.0,
'score_mode': 'multiply',
'boost_mode': 'sum'
}
}
with patch('course_discovery.apps.edx_haystack_extensions.backends.get_elasticsearch_boost_config',
return_value=test_elasticsearch_boost_config):
with patch.object(BaseSearchBackend, 'build_models_list', return_value=[]):
kwargs = self.backend.build_search_kwargs(self.specific_query_string)
function_score = test_elasticsearch_boost_config['function_score']
expected_function_score = {
'function_score': function_score
}
expected_function_score['function_score']['query'] = {
'query_string': self.simple_query
}
self.assertDictEqual(kwargs['query'], expected_function_score)