Skip to content

fix(search): handle hyphenated queries and preserve quoted literals in FTS5 - #1777

Closed
eren-karakus0 wants to merge 1 commit into
NousResearch:mainfrom
eren-karakus0:fix/fts5-hyphen-quoted-queries
Closed

fix(search): handle hyphenated queries and preserve quoted literals in FTS5#1777
eren-karakus0 wants to merge 1 commit into
NousResearch:mainfrom
eren-karakus0:fix/fts5-hyphen-quoted-queries

Conversation

@eren-karakus0

Copy link
Copy Markdown
Contributor

Summary

  • Fixes session_search mishandles hyphenated FTS5 queries and strips quoted literals #1770: session_search now correctly handles hyphenated terms (chat-send) and preserves user-provided quoted literals ("exact phrase") for FTS5 phrase search.
  • Rewrote _sanitize_fts5_query() to split queries into balanced-quoted vs unquoted segments — quoted phrases pass through intact, while unquoted inter-word hyphens are converted to spaces to match unicode61 tokenizer behavior.
  • Added logger.debug on FTS5 OperationalError for diagnosability.

Changes

File What
hermes_state.py Quote-aware FTS5 sanitization + debug logging
tests/test_hermes_state.py 7 new tests (4 unit + 3 integration)

Test plan

  • All 116 existing + new tests pass (pytest tests/test_hermes_state.py)
  • chat-send query finds hyphenated content (integration test)
  • "deploy docker" phrase search works (integration test)
  • "chat-send" quoted-hyphen regression covered (integration test)
  • Existing dangerous-query tests still pass (no regression)

…n FTS5

Split FTS5 query sanitization into quote-aware segments so that balanced
quoted phrases (e.g. "exact phrase") are preserved for phrase search,
while inter-word hyphens in unquoted text (e.g. chat-send) are converted
to spaces to match unicode61 tokenizer behavior.

Add debug logging for FTS5 OperationalError to aid future diagnosis.

Closes NousResearch#1770
@eren-karakus0

Copy link
Copy Markdown
Contributor Author

Closing — already fixed by #1776 (merged by teknium1). Our implementation was nearly identical but arrived ~10 minutes late.

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.

session_search mishandles hyphenated FTS5 queries and strips quoted literals

1 participant