Skip to content

[SeerrNG #747] feat(search): understand queries, rank results, suggest while typing and stream results - #39

Open
ncbudd wants to merge 1 commit into
mainfrom
seerrng-pr-747
Open

ncbudd wants to merge 1 commit into
mainfrom
seerrng-pr-747

Conversation

@ncbudd

@ncbudd ncbudd commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Mirror of snapetech-org/seerrng#747. The lumen/ tree is identical to that PR's branch. Review and discussion happen upstream; this closes once upstream merges and the sync picks it up.

Builds on #745 (branch pr/lumen-phone-layout): the Lumen search page uses the phone filter hooks and the partial-failure note from that PR. The two server commits don't depend on it.

Summary

Search now reads what was typed instead of only passing it on. "nate standup" is split into a person ("nate") and an intent (stand-up); TMDB person search finds Nate Bargatze (comedians ranked up), and his stand-up specials come back as a top result. The query is always still searched as typed: the intent only adds results and ordering.

Server

  • Query understanding (searchIntent): a tested parser for formats, genres, media types, roles, seasons, years and decades, and "X by Y". Besides stand-up it handles " live", " audiobook", " season 3", "2015 horror" and "80s action movies".
  • Intent results (searchIntentResolver): for a person plus stand-up it collects comedy credits where they play themselves, TMDB keyword 9716 (stand-up comedy) and titles with their name.
    • A special needs the person's whole name in its title, or a first-billed "Self" credit. A surname alone matched a relative's special, and guest spots or specials the person only produced slipped in.
  • Ranking (searchRanking): typo- and prefix-tolerant matching ("bargatze", "nate barg", "bergatze"), one 0–100 score per result (text fit, exact title, intent fit, owned, popularity, provider order), results ordered within each media type, and dedupe across providers.
  • GET /search adds intent, topResult, correctedQuery (did-you-mean when nothing matched), matchScore per result and failedSources. Existing fields are unchanged.
  • GET /search/stream answers per provider group as NDJSON, so TMDB results arrive while slow catalogs fill in or time out on their own.
  • GET /search/suggest answers from an in-memory index within 120 ms: library titles, recent answers, trending, people, intent queries such as "Nate Bargatze stand-up specials", and spelling corrections.
    • The did-you-mean dictionary is seeded with TMDB's popular people (5 pages) and popular stand-up specials (keyword 9716, 5 pages), refreshed daily. Before, "bergatze" found nothing until someone had searched for Nate Bargatze.
    • Intent suggestions attach to the right kind of match: stand-up to a person, live albums to an artist, a season to a series.
  • Provider cache (searchProviderCache): Bookshelf and ComicVine answers are kept for 2 minutes, and identical searches in flight share one request.
  • All three endpoints are documented in seerr-api.yml, and the new API messages are registered in the catalog.

Lumen

  • Suggestions while typing: the top search box (and the phone search box) shows query suggestions, "Did you mean", recent searches, people, and titles with an In library badge.
    • Combobox semantics: arrow keys, Enter, Escape and aria-activedescendant; the boxes keep their searchbox role.
    • 120 ms debounce, and each keystroke aborts the previous request. Taps keep focus in the box until a choice is made, and rows are 44 px.
    • On phones the list stays closed on arrival until something is typed, so it never covers the results.
  • Streamed All search: All reads /search/stream for video, music, authors and magazines (books and comics keep their own endpoints).
    • Movies and series show as soon as they answer and slower groups fill in. Typing on aborts the old search, and a cut-off stream falls back to the classic /search.
  • Top result card above the sections: a person with their fitting works, or a series that opens at the asked season. What it shows isn't repeated below, and it steps aside when a sort is chosen.
  • Order and spelling: sections follow the order the query asked for (intent.sections). The partial-failure note names the sources that didn't answer (Music, Authors...) with Retry. Corrected searches show "Showing results for …", otherwise a "Did you mean" link.
  • New messages are in en, fr and ar.

Testing

  • New tests:
    • server: searchIntent.test.ts (parser), searchRanking.test.ts (matching and scoring), searchSmart.test.ts (intent, top result, stand-up specials filtering, corrections, stream and suggest routes, dictionary seeding);
    • searchTiming.bench.ts measures classic, streamed and suggest timings with mocked providers (run on demand: node server/test/index.mts server/routes/searchTiming.bench.ts);
    • Lumen: searchStream.test.mjs (NDJSON line splitting, stream paths, a cut-off stream is rejected); search-suggestions.spec.ts (suggests while typing, keyboard moves and picks, a click opens a person, Escape closes, spelling correction); search-stream.spec.ts ("nate standup" top result, one quiet note with Retry for a source that doesn't answer, the Search page box suggests while typing).
  • Local checks on main as of today (00b4b12d1), with #745 below it:
    • server tsc -p server/tsconfig.json, ESLint on the changed files, pnpm i18n:check: pass;
    • server vitest (search tests, 4 files): 74 passed;
    • node test runner: 5,684 passed. The 1 failure also fails on untouched main: the scoped TV allowlist test in src/hooks/detailDisclosureMediaServer.test.mjs (same as in #740 and #741);
    • Lumen tsc, build and unit tests (93), ESLint on the changed Lumen files: pass;
    • Lumen browser specs for search, navigation and the shell (search-suggestions, search-stream, search-localization, people-search, mobile-navigation, swipe-navigation, review-core, indexer-search; desktop, iPhone, Android, tablet): 158 passed, 16 failed. The failures are the 4 review-core tests on every size, which fail the same way on untouched main.
  • Live: running on the production install since 2026-11-28.

AI assistance

AI tools helped write parts of the code and tests. I reviewed the changes, ran the tests listed above, and checked it on a live install.

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