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

@ -205,8 +205,15 @@ def _filtered_query(
) + timedelta(days=1)
query = query.where(Video.published_at < end)
if q:
like = f"%{q}%"
query = query.where(or_(Video.title.ilike(like), Channel.title.ilike(like)))
# Accent-insensitive: unaccent() both sides so "tiesto" matches "Tiësto" (ILIKE alone
# is case- but not diacritic-insensitive). unaccent is enabled by migration 0029.
like = func.unaccent(f"%{q}%")
query = query.where(
or_(
func.unaccent(Video.title).ilike(like),
func.unaccent(Channel.title).ilike(like),
)
)
if tags:
# AND across tag categories (e.g. language AND topic narrows), OR within a