def _get_notifications_by_email(self, email):
search = elasticsearch_dsl.Search(using=self.client, index=self.config['ELASTICSEARCH_INDEX'],
doc_type=self.config['ELASTICSEARCH_DOCTYPE'])
query = self.create_query_for_email(search, email)
# logger.debug("query:\n{!s}", pprint.pformat(query.to_dict()))
try:
response = query.execute()
except elasticsearch.exceptions.ElasticsearchException:
logger.exception("Exception caught in Elasticsearch query:\n index: {!r}\n doc_type: {!r}\n"
" query: {!s}".format(self.config['ELASTICSEARCH_INDEX'],
self.config['ELASTICSEARCH_DOCTYPE'], pprint.pformat(query.to_dict())))
# logger.debug("response:\n{!s}", pprint.pformat(response.to_dict()))
return response.hits.hits
评论列表
文章目录