5

I am using django-haystack and Whoosh on my Ubuntu server and finding that certain search queries just raise an error page, and I have no idea why this is happening...

I am using the following ones

Whoosh==2.4.0
django-haystack==1.2.7

And I also run python manage.py update_index once every hour

Example traceback

Traceback (most recent call last):

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

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/hooks/framework_django.py", line 430, in __call__
   return self.__wrapped(*args, **kwargs)

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

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/haystack/views.py", line 145, in create_response
   return render_to_response(self.template, context, context_instance=self.context_class(self.request))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
   return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader.py", line 188, in render_to_string
   return t.render(context_instance)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 123, in render
   return self._render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/api/function_trace.py", line 82, in __call__
   return self._nr_next_object(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
   return self.nodelist.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 127, in render
   return compiled_parent._render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/api/function_trace.py", line 82, in __call__
   return self._nr_next_object(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
   return self.nodelist.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/hooks/framework_django.py", line 622, in __call__
   return self.__wrapped(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 64, in render
   result = block.nodelist.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 311, in render
   return self.nodelist_true.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 227, in render
   nodelist.append(node.render(context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 915, in render
   resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 653, in resolve
   value = self._resolve_lookup(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 692, in _resolve_lookup
   raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute

VariableDoesNotExist: Failed lookup for key [object] in u'None'


<WSGIRequest
GET:<QueryDict: {u'q': [u'stockholm']}>,
ApPeL
  • 4,801
  • 9
  • 47
  • 84
  • 2
    I've noticed the same behavior running against Xapian, so I don't think it's backend related. You're most likely using the `highlight` tag, because it's poorly designed and raises this obtuse exception when `result` is `None`. Now why `result` is `None` is a totally different question. It feels like a bug. – Chris Pratt May 22 '12 at 14:57
  • @ChrisPratt thanks for the response, I am not currently using highlight tag, but I do find it quite frustrating that other people are having these issues and very little know how to fix it... – ApPeL May 23 '12 at 06:41

1 Answers1

0

Could you please put here your view and your template code? If this is happening with just some queries and not all of them, it could be the parameters you are passing to the view. Here's the code of the view I'm using to make search queries using Haystack 2.0 and Whoosh 2.3.2 in a project of my own:

def search(request):
   sqs = SearchQuerySet().filter(content=AutoQuery(request.GET['q']))
return  render_to_response('search.html', {'sqs': sqs,})

and this works perfectly fine. I guess you should consider using the latest version of Haystack, because I was experiencing a lot of bugs with the old stable ones. And I recommend you to use the "rebuild_index" once in a while too, just in case.

  • Can't speak for the OP, but at least in my case: I'm using the Haystack-provided search view, so no customization there. I'm running off Haystack's master branch and a cron job updates the index every hour. But, thanks for answering. Like I said, I can't speak for the OP, so perhaps your advice will end up being useful to them. – Chris Pratt Jul 26 '12 at 14:55