Skip to content

Commit

Permalink
Added a guard clause to prevent crashing in case of missing data/indi…
Browse files Browse the repository at this point in the history
…ces for any resource type
  • Loading branch information
mikaalanwar committed Sep 21, 2023
1 parent 00e3477 commit 3f3988a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions search/search_service/proxy/es_proxy_v2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ def search(self, *,
multisearch = MultiSearch(using=self.elasticsearch)

for resource in resource_types:
# guard clause to prevent search in missing indices
aliases_in_es = self.elasticsearch.indices.get_alias().keys()
if self.get_index_alias_for_resource(resource_type=resource) not in aliases_in_es:
continue

# build a query for each resource to search
query_for_resource = self._build_elasticsearch_query(resource=resource,
query_term=query_term,
Expand Down

0 comments on commit 3f3988a

Please sign in to comment.