Skip to content

fix(server): subquery bm25() before JOIN to fix hybrid search - #2

Merged
mtib merged 1 commit into
mainfrom
fix/hybrid-search-bm25
May 20, 2026
Merged

mtib merged 1 commit into
mainfrom
fix/hybrid-search-bm25

Conversation

@mtib

@mtib mtib commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • bm25() in SQLite FTS5 cannot be called in a JOIN context — it must be evaluated directly against the FTS virtual table
  • Wrapped the FTS query in a derived table that computes bm25() first, then joins entries against the result to group by doc_id
  • Fixes sqlite3.OperationalError: unable to use function bm25 in the requested context on GET /search/hybrid

Test plan

  • GET /search/hybrid?q=<term> returns 200 with results instead of 500
  • Scores are non-zero when matching entries exist
  • Falls back gracefully when no FTS match (empty text_scores_by_doc)

🤖 Generated with Claude Code

bm25() in SQLite FTS5 cannot be used in a JOIN context directly on the
virtual table. Pull it into a derived table first, then join entries
against that result to get doc_id grouping.
@mtib
mtib merged commit 1774760 into main May 20, 2026
1 check passed
mtib added a commit that referenced this pull request May 21, 2026
Replace Parakeet TDT 0.6B v3 (3 GB peak, not realtime on M1 Air) with three
CTC-headed offline models behind the existing picker:

- Parakeet TDT-CTC 110M (EN, ~99 MB) — default, best English quality
- FastConformer CTC multilingual (EN/DE/ES/FR, ~98 MB) — adds German
- Moonshine Tiny (EN, ~45 MB) — kept as lightest fallback

Both new models settle at ~630 MB RSS with mic + system active; ~4 s load
time under CoreML. Settings migrates the stored "parakeet" value.

Pipeline: when system audio is voiced, the mic stream is now fully gated —
no resample, no VAD, no decode. Mic VAD is flushed on gate entry so any
open segment closes cleanly. The single shared recognizer (NSLock) is
unchanged. Also tightened VAD buffer compaction (after every drain).

Quit UX: applicationShouldTerminate now returns .terminateLater and drains
on a detached task, replying once flush completes. MenuBarController gets
beginQuitTransition() to dim the status item and freeze the label.
Measured quit on a running pipeline: 0.74 s (was up to 5 s of frozen UI).

Cleanup: delete the orphaned RNNoise wrapper, DenoisingAudioSource, and
vendored CRNNoise target — Pipeline never wired them in.

CLAUDE.md: refreshed architecture diagram and model table, documented
NSString lifetime across C calls (bite #3) and why the 0.6B was dropped
(bite #2).
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