fix: 검색 500 에러 (ILIKE % 이스케이프) + 한글 조합 중 Enter 방지

- ILIKE '%' → '%%' (SQLAlchemy text() 파라미터 충돌 해결)
- e.isComposing 체크로 한글 조합 완료 전 Enter 무시

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-03 14:14:07 +09:00
parent 4d205b67c2
commit 3236b8d812
2 changed files with 4 additions and 4 deletions

View File

@@ -101,13 +101,13 @@ async def _search_trgm(session: AsyncSession, query: str, limit: int) -> list[Se
SELECT id, title, ai_domain, ai_summary, file_format,
GREATEST(
similarity(coalesce(title, '') || ' ' || coalesce(extracted_text, ''), :query),
CASE WHEN (coalesce(title, '') || ' ' || coalesce(extracted_text, '')) ILIKE '%' || :query || '%'
CASE WHEN (coalesce(title, '') || ' ' || coalesce(extracted_text, '')) ILIKE '%%' || :query || '%%'
THEN 0.5 ELSE 0 END
) AS score,
left(extracted_text, 200) AS snippet
FROM documents
WHERE (coalesce(title, '') || ' ' || coalesce(extracted_text, '')) %% :query
OR (coalesce(title, '') || ' ' || coalesce(extracted_text, '')) ILIKE '%' || :query || '%'
OR (coalesce(title, '') || ' ' || coalesce(extracted_text, '')) ILIKE '%%' || :query || '%%'
ORDER BY score DESC
LIMIT :limit
"""),
@@ -186,7 +186,7 @@ async def _search_hybrid(session: AsyncSession, query: str, limit: int) -> list[
FROM documents d
{vector_clause}
WHERE coalesce(d.extracted_text, '') != ''
OR (coalesce(d.title, '') || ' ' || coalesce(d.extracted_text, '')) ILIKE '%' || :query || '%'
OR (coalesce(d.title, '') || ' ' || coalesce(d.extracted_text, '')) ILIKE '%%' || :query || '%%'
) sub
WHERE sub.score > 0.001
ORDER BY sub.score DESC

View File

@@ -84,7 +84,7 @@
}
function handleSearchKeydown(e) {
if (e.key === 'Enter') {
if (e.key === 'Enter' && !e.isComposing) {
e.preventDefault();
submitSearch();
}