toastdriven/django-haystack — Issue #491: Result cache IndexError: list index out of range
Author: witten
Created: 2012-01-26 23:38:23+00:00
State: open

I'm using Haystack 1.2.4 with Python 2.7.1, Django 1.3.0, and Whoosh 2.3.2. Every few days, I get a Haystack error when users search on my site, but the error is not reproducible. The error appears to occur in the Haystack result cache, within ```SearchQuerySet.__getitem__()```. The following traceback has the most recent frame at the top:

```
IndexError: list index out of range

File ".../lib/python2.7/site-packages/haystack/query.py", line 242, in __getitem__
return self._result_cache[start]

File ".../lib/optixcommon/src/partners/views/search.py", line 23, in create_response
if len(self.results) != 1 or self.results[0] is None:

File ".../lib/python2.7/site-packages/haystack/views.py", line 50, in __call__
return self.create_response()

File ".../mycode.py", line 48, in search
return MySearchView(template='mytemplate.html', form_class=MySearchForm)(request)

File ".../lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
```

Here are the values in the code at the line where the error occurs:

```
bound: 1
is_slice: False
k: 0
self: []
start: 0
```

Please let me know if I can provide any other information.