From d3a97015b1f862ce31b4274a921d4fd5be3da2a2 Mon Sep 17 00:00:00 2001 From: William Laugesen Date: Mon, 31 Aug 2026 10:33:12 +1200 Subject: [PATCH] Fetch 20 search results a page instead of 30 Each row in a page costs a fragment fetch, so the page size is what a search pays before it can draw anything. Twenty still gives byNameThenDepth enough of the list to reorder, and a reader who has scrolled past twenty rows is better served by a narrower query. Co-Authored-By: Claude Opus 5 (1M context) --- src/scripts/search-engine-pagefind.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/scripts/search-engine-pagefind.ts b/src/scripts/search-engine-pagefind.ts index e6b902add9..02a088b87a 100644 --- a/src/scripts/search-engine-pagefind.ts +++ b/src/scripts/search-engine-pagefind.ts @@ -12,10 +12,12 @@ import { type SearchResult, } from './search-engine'; -// Rows fetched at a time. Pagefind's own UI shows five and offers the rest on -// demand; thirty, because `byNameThenDepth` reorders within a page and needs -// enough of the list to have something to reorder. -const PAGE_SIZE = 30; +// Rows fetched at a time, and a fragment fetch for each one. Pagefind's own UI +// shows five and offers the rest on demand; twenty, because `byNameThenDepth` +// reorders within a page and needs enough of the list to have something to +// reorder, and because a reader who has scrolled past twenty rows is served +// better by a narrower query than by row twenty-one. +const PAGE_SIZE = 20; // Above this share of the corpus, a query is too general to rank rather than // unanswerable, and the overlay says so instead of reporting nothing found. @@ -84,8 +86,7 @@ type PagefindApi = { const MINIMUM_SCORE = 8; // Sections are their own rows, so they compete with pages for the reader's first -// screenful. Three headings per page across thirty results made two thirds of -// the list headings. +// screenful. Three headings per page made two thirds of the list headings. /** Headings shown under one page. */ const SECTION_LIMIT = 2; /** How many of the leading pages get headings at all. */ @@ -281,7 +282,7 @@ export function pagefindEngine(bundlePath: string): SearchEngine { let loading: Promise | null = null; // Everything the last search matched, and how much of it has been handed over. // A stub is a score and a promise of its fragment, so holding a thousand of - // them costs nothing and saves searching again to show row thirty-one. + // them costs nothing and saves searching again to show row twenty-one. // `promoted` is the page `namedPage` pulled forward, whose own stub is still // waiting further down `stubs`. let page: {