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