tighten ES id query as match case (#678)

This commit is contained in:
Tom Kralidis
2021-04-22 06:55:24 -04:00
committed by GitHub
parent a196f40e8c
commit 3b0cc014d4
+11 -7
View File
@@ -366,7 +366,7 @@ class ElasticsearchProvider(BaseProvider):
'query': {
'bool': {
'filter': [{
'match': {
'match_phrase': {
self.mask_prop(self.id_field): identifier
}
}]
@@ -374,12 +374,16 @@ class ElasticsearchProvider(BaseProvider):
}
}
result = self.es.search(index=self.index_name, body=query)
if len(result['hits']['hits']) == 0:
LOGGER.error(err)
raise ProviderItemNotFoundError(err)
LOGGER.debug('Serializing feature')
feature_ = self.esdoc2geojson(result['hits']['hits'][0])
try:
result = self.es.search(index=self.index_name, body=query)
if len(result['hits']['hits']) == 0:
LOGGER.error(err)
raise ProviderItemNotFoundError(err)
LOGGER.debug('Serializing feature')
feature_ = self.esdoc2geojson(result['hits']['hits'][0])
except exceptions.RequestError as err2:
LOGGER.error(err2)
raise ProviderItemNotFoundError(err2)
except Exception as err:
LOGGER.error(err)
return None