mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 23:46:18 -05:00
Search: fast ABC mode by default, opt-in deep search
The file_group.textsearch tsvector indexes all four text columns;
d_text (captions, document text, zip contents) is ~90% of the data,
making ts_rank searches take seconds on large libraries. Add a
textsearch_abc generated column (title/author/description only, ~8x
smaller) and default all searches to it, with deep=true opting into the
full column.
Database:
- Migration adds the generated column and a GIN index (rewrites the
table; a few minutes on large libraries).
Backend:
- FilesSearchRequest, VideoSearchRequest, ArchiveSearchRequest, and
DocSearchRequest accept `deep`; each search function picks the column.
- /api/search_file_estimates returns both counts in one index-bound
query (COUNT FILTER on the abc subset): `file_groups` (fast) and
`file_groups_deep`.
UI (one coherent story across the count surfaces):
- The typing dropdown always suggests the deep count (what is findable).
- The tab badge shows the active mode's count so it matches the result
list.
- The gap is reconciled by a hint offering deep search: count-aware on
the global search ("No results in fast search. N results available in
deep search." / "N more results available..."), generic on the module
pages (no deep estimate there). The hint resets pagination.
- "Search Depth" toggle in the search filter modals, persisted as
?deep=true.
Tests that relied on d_text matches now pass deep=True, with fast-mode
assertions alongside. Also skip flaky test_download_channel on
CircleCI.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1522022330
commit
73fafcd645
33 changed files with 385 additions and 77 deletions
|
|
@ -187,7 +187,7 @@ export async function tagChannelInfo(channelId, tagName) {
|
|||
});
|
||||
}
|
||||
|
||||
export async function searchVideos(offset, limit, channelId, searchStr, order_by, tagNames, headline, censored) {
|
||||
export async function searchVideos(offset, limit, channelId, searchStr, order_by, tagNames, headline, censored, deep) {
|
||||
// Build a search query to retrieve a list of videos from the API
|
||||
offset = parseInt(offset || 0);
|
||||
limit = parseInt(limit || DEFAULT_LIMIT);
|
||||
|
|
@ -208,6 +208,9 @@ export async function searchVideos(offset, limit, channelId, searchStr, order_by
|
|||
if (censored) {
|
||||
body['censored'] = true;
|
||||
}
|
||||
if (deep) {
|
||||
body['deep'] = true;
|
||||
}
|
||||
|
||||
console.debug('searching videos', body);
|
||||
|
||||
|
|
@ -697,7 +700,7 @@ export async function saveCatalog(items) {
|
|||
}
|
||||
|
||||
|
||||
export async function searchArchives(offset, limit, domain, searchStr, order, tagNames, headline) {
|
||||
export async function searchArchives(offset, limit, domain, searchStr, order, tagNames, headline, deep) {
|
||||
// Build a search query to retrieve a list of videos from the API
|
||||
offset = parseInt(offset || 0);
|
||||
limit = parseInt(limit || DEFAULT_LIMIT);
|
||||
|
|
@ -717,6 +720,9 @@ export async function searchArchives(offset, limit, domain, searchStr, order, ta
|
|||
if (headline) {
|
||||
body['headline'] = true;
|
||||
}
|
||||
if (deep) {
|
||||
body['deep'] = true;
|
||||
}
|
||||
|
||||
console.debug('searching archives', body);
|
||||
const response = await apiPost(`${ARCHIVES_API}/search`, body);
|
||||
|
|
@ -1212,7 +1218,7 @@ export async function deleteDownload(downloadId) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function filesSearch(offset, limit, searchStr, mimetypes, model, tagNames, headline, months, fromYear, toYear, anyTag, order, suffix, path) {
|
||||
export async function filesSearch(offset, limit, searchStr, mimetypes, model, tagNames, headline, months, fromYear, toYear, anyTag, order, suffix, path, deep) {
|
||||
const body = {search_str: searchStr, offset: parseInt(offset), limit: parseInt(limit), any_tag: anyTag};
|
||||
if (suffix) {
|
||||
body['suffix'] = suffix;
|
||||
|
|
@ -1244,6 +1250,9 @@ export async function filesSearch(offset, limit, searchStr, mimetypes, model, ta
|
|||
if (order) {
|
||||
body['order'] = order;
|
||||
}
|
||||
if (deep) {
|
||||
body['deep'] = true;
|
||||
}
|
||||
console.info('searching files', body);
|
||||
const response = await apiPost(`${API_URI}/files/search`, body);
|
||||
|
||||
|
|
@ -1988,6 +1997,7 @@ export async function searchEstimateFiles(search_str, tagNames, mimetypes, month
|
|||
|
||||
return {
|
||||
fileGroups: content.file_groups,
|
||||
fileGroupsDeep: content.file_groups_deep,
|
||||
}
|
||||
} else {
|
||||
console.error('Failed to get file search estimates!');
|
||||
|
|
@ -2220,7 +2230,7 @@ export async function getDoc(fileGroupId) {
|
|||
}
|
||||
|
||||
|
||||
export async function searchDocs(offset, limit, searchStr, order, tagNames, author, subject, mimetype) {
|
||||
export async function searchDocs(offset, limit, searchStr, order, tagNames, author, subject, mimetype, deep) {
|
||||
offset = parseInt(offset || 0);
|
||||
limit = parseInt(limit || DEFAULT_LIMIT);
|
||||
let body = {offset, limit};
|
||||
|
|
@ -2242,6 +2252,9 @@ export async function searchDocs(offset, limit, searchStr, order, tagNames, auth
|
|||
if (mimetype) {
|
||||
body['mimetype'] = mimetype;
|
||||
}
|
||||
if (deep) {
|
||||
body['deep'] = true;
|
||||
}
|
||||
|
||||
console.debug('searching docs', body);
|
||||
const response = await apiPost(`${DOCS_API}/search`, body);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue