Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
match_query.extend(_construct_phonetic_match_query(e, weight))
text_relevance_query["query"]["function_score"]["query"]["bool"][
"should"
].append({"bool": {"should": match_query}})
whitelist_query = _construct_whitelist_query(
top_entity, use_phons=self._use_double_metaphone
)
text_relevance_query["query"]["function_score"]["query"]["bool"][
"should"
].append(whitelist_query)
try:
index = get_scoped_index_name(self._app_namespace, self._es_index_name)
response = self._es_client.search(index=index, body=text_relevance_query)
except EsConnectionError as ex:
logger.error(
"Unable to connect to Elasticsearch: %s details: %s", ex.error, ex.info
)
raise EntityResolverConnectionError(es_host=self._es_client.transport.hosts)
except TransportError as ex:
logger.error(
"Unexpected error occurred when sending requests to Elasticsearch: %s "
"Status code: %s details: %s",
ex.error,
ex.status_code,
ex.info,
)
raise EntityResolverError(
"Unexpected error occurred when sending requests to "
"Elasticsearch: {} Status code: {} details: "
"{}".format(ex.error, ex.status_code, ex.info)