django-haystack / django-haystack/django-haystack
"__len__() should return >=0" error when term not found
Open
Nobody has claimed this yet.
needs review
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 1.3k
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 3
Description
Using django-haystack==2.1.0 and Whoosh==2.5.7, I'm seeing the following exception for many search terms. I've rebuilt the index (a couple times), to no avail.
File "/home/devuser/webapps/pcgc-env/lib/python2.7/site-packages/haystack/query.py", line 697, in _manual_iter
if self._cache_is_full():
File "/home/devuser/webapps/pcgc-env/lib/python2.7/site-packages/haystack/query.py", line 680, in _cache_is_full
return len(self._result_cache) >= len(self)
ValueError: __len__() should return >= 0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in haystack/query.py at _manual_iter and _cache_is_full, using the reported no-results search terms to reproduce the ValueError. Trace how the result cache and query length are calculated when a term is not found, then verify that such searches complete without the exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100