Skip to content

fix(search): robust FTS5 sanitize + real LIKE fallback + param aliases - #3

Open
ytrofr wants to merge 1 commit into
mainfrom
fix-search-fts-robustness
Open

fix(search): robust FTS5 sanitize + real LIKE fallback + param aliases#3
ytrofr wants to merge 1 commit into
mainfrom
fix-search-fts-robustness

Conversation

@ytrofr

@ytrofr ytrofr commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Problem

Hyphenated search terms (most repo names — e.g. context-mode, claude-code-templates) hit FTS5's - NOT-operator, threw a syntax error, and silently fell through to the unfiltered top-by-score list — returning unrelated items (openclaw/n8n/AutoGPT) instead of matches. This made the hub's search look broken for exactly the queries that matter, and the silent-garbage fallback violated the repo's own no-mock-data rule.

Fix

  • Sanitize FTS query (database/db.js getItems): phrase-quote any whitespace token containing an FTS operator char (-, :, ., /) so hyphenated terms are no longer parsed as operators; a lone clean token keeps prefix matching.
  • Real LIKE fallback: on FTS error, run a term-filtered LIKE search instead of returning unrelated top-scored items (honors no-mock-data).
  • Forgiving params (routes/items.js): accept ?q= / ?source= as aliases for ?search= / ?sources=.

Verification (live)

  • ?search=context-mode → returns the real context-mode item (was openclaw/n8n).
  • ?q=context-mode → confirms both the alias + the hyphen sanitize.
  • ?search=claude-code-templates → returns davila7/claude-code-templates.

Scope: only database/db.js + routes/items.js. No schema/dependency changes.

🤖 Generated with Claude Code

…aliases

Hyphenated search terms (most repo names, e.g. context-mode) hit FTS5's
'-' NOT-operator, threw a syntax error, and silently fell through to the
unfiltered top-by-score list — returning unrelated items (openclaw/n8n)
instead of matches. Now:
- phrase-quote tokens containing FTS operator chars (db.js getItems)
- on FTS error, fall back to a REAL term-filtered LIKE search, never
  unrelated items (honors no-mock-data rule)
- accept forgiving ?q= / ?source= aliases for ?search= / ?sources=

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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