Skip to content

Commit

Permalink
Fix - Handle ES missing index edge case (bug fix) (#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaalanwar authored Sep 22, 2023
1 parent a0ba31f commit e04d789
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions search/search_service/proxy/es_proxy_v2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,18 @@ def search(self, *,

for resource in resource_types:
# guard clause to prevent search in missing indices or aliases
aliases_in_es = self.elasticsearch.indices.get_alias().keys()
if self.get_index_alias_for_resource(resource_type=resource) not in aliases_in_es:
aliases_in_es = {alias['alias'] for alias in self.elasticsearch.cat.aliases(format="json")}
resource_alias = self.get_index_alias_for_resource(resource_type=resource)
if resource_alias not in aliases_in_es:
LOGGER.info(f"There are no indices in elasticsearch against resource_type: {resource}")
continue

# build a query for each resource to search
query_for_resource = self._build_elasticsearch_query(resource=resource,
query_term=query_term,
filters=filters)
# wrap the query in a search object
search = Search(index=self.get_index_alias_for_resource(resource_type=resource)).query(query_for_resource)
search = Search(index=resource_alias).query(query_for_resource)

# highlighting
if highlight_options:
Expand Down
2 changes: 1 addition & 1 deletion search/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

__version__ = '4.1.2'
__version__ = '4.1.3'

oidc = ['flaskoidc>=1.0.0']

Expand Down

0 comments on commit e04d789

Please sign in to comment.