def search_reports(state, must_terms, should_terms):
s = Report.search()
q = Q('bool',
must=[Q('match', body=term) for term in must_terms],
should=[Q('match', body=term) for term in should_terms],
minimum_should_match=1
)
s = s.filter('terms', state=[state]).query(q)
response = s.execute()
return response.to_dict()['hits']['hits']
评论列表
文章目录