4669: First search with elasticsearch: error 500

Misery

What version are you running?

3.0.3

What's the URL of the page containing the problem?

http://localhost/search/?q=test

What steps will reproduce the problem?

  1. Enable elastic search in admin settings
  2. Type something in text area and press enter

What is the expected output? What do you see instead?

Nice error message or success but no error 500

What operating system are you using? What browser?

Linux, Firefox

Please provide any additional information below.

too many values to unpack
Traceback (most recent call last):
File "/var/www/dist/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, callback_args, callback_kwargs)
File "/var/www/dist/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args,
kwargs)
File "/var/www/dist/lib/python2.7/site-packages/reviewboard/search/views.py", line 98, in dispatch
return self.form_valid(form)
File "/var/www/dist/lib/python2.7/site-packages/haystack/generic_views.py", line 80, in form_valid
'object_list': self.queryset
File "/var/www/dist/lib/python2.7/site-packages/reviewboard/search/views.py", line 117, in get_context_data
kwargs)
File "/var/www/dist/lib/python2.7/site-packages/django/views/generic/list.py", line 112, in get_context_data
paginator, page, queryset, is_paginated = self.paginate_queryset(queryset, page_size)
File "/var/www/dist/lib/python2.7/site-packages/django/views/generic/list.py", line 56, in paginate_queryset
page = paginator.page(page_number)
File "/var/www/dist/lib/python2.7/site-packages/django/core/paginator.py", line 50, in page
number = self.validate_number(number)
File "/var/www/dist/lib/python2.7/site-packages/django/core/paginator.py", line 39, in validate_number
if number > self.num_pages:
File "/var/www/dist/lib/python2.7/site-packages/django/core/paginator.py", line 86, in _get_num_pages
if self.count == 0 and not self.allow_empty_first_page:
File "/var/www/dist/lib/python2.7/site-packages/django/core/paginator.py", line 72, in _get_count
self._count = self.object_list.count()
File "/var/www/dist/lib/python2.7/site-packages/haystack/query.py", line 487, in count
return len(self)
File "/var/www/dist/lib/python2.7/site-packages/haystack/query.py", line 96, in len
self._result_count = self.query.get_count()
File "/var/www/dist/lib/python2.7/site-packages/haystack/backends/init.py", line 626, in get_count
self.run()
File "/var/www/dist/lib/python2.7/site-packages/haystack/backends/init.py", line 563, in run
results = self.backend.search(final_query,
search_kwargs)
File "/var/www/dist/lib/python2.7/site-packages/haystack/backends/init.py", line 35, in wrapper
return func(obj, query_string,
args, kwargs)
File "/var/www/dist/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 497, in search
search_kwargs = self.build_search_kwargs(query_string,
kwargs)
File "/var/www/dist/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 297, in build_search_kwargs
for field, direction in sort_by:
ValueError: too many values to unpack

Misery
#1 Misery

"sort_by" tuple in line 297 has only this entry: [u'-last_updated']

Misery
#2 Misery

Work-Around in line 295:

-if sort_by is not None:
+if sort_by is not None and len(sort_by) == 2: