From fff0c67e88e49d339119c37659d9b64ceedb07d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 22 Mar 2024 12:13:15 -0300 Subject: [PATCH] feat: move changes from merge --- openedx/core/djangoapps/content/search/api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openedx/core/djangoapps/content/search/api.py b/openedx/core/djangoapps/content/search/api.py index 79b18055437f..9fb3d617eb0c 100644 --- a/openedx/core/djangoapps/content/search/api.py +++ b/openedx/core/djangoapps/content/search/api.py @@ -278,6 +278,11 @@ def nop(_message): status_cb(f"Found {num_courses} courses and {num_libraries} libraries.") with _using_temp_index(status_cb) as temp_index_name: ############## Configure the index ############## + + # The following index settings are best changed on an empty index. + # Changing them on a populated index will "re-index all documents in the index, which can take some time" + # and use more RAM. Instead, we configure an empty index then populate it one course/library at a time. + # Mark usage_key as unique (it's not the primary key for the index, but nevertheless must be unique): client.index(temp_index_name).update_distinct_attribute(Fields.usage_key) # Mark which attributes can be used for filtering/faceted search: @@ -312,6 +317,9 @@ def nop(_message): ) docs = [] + # Pre-fetch the course with all of its children: + course = store.get_course(course.id, depth=None) + def add_with_children(block): """ Recursively index the given XBlock/component """ doc = searchable_doc_for_course_block(block)