def _get_es_results(query: str, category: str, keyphrase: str, strict: bool) -> Response:
skill_search = es_search
if category:
skill_search = skill_search.query('match',
category=string.capwords(category)
.replace(' And ', ' & ')
.replace('Movies & Tv', 'Movies & TV'))
if keyphrase:
skill_search = skill_search.query('match', keyphrases=keyphrase)
if query:
operator = 'and' if strict else 'or'
skill_search = skill_search.query('multi_match',
query=query,
fields=['name', 'description', 'usages', 'keyphrases'],
minimum_should_match='50%',
operator=operator) \
.highlight('description', order='score', pre_tags=['*'], post_tags=['*']) \
.highlight('title', order='score', pre_tags=['*'], post_tags=['*']) \
.highlight('usages', order='score', pre_tags=['*'], post_tags=['*'])
return skill_search.execute()
评论列表
文章目录