Full-text search uses to_tsvector('simple'): diacritics and inflections silently return no results
Summary
search_tsv is generated with to_tsvector('simple', content). The simple configuration does no
stemming and no accent folding, so message search misses obvious matches in any language where words
inflect or carry diacritics. On a Portuguese-speaking team this makes search unreliable for everyday
queries; English is affected too, just less visibly.
The migration comment says the config can be revisited "behind evidence" — this issue is that evidence, measured on a self-hosted relay.
Reproduction
Relay ghcr.io/block/buzz:sha-00e61ea, single-node deploy/compose stack, Postgres 17.
Post one message:
Manutenção programada nas estações de trabalho — configurações de rede serão revisadas
Then search via buzz messages search --query <term>:
| Query | Expected | Actual |
|---|---|---|
manutenção |
match | ✅ match |
manutencao (no diacritic) |
match | ❌ no results |
estações (as written) |
match | ✅ match |
estação (singular) |
match | ❌ no results |
programada |
match | ✅ match |
Same behaviour through POST /query with a NIP-50 search filter.
Why this matters in practice
- Diacritics are typed inconsistently on mobile.
manutencaois how a large share of Portuguese-speaking users will type it — including people who wrote the original message. Search silently returns nothing, which reads as "the message is gone", not "your query was normalised differently". - Inflection is not an edge case. Singular/plural is the most common way a searcher's wording
differs from the author's.
estaçãovsestaçõesis not a clever query; it is the normal one. - English is affected as well, just less noticeably:
rundoes not matchrunning,deploydoes not matchdeployed. - The failure is silent. There is no "did you mean", no partial match, no hint that normalisation is the reason — an empty result set is indistinguishable from "no such message".
Root cause
migrations/0001_initial_schema.sql:
search_tsv TSVECTOR GENERATED ALWAYS AS (
CASE WHEN kind IN (1059, 30300, 30622, 44100, 44101) THEN NULL::tsvector
ELSE to_tsvector('simple', content)
END
) STORED,
with the accompanying comment:
'simple'config = no stemming/stopwords, matching the existing substring-ish search semantics; the search lane can revisit the config behind evidence.
Query side matches it in crates/buzz-search/src/query.rs:
qb.push("websearch_to_tsquery('simple', ");
So index and query are consistent — the behaviour is deliberate, not a mismatch. The question is
whether simple is the right default once a deployment is single-language.
Possible directions
Listing options rather than proposing a patch, since this is a product call and there are real trade-offs:
unaccent+simple— fixes diacritics only, keeps language-neutral behaviour. Requires theunaccentextension and anIMMUTABLEwrapper for the generated column. Smallest behaviour change; does not address inflection.- Operator-configurable text search configuration (e.g.
BUZZ_FTS_CONFIG=portuguese, defaulting tosimple). Self-hosted deployments are usually single-language, so the operator knows the answer the product cannot. Changing it means rebuildingsearch_tsv. - Keep
simple, surface the constraint in the UI — an empty result is currently indistinguishable from "nothing matched". Even a hint that search is exact-form would remove most of the confusion, at no schema cost.
Option 2 seems the best fit for self-hosted, but option 3 alone would already remove the "the message disappeared" reading, which is the part that erodes trust in search.
Environment
- Relay:
ghcr.io/block/buzz:sha-00e61ea, NIP-11 reportsBuzz Relay 0.2.1 - Deployment:
deploy/composesingle node, Postgres 17, self-hosted - Client:
buzz-clibuilt from the same commit - Language: Brazilian Portuguese (pt-BR)
Note on the privacy exclusions
Unrelated to the bug, but worth recording since I read the same code: the CASE excluding kinds
1059 / 30300 / 30622 / 44100 / 44101 from search_tsv means gift-wrapped DMs are not in the search
index at all (NULL tsvector never matches @@). That is a good property and it is easy to miss —
it deserves to stay whatever happens to the text search configuration.
Confirming this on a different language family, because CJK fails the same config for a different reason — and the difference matters for which fix gets chosen.
Measured on just setup local dev (Postgres 17.11, migrations/0001 schema).
Tokenisation
simple splits on whitespace and punctuation only. Korean is agglutinative, and
Japanese/Chinese have no whitespace at all:
| Language | Input | to_tsvector('simple', …) |
|---|---|---|
| Korean | 번역을 부탁해 |
'번역을':1 '부탁해':2 — particle fused to the stem |
| Japanese | 日本語のテスト |
'日本語のテスト':1 — whole sentence, one lexeme |
| Chinese | 这是一个测试 |
'这是一个测试':1 — whole sentence, one lexeme |
| English | please translate this |
'please':1 'this':3 'translate':2 |
FullText mode (websearch_to_tsquery)
| Case | Match |
|---|---|
번역을 부탁해 ← 번역 (stem) |
❌ |
번역을 부탁해 ← 번역을 (exact eojeol) |
✅ |
번역이 필요해 ← 번역 |
❌ |
日本語のテスト ← テスト |
❌ |
这是一个测试 ← 测试 |
❌ |
please translate this ← translate |
✅ |
Why this is a distinct class from diacritics/inflection
For Portuguese the tokeniser produces the right tokens and only normalisation
is missing — unaccent, or a language-specific config, fixes it.
For Japanese and Chinese the tokeniser produces the wrong tokens. There is no
to_tsvector('japanese', …) in stock Postgres, and no stemming configuration
recovers a word boundary that was never detected. It needs a segmenter —
pg_bigm, pgroonga, or an n-gram column.
So a fix that resolves this issue by moving to per-language configs would leave CJK exactly where it is today. Flagging it now rather than after that choice is made.
One extra wrinkle: the two modes disagree for Korean
SearchMode::Prefix (crates/buzz-search/src/query.rs:149, the desktop
typeahead) appends :* to the trailing token, which accidentally works for
Korean because particles are suffixes:
| Case | FullText |
Prefix |
|---|---|---|
번역을 부탁해 ← 번역 |
❌ | ✅ |
번역이 필요해 ← 번역 |
❌ | ✅ |
日本語のテスト ← テスト |
❌ | ❌ |
Prefix does not rescue Japanese or Chinese, because :* only anchors at the
start of a lexeme and the lexeme is the entire sentence. It matches only when
the query happens to be a sentence-initial prefix — 日本:* matches
日本語のテスト and 这是:* matches 这是一个测试, while テスト:* and
测试:* do not.
For a Korean user that reads as: the message appears in the typeahead dropdown, then vanishes when they press Enter. That is a worse failure than a plain empty result, because it looks like the message was deleted.
Repro
docker exec -e PGPASSWORD=buzz_dev buzz-postgres psql -U buzz -d buzz -X -c \
"SELECT to_tsvector('simple','번역을 부탁해') @@ websearch_to_tsquery('simple','번역');"
# f
docker exec -e PGPASSWORD=buzz_dev buzz-postgres psql -U buzz -d buzz -X -c \
"SELECT to_tsvector('simple','日本語のテスト');"
# '日本語のテスト':1
Happy to open a separate issue for the CJK case if you'd rather keep this one scoped to normalisation — it may well want a different fix than the one that lands here.