fix: 검색 UX 개선 — Enter 키 기반 + 한국어 검색 ILIKE fallback
- 프론트: debounce 자동검색 제거 → Enter 키로만 검색 (한글 조합 문제 해결) - 백엔드: trgm threshold 0.1로 낮춤 + ILIKE '%검색어%' fallback 추가 - hybrid 검색 score threshold 0.01 → 0.001로 낮춤 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,27 +63,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearchInput() {
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = setTimeout(() => {
|
||||
const params = new URLSearchParams($page.url.searchParams);
|
||||
params.delete('page');
|
||||
if (searchQuery.trim()) {
|
||||
params.set('q', searchQuery.trim());
|
||||
} else {
|
||||
params.delete('q');
|
||||
}
|
||||
if (searchMode !== 'hybrid') {
|
||||
params.set('mode', searchMode);
|
||||
} else {
|
||||
params.delete('mode');
|
||||
}
|
||||
for (const [key, val] of [...params.entries()]) {
|
||||
if (!val) params.delete(key);
|
||||
}
|
||||
const qs = params.toString();
|
||||
goto(`/documents${qs ? '?' + qs : ''}`, { noScroll: true });
|
||||
}, 300);
|
||||
function submitSearch() {
|
||||
const params = new URLSearchParams($page.url.searchParams);
|
||||
params.delete('page');
|
||||
if (searchQuery.trim()) {
|
||||
params.set('q', searchQuery.trim());
|
||||
} else {
|
||||
params.delete('q');
|
||||
}
|
||||
if (searchMode !== 'hybrid') {
|
||||
params.set('mode', searchMode);
|
||||
} else {
|
||||
params.delete('mode');
|
||||
}
|
||||
for (const [key, val] of [...params.entries()]) {
|
||||
if (!val) params.delete(key);
|
||||
}
|
||||
const qs = params.toString();
|
||||
goto(`/documents${qs ? '?' + qs : ''}`, { noScroll: true });
|
||||
}
|
||||
|
||||
function handleSearchKeydown(e) {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
submitSearch();
|
||||
}
|
||||
}
|
||||
|
||||
async function doSearch(q, mode) {
|
||||
@@ -145,13 +149,13 @@
|
||||
data-search-input
|
||||
type="text"
|
||||
bind:value={searchQuery}
|
||||
oninput={handleSearchInput}
|
||||
placeholder="검색어 입력... (/ 키로 포커스)"
|
||||
onkeydown={handleSearchKeydown}
|
||||
placeholder="검색어 입력 후 Enter (/ 키로 포커스)"
|
||||
class="flex-1 px-3 py-1.5 bg-[var(--surface)] border border-[var(--border)] rounded-lg text-[var(--text)] text-sm focus:border-[var(--accent)] outline-none"
|
||||
/>
|
||||
<select
|
||||
bind:value={searchMode}
|
||||
onchange={() => { if (searchQuery) handleSearchInput(); }}
|
||||
onchange={() => { if (searchQuery) submitSearch(); }}
|
||||
class="px-2 py-1.5 bg-[var(--surface)] border border-[var(--border)] rounded-lg text-[var(--text)] text-xs"
|
||||
>
|
||||
<option value="hybrid">하이브리드</option>
|
||||
|
||||
Reference in New Issue
Block a user