nusmodifications / nusmodifications/nusmods
Harden Elasticsearch indexing and search for larger module corpora
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 689
- Forks
- 364
- Avg merge
- 7h 5m
- Merged PRs (30d)
- 14
Description
Problem
The timeout increase in #4463 is an immediate mitigation, but the scraper/search integration still has several size-related assumptions that are now brittle with the current corpus size.
Observed production context:
modules_v2has about 21,096 documents.moduleInfobulk indexing is sent as one large request, about 18.5 MB.ElasticPersist.getModuleCodes()fetches at most 20,000 docs in a single search.modules_v2hasindex.max_result_window = 20000.- Frontend pagination/random-course paths can request beyond the ES result window and receive HTTP 400.
createIndex()assumes a specific error shape and can throwCannot read properties of undefined (reading 'type')for other ES errors.
Proposed work
- Chunk scraper
moduleInfobulk writes by document count and/or byte size. - Add retry/backoff for transient ES timeout/connection failures.
- Replace
getModuleCodes()singlesize: 20000search with scroll/search-after so cleanup sees all existing documents. - Fix frontend deep pagination/random-course behavior so it does not request beyond
index.max_result_window, or move those paths to a cursor/search-after-safe design. - Harden ES error handling in
createIndex()and delete paths so unexpected ES/network errors are logged clearly without masking the original cause.
Notes
This is intentionally separate from the timeout mitigation PR so the production scraper can be unblocked first.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing scraper moduleInfo bulk indexing, ElasticPersist.getModuleCodes(), createIndex(), delete paths, and the frontend pagination/random-course paths named in the issue. Verify the current Elasticsearch request limits and error behavior before splitting the work into focused changes. Done means large corpora index and clean up reliably, deep pagination avoids result-window failures, and unexpected Elasticsearch errors retain clear original causes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elasticsearch, javascript
- Domain
- backend, frontend, search
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100