feat(feed): accent-insensitive search (unaccent)

Feed text search used plain ILIKE, which is case- but not diacritic-insensitive, so 'tiesto'
missed the many titles spelled 'Tiësto' — a search that ingested ~45 results showed only ~12.
Enable the postgres unaccent extension (migration 0029) and wrap both sides of the title/
channel match in unaccent(), so 'tiesto' now matches 'Tiësto'. Applies to feed, count and
facets alike.
This commit is contained in:
npeter83 2026-06-29 02:30:37 +02:00
parent a528e2c366
commit a7a72c4c7e
2 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,31 @@
"""accent-insensitive feed search (unaccent)
Revision ID: 0029_unaccent_search
Revises: 0028_live_search_provenance
Create Date: 2026-06-29
Enables the PostgreSQL `unaccent` contrib extension so the feed's text search can match
regardless of diacritics e.g. searching "tiesto" finds titles spelled "Tiësto". The feed
query wraps both sides in unaccent(); this migration just makes the function available.
`unaccent` ships with the official postgres image (postgresql-contrib). The DB role is a
superuser in our deployments, so CREATE EXTENSION succeeds; IF NOT EXISTS keeps it idempotent.
"""
from typing import Sequence, Union
from alembic import op
revision: str = "0029_unaccent_search"
down_revision: Union[str, None] = "0028_live_search_provenance"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.execute("CREATE EXTENSION IF NOT EXISTS unaccent")
def downgrade() -> None:
# Intentionally left in place: other code/queries may rely on unaccent() and dropping a
# contrib extension is rarely what's wanted on a downgrade. (The feed query reverts with
# the code, not this migration.)
pass