Skip to content

Commit

Permalink
fix: catch MeilisearchError, but don't call create_indexes
Browse files Browse the repository at this point in the history
Tutor will handle this step for us.
  • Loading branch information
pomegranited committed Oct 31, 2024
1 parent 2bde70c commit 7a99d59
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator
from search.meilisearch import create_indexes, MeilisearchEngine, INDEX_FILTERABLES
from meilisearch.errors import MeilisearchError
from search.search_engine_base import SearchEngine

from cms.djangoapps.contentstore.courseware_index import CourseAboutSearchIndexer, CoursewareSearchIndexer
Expand Down Expand Up @@ -94,17 +94,12 @@ def handle(self, *args, **options): # pylint: disable=too-many-statements
for index_name in index_names:
try:
searcher = SearchEngine.get_search_engine(index_name)
except exceptions.ElasticsearchException as exc:
except (exceptions.ElasticsearchException, MeilisearchError) as exc:
logging.exception('Search Engine error - %s', exc)
return

# Meilisearch engine
if isinstance(searcher, MeilisearchEngine) and index_name in INDEX_FILTERABLES:
logging.info(f"Creating meilisearch index for {index_name}")
create_indexes({index_name: INDEX_FILTERABLES[index_name]})

# Legacy Elasticsearch engine
else:
if hasattr(searcher, '_es'): # pylint: disable=protected-access
index_exists = searcher._es.indices.exists(index=index_name) # pylint: disable=protected-access

index_mapping = searcher._es.indices.get_mapping( # pylint: disable=protected-access
Expand Down

0 comments on commit 7a99d59

Please sign in to comment.