fix(search): robust FTS5 sanitize + real LIKE fallback + param aliases - #3
Open
ytrofr wants to merge 1 commit into
Open
fix(search): robust FTS5 sanitize + real LIKE fallback + param aliases#3ytrofr wants to merge 1 commit into
ytrofr wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ownno-mock-datarule.Fix
database/db.jsgetItems): 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.LIKEsearch instead of returning unrelated top-scored items (honorsno-mock-data).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