mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-05-26 07:00:36 +00:00
Fix (dev): return empty list for non-positive search limit (#12703)
This commit is contained in:
@@ -681,6 +681,8 @@ class TantivyBackend:
|
||||
|
||||
searcher = self._index.searcher()
|
||||
effective_limit = limit if limit is not None else searcher.num_docs
|
||||
if effective_limit <= 0:
|
||||
return []
|
||||
|
||||
if sort_field and sort_field in self.SORT_FIELD_MAP:
|
||||
mapped_field = self.SORT_FIELD_MAP[sort_field]
|
||||
|
||||
@@ -40,6 +40,10 @@ class TestWriteBatch:
|
||||
class TestSearch:
|
||||
"""Test search query parsing and matching via search_ids."""
|
||||
|
||||
def test_empty_index_returns_no_ids(self, backend: TantivyBackend) -> None:
|
||||
"""Empty indexes must not pass a zero limit to Tantivy."""
|
||||
assert backend.search_ids("missing", user=None) == []
|
||||
|
||||
def test_text_mode_limits_default_search_to_title_and_content(
|
||||
self,
|
||||
backend: TantivyBackend,
|
||||
|
||||
Reference in New Issue
Block a user