Full-text search (#14) #33

Merged
miko merged 2 commits from feature/14-full-text-search into development 2026-11-02 12:49:00 +01:00
Owner

Closes #14.

What

  • Guide.searchText now holds the plain text of the guide (title, description) and all its steps (titles, step lines, content). It is rebuilt from stored data in every transaction that saves the guide or a step, deletes or reorders steps; the guide row is locked first so concurrent saves can't write stale text.
  • FULLTEXT index on Guide.searchText; the migration backfills existing guides from their steps.
  • Search box in the Titlebar, results page at /search with prominent empty states and a link back to all categories.
  • Results go through canViewGuide (#7): drafts, internal and deleted guides stay hidden from those who may not see them.

Notes

  • The dev DB is MySQL 8.4 (the spec says MariaDB): words shorter than 3 characters and stopwords aren't indexed, so they are optional in the query instead of required (otherwise e.g. "PRUSA i3" found nothing). Typed boolean operators are ignored.
  • Only the 500 best-ranked matches are checked against permissions; up to 50 are shown.
  • getCurrentUser now awaits connection() before auth() (Next flagged prerendering hitting random values on /search).
  • The unused text field was dropped from rich-text and step-line submissions; Step.searchText is still written but no longer read.

Tests

Unit tests for the search text builder, the query parser and the visibility filter; full suite (236) green, typecheck and lint clean.

🤖 Generated with Claude Code

Closes #14. ## What - `Guide.searchText` now holds the plain text of the guide (title, description) and all its steps (titles, step lines, content). It is rebuilt from stored data in every transaction that saves the guide or a step, deletes or reorders steps; the guide row is locked first so concurrent saves can't write stale text. - FULLTEXT index on `Guide.searchText`; the migration backfills existing guides from their steps. - Search box in the Titlebar, results page at `/search` with prominent empty states and a link back to all categories. - Results go through `canViewGuide` (#7): drafts, internal and deleted guides stay hidden from those who may not see them. ## Notes - The dev DB is MySQL 8.4 (the spec says MariaDB): words shorter than 3 characters and stopwords aren't indexed, so they are optional in the query instead of required (otherwise e.g. "PRUSA i3" found nothing). Typed boolean operators are ignored. - Only the 500 best-ranked matches are checked against permissions; up to 50 are shown. - `getCurrentUser` now awaits `connection()` before `auth()` (Next flagged prerendering hitting random values on `/search`). - The unused `text` field was dropped from rich-text and step-line submissions; `Step.searchText` is still written but no longer read. ## Tests Unit tests for the search text builder, the query parser and the visibility filter; full suite (236) green, typecheck and lint clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Guide.searchText now holds the plain text of the guide's title and
description and of all its steps (titles, step lines, content), rebuilt
from the stored data in every transaction that saves the guide or a
step, deletes or reorders steps; the guide row is locked first so
concurrent saves cannot write stale text. A FULLTEXT index covers it;
the migration backfills existing guides from their steps.

A search box in the Titlebar leads to /search, which runs a boolean-mode
query (every word a required prefix; words the index leaves out, i.e.
shorter than three characters or stopwords, are optional; typed
operators are ignored) and shows only the guides the viewer may see
via canViewGuide, so drafts, internal and deleted guides stay hidden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No results and an empty query now show a large, centred notice with an
icon; an "All categories" link leads back to the top level.

getCurrentUser awaits connection() before auth(), so prerendering stops
there instead of hitting auth()'s random values (flagged by Next on
/search).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit 8d4929e87d into development 2026-11-02 12:49:00 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!33
No description provided.