Skip to content

Search: stream results as the scan finds them - #160

Merged
RonanHevenor merged 1 commit into
mainfrom
fiddle-with-the-search-bar
Sep 17, 2026
Merged

RonanHevenor merged 1 commit into
mainfrom
fiddle-with-the-search-bar

Conversation

@RonanHevenor

Copy link
Copy Markdown
Member

Follow-up to #159: results still arrived as one block, because page one is almost always entirely headline matches, so the second request changed nothing visible.

/api/search?stream=1 now returns NDJSON:

  1. the headline count (short columns, ~0.3s on production data)
  2. headline matches in batches of 5, each with the page order so far
  3. the full page once the body scan lands (newest first, body mentions included), plus totals

Rows render as each batch arrives, later matches displace earlier ones (rows slide to their new positions), and the count climbs as it goes. X-Accel-Buffering: no keeps nginx from buffering the stream.

The plain JSON response is unchanged for the 404 page's search box and the spellcheck retry.

Measured on production before this change: headline pass 0.29–0.41s, full scan 1.1–3.2s.

🤖 Generated with Claude Code

The headline pass and full scan were two separate requests, so page one
(almost always all headline matches) arrived as a single block and the
later batch changed nothing visible.

- /api/search?stream=1 returns NDJSON: headline count, then headline
  matches in batches of 5, then the full page once the body scan lands
- Final order is newest-first across all matches again, so later matches
  displace earlier ones; rows slide to their new positions and the count
  climbs as each batch arrives
- Plain JSON response kept for the 404 page's search box and spellcheck

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@RonanHevenor
RonanHevenor force-pushed the fiddle-with-the-search-bar branch from 77ed351 to c7a728d Compare September 17, 2026 20:51
@RonanHevenor
RonanHevenor merged commit 9fe5971 into main Sep 17, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant