mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 21:29:59 -05:00
Search: drop stopwords from unquoted terms, as Postgres did (#1085)
Postgres' english websearch_to_tsquery dropped stopwords; FTS5 indexes them. A stopword matches most of the library, so a search containing one read its whole doclist (slow on a cold HDD) and only found files that happened to contain it. translate_websearch now drops Postgres' english stopword list from unquoted terms; quoted phrases keep them. A search with nothing left to search (stopwords or punctuation only) now matches nothing in archive, video and doc search too, as files search, the search estimates and Postgres already did, instead of listing everything. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a61d528832
commit
45b52a698e
8 changed files with 107 additions and 11 deletions
|
|
@ -80,9 +80,16 @@ async def test_archives_search(test_session, archive_directory, archive_factory,
|
|||
data = {'search_str': 'baz', 'domain': 'example.org', 'deep': True}
|
||||
await check_results(async_client, data, [3, ])
|
||||
|
||||
# 1's title contains "my". Postgres ignored this stopword; FTS5 has no stopwords, so it matches.
|
||||
# 1's title contains "my", a stopword. A search of only stopwords matches nothing (as Postgres did), rather
|
||||
# than listing every archive.
|
||||
data = {'search_str': 'my', 'deep': True}
|
||||
await check_results(async_client, data, [1, ])
|
||||
await check_results(async_client, data, [])
|
||||
# "my archive" is a search for "archive", which all three titles contain.
|
||||
request, response = await async_client.post('/api/archive/search',
|
||||
content=json.dumps({'search_str': 'archive', 'deep': True}))
|
||||
archive_ids = [i['id'] for i in response.json['file_groups']]
|
||||
assert len(archive_ids) == 3
|
||||
await check_results(async_client, {'search_str': 'my archive', 'deep': True}, archive_ids)
|
||||
|
||||
# 3's title contains "third", found by the default (fast) search and the deep search.
|
||||
data = {'search_str': 'third'}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue