2010-08-06 59 views
3

的Python 2.5,Django的1.2.1,最近的草垛,最近嗖Django的草堆/嗖 - 重建索引錯誤

這是我第一次鑽研Django的草垛。我一直在關注Haystack的「入門指南」,一切似乎都很順利,直到我去建立索引。

所以,運行「manage.py rebuild_index」拍我這回:

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' 

不知道,甚至從哪裏開始的這個......有沒有人遇到此之前?

上的解決方案有什麼想法?

更新: 試過這個與python 2.6以及,得到了同樣的錯誤。有沒有一些我沒有做過的移動配置?

更新: 利用philippbosch下面的建議後,第一個錯誤沒有露面了,但現在我得到這樣的:

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' 

我,如果我使用的是不相容的版本疑惑嗖的....我抓住它是1.0.0b2最新... http://pypi.python.org/pypi/Whoosh/

更新: 原來這是一個版本的問題。目前,草堆被綁定到嗖0.3.18

回答

6

剛纔我有同樣的問題。您是否嘗試使用»update_index«而不是»rebuild_index«?這似乎爲我工作...

+0

嗯,這讓我的地方......不幸的是它剛搬到我到一個新的錯誤... TypeError:__init __()有一個意外的關鍵字參數'postlimit' – Brant 2010-08-06 14:35:09

+0

請提供完整的回溯。 – philippbosch 2010-08-06 14:37:18

+0

更新了最初的帖子 – Brant 2010-08-06 14:46:40

0

如果您發現了這個問題,同時試圖從索引中刪除條目,您可能需要使用一個IndexWriter刪除該條目,而不是一個FileIndex對象;例如:

相反的:

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

會拋出上述的錯誤,你可以通過運行刪除文件:

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