feat: split Studio search into separate course and library indexes - #39103
blarghmatey wants to merge 2 commits into
Conversation
Library authoring waits synchronously on Meilisearch, and indexing cost grows with index size. On large instances the shared studio_content index is almost entirely course blocks, so creating a library component can time out (openedx#38993). Course content is indexed asynchronously and doesn't need to share an index with libraries. Course blocks stay in studio_content so existing course documents don't need reindexing. Libraries V2 blocks, containers and collections move to a new studio_library_content index. Writes are routed by document type or key context, rebuild locks and _new temp indexes are per index, and reconcile creates/configures both. The studio search endpoint now returns course_index_name and library_index_name with one tenant token covering both indexes. index_name is kept for one release, pointing at the course index. Existing installs run `reindex_studio --libraries-only` once after migrate. It rebuilds the library index and deletes `type != "course_block"` documents from the course index without reindexing courses. Full rebuilds run the same cleanup. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J43t1WXNsmVV5mbdzxv6iT
Each Studio search surface already queries course content or library content, never both, so the frontend picks one index per surface rather than issuing a multi-index search. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J43t1WXNsmVV5mbdzxv6iT
|
Thanks for the pull request, @blarghmatey! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Description
Splits the Studio Meilisearch index in two: course blocks stay in
studio_content, and Libraries V2 content (blocks, containers, collections) moves to a newstudio_library_contentindex.Library authoring waits synchronously on Meilisearch, and indexing cost grows with index size. On large instances
studio_contentis almost entirely course blocks (one instance: 1,319,937 documents, 99.93% course blocks), so every library write pays for content it never touches. That is the root of #38993, where the library commit endpoint times out publishing a few blocks because each synchronous library index update takes seconds on a 500K+ document index. Course indexing is async and has no reason to share an index with libraries. This implements @bradenmacdonald's proposal in #38993 (comment) and replaces #39041 (disable course indexing) as the quick fix, without losing Studio course search._newtemp indexes are per index, andpost_migratereconciliation creates and configures both.rebuild_indexrebuilds and swaps in the library index before starting courses. Course indexing is otherwise unchanged.GET /api/content_search/v2/studio/returnscourse_index_nameandlibrary_index_name. The tenant token's search rules cover both indexes with the existing access filter.index_namestays for one release and points at the course index.reindex_studio --libraries-only, backed by a newrebuild_library_indextask.openedx/core/djangoapps/content/search/docs/decisions/0002-separate-course-and-library-indexes.rst.Roles affected: Operator (upgrade steps below), Course Author (faster library authoring on large instances; no UI change).
Supporting information
Testing instructions
Upgrading an instance that already has a populated
studio_content:./manage.py cms migrate. Reconciliation creates the emptystudio_library_contentindex../manage.py cms reindex_studio --libraries-only. This rebuilds the library index, then deletestype != "course_block"documents fromstudio_content. Courses are not reindexed.studio_library_contentand not instudio_content.Automated:
pytest -c cms/pytest.ini openedx/core/djangoapps/content/searchpasses, 126 tests. New tests assert which index each write, rebuild, swap and cleanup targets, and that the token rules cover both indexes.The unit tests mock the Meilisearch client, so I also replayed the calls this change relies on against a real Meilisearch v1.36.0, using the index settings from
index_config.py: temp index then swap for the library index, thetype != "course_block"delete-by-filter (leaves only course blocks, and is a no-op on rerun), and a tenant token scoped to both indexes (both searchable with the access filter applied, multi-search across both works, any other index returns 403). All passed. Not yet run end to end on a full Studio deployment.Deadline
Wanted in Verawood per the discussion on #39041. A
release/verawoodbackport branch is ready and will be opened once this is reviewed.Other information
index_namesearches the course index, so it stops finding library content once step 2 has run.STUDIO_INDEX_NAMEis replaced bySTUDIO_COURSE_INDEX_NAMEandSTUDIO_LIBRARY_INDEX_NAME, andreset_index()now takes an index name. Nothing else in this repo uses them; an external plugin importing them would need updating.studio_library_contentandstudio_library_content_new(keys scoped byMEILISEARCH_INDEX_PREFIXalready are).