3

Python 2.5, Django 1.2.1, most recent haystack, most recent whoosh

This is my first delve into Django-Haystack. I was following the "Getting Started" guide from Haystack and everything seemed to be going along fine, until I went to build the index.

So, running "manage.py rebuild_index" shot this back at me:

Traceback (most recent call last):
  File "/Users/steenb/Documents/Aptana Studio Workspace/bucksac/buckshr/manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 218, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.5/site-packages/haystack/management/commands/rebuild_index.py", line 13, in handle
    call_command('clear_index', **options)
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 218, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.5/site-packages/haystack/management/commands/clear_index.py", line 38, in handle
    sb.clear()
  File "/Library/Python/2.5/site-packages/haystack/backends/whoosh_backend.py", line 212, in clear
    self.index.commit()
AttributeError: 'FileIndex' object has no attribute 'commit'

Not sure even where to start with this... has anyone run into this before?

Any thoughts on a solution?

Update: Tried this with python 2.6 as well, got the same error. Is there some Whoosh configuration that I have not done?

Update: After using the below suggestion from philippbosch, the first error didn't show up anymore but now I am getting this:

Traceback (most recent call last):
  File "/Users/steenb/Documents/Aptana Studio Workspace/bucksac/buckshr/manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 218, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.5/site-packages/haystack/management/commands/update_index.py", line 69, in handle
    return super(Command, self).handle(*apps, **options)
  File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 282, in handle
    app_output = self.handle_app(app, **options)
  File "/Library/Python/2.5/site-packages/haystack/management/commands/update_index.py", line 123, in handle_app
    index.backend.update(index, small_cache_qs[start:end])
  File "/Library/Python/2.5/site-packages/haystack/backends/whoosh_backend.py", line 163, in update
    writer = AsyncWriter(self.index.writer, postlimit=self.post_limit)
TypeError: __init__() got an unexpected keyword argument 'postlimit'

I am wondering if I am using an incompatable version of Whoosh.... I grabbed the latest which is 1.0.0b2 ... http://pypi.python.org/pypi/Whoosh/

update: Turns out it is a version problem. Currently, Haystack is tied to whoosh 0.3.18

Brant
  • 5,721
  • 4
  • 36
  • 39

3 Answers3

6

I had the same problem just now. Did you try »update_index« instead of »rebuild_index«? That seemed to work for me …

philippbosch
  • 761
  • 5
  • 9
  • Well, that got me somewhere... unfortunately it just moved me to a new error... TypeError: __init__() got an unexpected keyword argument 'postlimit' – Brant Aug 06 '10 at 14:35
  • Please provide the full traceback. – philippbosch Aug 06 '10 at 14:37
  • Had the same error. Update instead of rebuild worked for me. Thanks. – Mike Meyer Aug 07 '10 at 19:58
  • @MikeMeyer, I am getting exception as `NotImplementedError: You must provide a 'model' method for the '' index` when I fire the command `manage.py rebuild_index` I could not get point why its coming can you suggest me what am I missing? – MegaBytes Mar 04 '15 at 18:30
  • @MegaBytes oh man, I have no idea. My comment is almost five years old. Have you googled the error message? I found this with one google search: https://github.com/django-haystack/django-haystack/blob/master/haystack/indexes.py#L125 – Mike Meyer Mar 05 '15 at 18:50
  • @MikeMeyer, Thanks for reply, I resolved it, it was silly my typo mistake. and after that update_index worked instead rebuild_index. – MegaBytes Mar 09 '15 at 06:16
1

Installing Whoosh 0.3.18 solved the problem on my side

Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108
0

If you found this question while attempting to delete an entry from an index, you might need to use an IndexWriter to delete the entry, rather than a FileIndex object; e.g.:

Instead of:

ix = open_dir('index')
ix.delete_by_term('path', u'/a/b/c')
ix.commit()

which throws the error discussed above, you can delete a file by running:

ix = open_dir('index')
writer = ix.writer()
writer.delete_by_term('path', u'/a/b/c')
writer.commit()
duhaime
  • 25,611
  • 17
  • 169
  • 224