Skip to content

postgresql: AND whitespace-separated terms in SubstringSearch - #73

Merged
mattn merged 1 commit into
fiatjaf:masterfrom
mattn:feat/postgres-substring-multiterm
Aug 11, 2026
Merged

mattn merged 1 commit into
fiatjaf:masterfrom
mattn:feat/postgres-substring-multiterm

Conversation

@mattn

@mattn mattn commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #72. SubstringSearch matched the entire query string as a single ILIKE '%q%', so a multi-word search like 東京 京都 looked for that literal substring (the space included) and missed content that contains both words separately.

Split the search on whitespace and AND one ILIKE per term, mirroring plainto_tsquery's all-terms semantics (which the default tsvector path already has). strings.Fields also treats the ideographic space (U+3000) as a separator, so full-width-spaced CJK queries work too. Single-term behavior is unchanged.

Test added for the multi-term case.

SubstringSearch matched the whole query string as one ILIKE '%q%', so a
multi-word search like "東京 京都" looked for that literal substring (space
included) and missed content containing both words separately. Split on
whitespace and AND one ILIKE per term instead, mirroring plainto_tsquery's
all-terms semantics. strings.Fields also splits the ideographic space (U+3000),
so full-width-spaced CJK queries work too. Single-term behavior is unchanged.
@mattn
mattn merged commit 4044cac into fiatjaf:master Aug 11, 2026
1 check passed
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