Files
alpenwerk-hr/app/(app)/employees
Maximilian Stubhan 9308096754 Search names first, and only fall back to job titles
"Winkler M" returned four people, two of whom are not called M: Karin
Winkler is a Montagemitarbeiterin and Katharina Winkler a
Maschinenbedienerin. The job title was searched with the same weight as
the name, so a single letter matched the start of a job word just as
readily as the start of a first name.

Searching job titles is worth keeping — "dreher" finding the CNC-Dreher
is useful. So the search is now tiered: names alone first, and the job
title joins in only when the names return nothing at all. A minimum word
length would have been the simpler rule, but any threshold is a guess;
this one is decided by the data in front of it.

Checked against the live data: "winkler m" gives Martin and Magdalena,
"winkler h" Hannah, "dreher" and "montage" still find their trades, and
"winkler montage" finds Karin Winkler — no name matches both words, so
the fallback does what was meant.

When the fallback runs, the result line says so. Without that, a list of
people whose names look nothing like the query reads as though the
search invented them.

Costs one small count query, and only when text was typed.

Not verified with next build: a dev server from an earlier session is
holding .next, and the user is testing in it. tsc, eslint and 297 tests
are green, and the search itself was run against the database.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 21:13:41 +02:00
..