当前位置: 首页>>代码示例>>Python>>正文


Python backends.BaseSearchBackend方法代码示例

本文整理汇总了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')) 
开发者ID:edx,项目名称:course-discovery,代码行数:8,代码来源:mixins.py

示例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()) 
开发者ID:edx,项目名称:course-discovery,代码行数:8,代码来源:mixins.py

示例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')) 
开发者ID:edx,项目名称:course-discovery,代码行数:8,代码来源:mixins.py

示例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()) 
开发者ID:edx,项目名称:course-discovery,代码行数:8,代码来源:mixins.py

示例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) 
开发者ID:edx,项目名称:course-discovery,代码行数:34,代码来源:mixins.py


注:本文中的haystack.backends.BaseSearchBackend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。