From 3f3988a8369f23e1ab2087d68ba01c72a2d82e90 Mon Sep 17 00:00:00 2001 From: "Muhammad Mikaal S. Anwar" Date: Thu, 21 Sep 2023 17:37:48 +0200 Subject: [PATCH] Added a guard clause to prevent crashing in case of missing data/indices for any resource type --- search/search_service/proxy/es_proxy_v2_1.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/search/search_service/proxy/es_proxy_v2_1.py b/search/search_service/proxy/es_proxy_v2_1.py index 3ba5ea5f06..2893e9be97 100644 --- a/search/search_service/proxy/es_proxy_v2_1.py +++ b/search/search_service/proxy/es_proxy_v2_1.py @@ -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,