#460 Explore searches every timeline, moment and duration, with the words highlighted (#459)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#460
- pull request
- state:merged
Closes #459. Explore's search now finds every item on the site: timelines, and their events (moments and durations), by titles and notes. It's what #422 (PR #457) uses to find what to link to. ## On the page - **One search field across Explore.** The filters are folded under **Filters**, which says how many are on: - **Show:** Timelines, Moments, Durations; - **Tag**; - **Search in:** the whole library, or (signed in) my timelines; - **Sort timelines**. - **Results:** matching timelines as cards, then **Events**: each with its kind, its title (opening its page), its time as its timeline shows times, its timeline and owner, and its notes from where they match. - **Highlighting:** the words searched for are highlighted in timeline titles and descriptions, and event titles and notes. - **In the address:** `show`, `within` and `entityPage` join `search`, `tag`, `sort` and `page`. It searches in place with JavaScript, and works without it. - **Signed in:** a search with words also finds the account's own private timelines and those shared with it. Browsing without words stays public. ## Server `POST /api/timelines/entities/search` (`server/library-search.mjs`): - **Matching:** the per-timeline search's rules (word prefixes, titles weighted most), over every timeline's search rows at once. - **Scopes:** `public`, `visible` or `mine`. - **Never searched:** comparisons, copies still being prepared, and labelled timelines' events, except for signed-in adults. - **Order:** established accounts' events first. - **Forks:** show only what they changed. - **Cap:** at most 5,000 matches are read and ranked; past that the total says "5,000+". ## Benchmark `bench/library-search.mjs`, in `docs/benchmarks.md`. At 1.76 million rows, searches take 7.5–254 ms. Searching only durations at first took 955 ms: PostgreSQL read the whole text index once per timeline. The match now runs fenced in a subquery, and durations have a text index of their own, which brought it to 58 ms. ## Tests - New: `test/library-search-postgres.mjs`, and `test/library-search-live-postgres.mjs` (desktop, phone, no JavaScript). Both are in CI. - Unit tests for the list state, highlighting and match snippets. - Updated: `test/timeline-browser-live-postgres.mjs` passes. Signed-in searches now count the account's 2 private timelines (16, not 14), and sort sits under Filters. - The OpenAPI test and the unit tests pass. The only failure is the local `node_modules` symlink in the contents check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/460