Fix (dev): return empty list for non-positive search limit (#12703)

This commit is contained in:
shamoon
2026-05-04 08:50:15 -07:00
committed by GitHub
parent 31afd0483f
commit ca4444c9a3
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -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,