本文整理汇总了Python中pyes.query.MatchAllQuery.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python MatchAllQuery.serialize方法的具体用法?Python MatchAllQuery.serialize怎么用?Python MatchAllQuery.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyes.query.MatchAllQuery
的用法示例。
在下文中一共展示了MatchAllQuery.serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: facets
# 需要导入模块: from pyes.query import MatchAllQuery [as 别名]
# 或者: from pyes.query.MatchAllQuery import serialize [as 别名]
def facets(host='localhost:9200',
facet_terms=['bibleverse'],
_type='habakkuk',
date_filter=[],
size=10):
ret = {}
conn = ES(host)
q = MatchAllQuery()
if date_filter:
start,end = date_filter
q = FilteredQuery(q, RangeFilter(qrange=ESRange('created_at_date',
start.isoformat(),
end.isoformat(),
include_upper=False)))
q = q.search(size=0)
for term in facet_terms:
q.facet.add_term_facet(term,order='count',size=size)
es_logger.info(q.serialize())
resultset = conn.search(query=q, indices=_type+'-*', doc_types=[_type])
for facet in resultset.facets:
ret[facet] = []
for row in resultset.facets[facet]['terms']:
ret[facet].append({"value":row['term'],"count":row['count']})
logger.debug("facets return|'%s'"%json.dumps(ret))
return ret
示例2: test_facet_filter_is_serialized_correctly
# 需要导入模块: from pyes.query import MatchAllQuery [as 别名]
# 或者: from pyes.query.MatchAllQuery import serialize [as 别名]
def test_facet_filter_is_serialized_correctly(self):
query = MatchAllQuery().search(size=0)
query.facet.add(
TermFacet(field="topic", facet_filter=BoolFilter(must_not=TermQuery(field="reviewed", value=True)))
)
serialized = query.serialize()
self.assertTrue(serialized["facets"]["topic"]["facet_filter"]["bool"])
示例3: test_facet_filter_is_serialized_correctly
# 需要导入模块: from pyes.query import MatchAllQuery [as 别名]
# 或者: from pyes.query.MatchAllQuery import serialize [as 别名]
def test_facet_filter_is_serialized_correctly(self):
query = MatchAllQuery().search(size=0)
query.facet.add(TermFacet(field='topic', facet_filter=BoolFilter(must_not=TermQuery(field='reviewed', value=True))))
serialized = query.serialize()
self.assertTrue(serialized['facets']['topic']['facet_filter']['bool'])