I set up in-memory full text search (for the second time) on all my site’s
This leverages the Unified.js ecosystem for MDX parsing and Orama (formerly Lyra) for indexing and searching.
The indexing happens at build time, and the index is persisted as a JSON file. At runtime, the JSON file is loaded into memory and used inside an API route. CloudFront caching helps to reduce the compute load as well, and speed up response times of repeat requests.
ETL code snippet.
GET /api/search route handler