fix(search): stem wildcard patterns so prefix searches match again

Index terms are stemmed but query patterns were not, so invoice* matched nothing
while invoic* worked. v2's index was unstemmed (whoosh TEXT() defaults to
StandardAnalyzer), so this regressed against both baselines, not just dev. Uses
the typed run's stem unless the stem is longer than the run, since a stem can be
longer than a partial prefix and a shorter prefix only widens recall. Patterns
spanning the stem boundary (produ*name) still cannot match a stemmed index, so
usage.md loses that example rather than advertising a broken one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
stumpylog
2026-08-20 07:37:26 -07:00
co-authored by Claude Opus 5
parent 3f6af15f7d
commit e311c84139
5 changed files with 216 additions and 16 deletions
+8 -1
View File
@@ -922,9 +922,16 @@ original_filename:invoice.pdf
Matching inexact words:
```
produ*name
invoice*
title:Invoice*
```
Wildcards are matched against the _stemmed_ terms stored in the index, not
against the words as they appear in the document. A trailing `*` therefore
works as expected (`invoice*` finds "invoice", "invoices" and "invoiced"), but
a pattern whose text continues past where stemming cuts a word off cannot
match: `productname` is indexed as `productnam`, so `produ*name` finds nothing.
Matching natural date keywords:
Multi-word date keywords work quoted or unquoted after a date field