Issue #102 open

SearchQuerySet error on Linux when using order_by

Tommy Tam
created an issue

I'm running Django Haystack with Whoosh. Tried on both Windows and Linux. Whoosh and Haystack were installed with easy_install on both Windows and Linux. On Windows, it works fine. On Linux, the following order by on the SearchQuerySet will cause error.

sqs = sqs.order_by('name')

Error: Django Version: 1.2.3 Exception Type: error Exception Value:
unpack requires a string argument of length 4 Exception Location: /home/foodia/lib/python2.6/Whoosh-1.5.5-py2.6.egg/whoosh/filedb/structfile.py in read_uint, line 230 Python Executable: /usr/local/bin/python Python Version: 2.6.5

Comments (10)

  1. Matt Chaput repo owner
    • changed status to open
    • changed component to Search

    Hi, sorry about this problem and sorry I didn't see this bug until now, there was a problem with my mail.

    I think I have an idea what this might be, but could you please add some information if possible:

    1. Could you please install the latest version of Whoosh from PyPI and confirm the problem still occurs?
    2. Can you give me the complete stack trace from the error?
    3. Is this in a single-threaded, multi-threaded, or multi-processing server?
    4. Is the problem intermittent or does it happen on every request?

    Thanks!

  2. Tommy Tam reporter

    I noticed that the hosted linux site was using python 2.6, and the easy_install of whoosh installed 1.5.5 (may be this is what you set up as the version for python 2.6 in easy_install?) My windows machine has python 2.7 and easy_install installed whoosh 1.5.9.

    Anyhow, I'm getting your latest source code and using setup.py install on both to try now.

  3. Tommy Tam reporter

    Now with whoosh 1.5.9 on python 2.6. Using any filter will yield no search result. As for order_by, ordering by certain column will still cause error like this...

    Environment:

    Request Method: GET Request URL: http://dev.foodia.com/search4/?q=&order_by=rating&foods= Django Version: 1.2.3 Python Version: 2.6.5 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'south', 'registration', 'profiles', 'foodia.polls', 'foodia.food', 'django.contrib.comments', 'foodia_comments', 'sorl.thumbnail', 'fccv', 'django_facebook', 'jogging', 'haystack'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'maintenancemode.middleware.MaintenanceModeMiddleware', 'food.middleware.http.SetRemoteAddrFromForwardedFor', 'jogging.middleware.LoggingMiddleware')

    Traceback: File "/home/foodia/webapps/dev/lib/python2.6/django/core/handlers/base.py" in get_response 100. response = callback(request, *callback_args, callback_kwargs) File "/home/foodia/webapps/dev/foodia/food/views/search_engine_views.py" in searchCustom 148. for result in sqs[0:100]: #limit the number of results to look File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/query.py" in getitem 223. self._fill_cache(start, bound) File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/query.py" in _fill_cache 133. results = self.query.get_results() File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/backends/init.py" in get_results 431. self.run() File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/backends/init.py" in run 362. results = self.backend.search(final_query, kwargs) File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/backends/init.py" in wrapper 50. return func(obj, query_string, *args, kwargs) File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/backends/whoosh_backend.py" in search 370. return self._process_results(raw_page, highlight=highlight, query_string=query_string, spelling_query=spelling_query) File "/home/foodia/lib/python2.6/django_haystack-1.1.0-py2.6.egg/haystack/backends/whoosh_backend.py" in _process_results 407. for doc_offset, raw_result in enumerate(raw_page): File "/home/foodia/lib/python2.6/Whoosh-1.5.9-py2.6.egg/whoosh/searching.py" in iter 1078. return iter(self.results[self.offset:self.offset + self.pagelen]) File "/home/foodia/lib/python2.6/Whoosh-1.5.9-py2.6.egg/whoosh/searching.py" in getitem 708. for i in xrange(start, stop, step)]

    Exception Type: IndexError at /search4/ Exception Value: list index out of range

  4. Tommy Tam reporter

    Thanks, Matt. It is getting better... now no error, but the paginator is showing like 67 pages of results while the result objects are not showing anything.

    By the way, using "filter" with anything yield no result at all. What I mean is that for this statement:

    sqs = SearchQuerySet().models(Product).filter(content=query)

    If query = '', there is a lot of results. If query equals anything but blank, no result at all. This used to work. Should I report another ticket?

  5. mrblue

    Hi Mat,

    I tried to clone the latest version of Whoosh, and tried with the above same code and this error happened:

          File "/usr/local/lib/python2.6/dist-packages/Whoosh-1.8.1-py2.6.egg/whoosh/searching.py", line 450, in search_page
            **kwargs)
        TypeError: search() got an unexpected keyword argument 'optimized'
    

    Is there anything wrong ?

    Thanks a lot

  6. Thomas Waldmann

    tommy, could you try to reproduce your issue with a current whoosh version and either:

    • close this ticket (if it was fixed), or
    • close this ticket and open another ticket just for the remaining issue (if it still happens)?

    this ticket here is a bit messy as it covers all sorts of things and the title does not match the current state.

  7. Log in to comment