Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow non-Elasticsearch search engines when reindexing courses [FC-0062] #35743

Merged
17 changes: 10 additions & 7 deletions cms/djangoapps/contentstore/management/commands/reindex_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator
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 @@ -93,18 +94,20 @@ 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:
pomegranited marked this conversation as resolved.
Show resolved Hide resolved
logging.exception('Search Engine error - %s', exc)
return

index_exists = searcher._es.indices.exists(index=index_name) # pylint: disable=protected-access
# Legacy Elasticsearch engine
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
index=index_name,
) if index_exists else {}
index_mapping = searcher._es.indices.get_mapping( # pylint: disable=protected-access
index=index_name,
) if index_exists else {}

if index_exists and index_mapping:
return
if index_exists and index_mapping:
return

# if reindexing is done during devstack setup step, don't prompt the user
if setup_option or query_yes_no(self.CONFIRMATION_PROMPT, default="no"):
Expand Down
Loading