Skip to content

Conversation

@jdvmi00
Copy link
Contributor

@jdvmi00 jdvmi00 commented Feb 2, 2026

Adds support for quoted phrases in FTS search queries, enabling exact phrase matching alongside the existing prefix matching behavior.

Syntax

Query Behavior
hello world Prefix match: "hello"* AND "world"* (existing)
"hello world" Exact phrase: "hello world" (new)
meeting "Q1 planning" Mixed: "meeting"* AND "q1 planning" (new)

Changes

  • src/store.ts: Updated buildFTS5Query() to parse quoted phrases and pass them to FTS5 as exact matches (no wildcard), while unquoted terms continue as prefix matches
  • src/store.ts: Added sanitizeFTS5Phrase() helper that preserves spaces within phrases while removing FTS5 special characters
  • src/store.ts: Exported buildFTS5Query for testability
  • src/store.test.ts: Added unit tests for buildFTS5Query covering quoted phrases, mixed queries, unicode, case normalization, and edge cases
  • src/store.test.ts: Added integration tests for searchFTS with exact phrases

Examples

# Find exact phrase
qmd search '"project timeline"'

# Mix exact phrase with regular terms
qmd search 'meeting "Q1 planning"'

# Multiple exact phrases
qmd search '"data migration" "caboodle express"'

Notes

  • Phrases are lowercased to match FTS5 tokenization
  • Special characters within phrases are sanitized to spaces
  • Empty quoted phrases are ignored
  • Fully backward compatible — unquoted queries work exactly as before

Support quoted phrases in search queries for exact phrase matching:
- "hello world" matches the exact phrase (no prefix matching)
- Unquoted terms continue to work as prefix matches with AND
- Mixed queries like: meeting "project timeline"
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