Skip to content

Commit

Permalink
feat: move changes from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Mar 22, 2024
1 parent 7320e3c commit fff0c67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions openedx/core/djangoapps/content/search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fff0c67

Please sign in to comment.