fix: member search matches substrings, not just prefixes#2529
Open
yoamomonstruos wants to merge 4 commits into
Open
fix: member search matches substrings, not just prefixes#2529yoamomonstruos wants to merge 4 commits into
yoamomonstruos wants to merge 4 commits into
Conversation
Neither FullText nor Prefix FTS can match a fragment inside a single lexeme: kind-0 profile content is tokenized as whole names, so a member search for "kurs" never finds "mattkursmark". Contains mode matches the raw content with an escaped ILIKE pattern instead of a tsquery, keeping the community fence and the search_tsv allowlist exclusion (gift wraps et al stay invisible). Accepted on the bridge as search_mode="contains". Co-authored-by: Cursor <cursoragent@cursor.com>
Flip the user-search filters from search_mode="prefix" to "contains" so every picker surface (member add, @mentions, DM recipients, topbar people) matches any typed fragment of a name. Message typeahead stays on prefix. Co-authored-by: Cursor <cursoragent@cursor.com>
buzz_db::user::search_users, UserSearchProfile, and escape_like had no callers anywhere and no relay-facing surface; relay user search now goes through buzz-search contains mode. Co-authored-by: Cursor <cursoragent@cursor.com>
Shipped desktop and mobile builds send search_mode="prefix" for user pickers over kinds:[0] and can't be retroactively taught "contains". Every prefix hit is a substring hit and profile-only searches are always picker typeaheads, so the bridge maps that shape to contains — installed apps get mid-token matching as soon as the relay deploys, no client update needed. Message typeahead queries other kinds and keeps true prefix matching. Co-authored-by: Cursor <cursoragent@cursor.com>
yoamomonstruos
marked this pull request as ready for review
July 23, 2026 15:27
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.
Member search (and every other user-picker surface) only matched from the start of a name. Searching "matt" found
mattkursmark; searching "kurs" returned nothing.Root cause. User pickers search kind-0 profiles through the relay's NIP-50 FTS path with
search_mode: "prefix". Profile content is indexed as a whole JSON blob, so a name is a singlesimplelexeme, and the prefix tsquery ('kurs':*) can never match mid-token. No existing mode could: full-text needs the whole word.Fix, in commit order:
buzz-searchgainsSearchMode::Contains: case-insensitive substring matching via escapedILIKEon raw content, with the community fence, pagination, and the search-allowlist exclusion (search_tsv IS NOT NULL, so gift wraps and friends stay invisible) all unchanged. The bridge acceptssearch_mode: "contains".containsinstead ofprefix. Desktop message typeahead keeps true prefix.buzz_db::user::search_usersis deleted. It had no callers and no reachable surface; leaving it invites the "just wire it up" confusion that shaped the original issue report.prefix+kinds:[0]) to contains. Shipped desktop and mobile builds can't be taught the new mode, and every prefix hit is a substring hit, so installed apps get mid-token matching as soon as the relay deploys, with no client update. This also covers the rollout window where new clients talk to old relays: those degrade to whole-word matching, so the server-side upgrade is what actually fixes fleets in the wild.Verification. New FTS integration tests cover mid-token matching, case-insensitivity, LIKE-metacharacter escaping, community isolation, and the allowlist fence (
cargo test -p buzz-search -- --include-ignored, requires Postgres). Bridge unit tests pin the mode parsing and the prefix upgrade. Verified live against a local relay overPOST /query: prefixkursand containskursboth return the seededmattkursmarkprofile,%stays literal, and message-kind prefix search is unchanged.Deferred. A
pg_trgmindex is not included. The contains scan is index-narrowed to a community's kind-0 rows, so cost scales with member count, not message volume; below ~50k members it is single-digit milliseconds. If relay timing ever shows profile search above ~50ms, a partial trigram index on kind-0 content is a one-migration follow-up.