Skip to content

fix: stop search from failing on a trailing negated hyphenated word - #60

Merged
flthibaud merged 1 commit into
developfrom
fix/search-negated-prefix
Nov 11, 2026
Merged

flthibaud merged 1 commit into
developfrom
fix/search-negated-prefix

Conversation

@flthibaud

Copy link
Copy Markdown
Owner

tsqueryExpr appended :* to the text form of websearch_to_tsquery. A query ending with a negated hyphenated word (chat -foo-bar, -e-mail) renders with a closing parenthesis, and ):* is not valid tsquery syntax, so the search returned a 500.

  • The prefix marker is now appended only when the rendered text ends with a lexeme (a closing quote); otherwise the text is cast as it is.
  • New DB test TestSearchWithTrailingNegatedHyphenatedWord; TestSearchMatchesAPrefix still passes.

Tested with gofmt, go vet ./... and go test -race ./... against a migrated postgres:16 (no test skipped).

Closes #18

@flthibaud

Copy link
Copy Markdown
Owner Author

Review: OK to merge.

  • Code and DB test by Mistral. Its change broke TestSearchQueryExpr (it counted the config name twice, now four times); I corrected that assertion.
  • Checked on PostgreSQL that a phrase query still ends with a quote, so "foo bar" keeps its prefix match.
  • All three acceptance points of Search returns 500 when the query ends with a negated hyphenated word #18 are covered except the HTTP-level one, which follows from the model test.

@flthibaud
flthibaud merged commit f5d2312 into develop Nov 11, 2026
5 checks passed
@flthibaud
flthibaud deleted the fix/search-negated-prefix branch November 11, 2026 23:06
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.

Search returns 500 when the query ends with a negated hyphenated word

1 participant