本文整理汇总了Python中apps.content_filters.filter_condition.FilterConditionService.get_elastic_query方法的典型用法代码示例。如果您正苦于以下问题:Python FilterConditionService.get_elastic_query方法的具体用法?Python FilterConditionService.get_elastic_query怎么用?Python FilterConditionService.get_elastic_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.content_filters.filter_condition.FilterConditionService
的用法示例。
在下文中一共展示了FilterConditionService.get_elastic_query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_elastic_using_endswith_filter
# 需要导入模块: from apps.content_filters.filter_condition import FilterConditionService [as 别名]
# 或者: from apps.content_filters.filter_condition.FilterConditionService import get_elastic_query [as 别名]
def test_elastic_using_endswith_filter(self):
f = FilterConditionService()
doc = {'field': 'headline', 'operator': 'endswith', 'value': 'Que'}
query = f.get_elastic_query(doc)
with self.app.app_context():
self._setup_elastic_args(query, 'keyword')
docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
self.assertEqual(1, docs.count())
self.assertEqual('2', docs[0]['_id'])
示例2: test_elastic_using_notlike_filter
# 需要导入模块: from apps.content_filters.filter_condition import FilterConditionService [as 别名]
# 或者: from apps.content_filters.filter_condition.FilterConditionService import get_elastic_query [as 别名]
def test_elastic_using_notlike_filter(self):
f = FilterConditionService()
doc = {'field': 'headline', 'operator': 'notlike', 'value': 'que'}
query = f.get_elastic_query(doc)
with self.app.app_context():
self._setup_elastic_args(query, 'not')
docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
self.assertEqual(8, docs.count())
doc_ids = [d['_id'] for d in docs]
self.assertTrue('2' not in doc_ids)
示例3: test_elastic_using_anpa_category_filter_complete_string
# 需要导入模块: from apps.content_filters.filter_condition import FilterConditionService [as 别名]
# 或者: from apps.content_filters.filter_condition.FilterConditionService import get_elastic_query [as 别名]
def test_elastic_using_anpa_category_filter_complete_string(self):
f = FilterConditionService()
doc = {'field': 'anpa_category', 'operator': 'in', 'value': 'a,i'}
query = f.get_elastic_query(doc)
with self.app.app_context():
self._setup_elastic_args(query)
docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
doc_ids = [d['_id'] for d in docs]
self.assertEqual(1, docs.count())
self.assertTrue('9' in doc_ids)
示例4: test_elastic_using_in_filter
# 需要导入模块: from apps.content_filters.filter_condition import FilterConditionService [as 别名]
# 或者: from apps.content_filters.filter_condition.FilterConditionService import get_elastic_query [as 别名]
def test_elastic_using_in_filter(self):
f = FilterConditionService()
doc = {'field': 'urgency', 'operator': 'in', 'value': '3,4'}
query = f.get_elastic_query(doc)
with self.app.app_context():
self._setup_elastic_args(query)
docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
doc_ids = [d['_id'] for d in docs]
self.assertEqual(2, docs.count())
self.assertTrue('4' in doc_ids)
self.assertTrue('3' in doc_ids)