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:
@@ -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,
|
SELECT id, title, ai_domain, ai_summary, file_format,
|
||||||
GREATEST(
|
GREATEST(
|
||||||
similarity(coalesce(title, '') || ' ' || coalesce(extracted_text, ''), :query),
|
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
|
THEN 0.5 ELSE 0 END
|
||||||
) AS score,
|
) AS score,
|
||||||
left(extracted_text, 200) AS snippet
|
left(extracted_text, 200) AS snippet
|
||||||
FROM documents
|
FROM documents
|
||||||
WHERE (coalesce(title, '') || ' ' || coalesce(extracted_text, '')) %% :query
|
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
|
ORDER BY score DESC
|
||||||
LIMIT :limit
|
LIMIT :limit
|
||||||
"""),
|
"""),
|
||||||
@@ -186,7 +186,7 @@ async def _search_hybrid(session: AsyncSession, query: str, limit: int) -> list[
|
|||||||
FROM documents d
|
FROM documents d
|
||||||
{vector_clause}
|
{vector_clause}
|
||||||
WHERE coalesce(d.extracted_text, '') != ''
|
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
|
) sub
|
||||||
WHERE sub.score > 0.001
|
WHERE sub.score > 0.001
|
||||||
ORDER BY sub.score DESC
|
ORDER BY sub.score DESC
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSearchKeydown(e) {
|
function handleSearchKeydown(e) {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter' && !e.isComposing) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
submitSearch();
|
submitSearch();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user