DjangoHaystack/Whoosh重建索引E

2024-04-26 15:03:58 发布

您现在位置:Python中文网/ 问答频道 /正文

python2.5,Django 1.2.1,最新的haystack,最近的whoosh

这是我第一次深入Django Haystack。我一直在遵循Haystack的“入门”指南,一切似乎进展顺利,直到我去建立索引。在

所以,跑步”管理.py“重建索引”回击我:

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'

不知道从哪里开始。。。以前有人碰到过这个吗?在

有什么解决办法吗?在

更新: 在Python2.6中也尝试过,得到了相同的错误。有没有什么我没有做过的配置?在

更新: 在使用了philippbosch的以下建议后,第一个错误不再出现,但现在我得到了:

^{pr2}$

我想知道我是否在使用一个不兼容的版本。。。。我抓到了最新的1.0.0b2。。。http://pypi.python.org/pypi/Whoosh/

更新: 原来是版本问题。目前,Haystack与whoosh 0.3.18挂钩


Tags: djangoinpycoreselfexecutepackagesline
3条回答

安装Whoosh 0.3.18解决了我这边的问题

如果您在试图从索引中删除某个条目时发现此问题,则可能需要使用IndexWriter来删除该条目,而不是使用FileIndex对象;例如:

而不是:

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

这会引发上面讨论的错误,您可以通过运行以下命令删除文件:

^{pr2}$

我刚才也有同样的问题。您是否尝试过»更新索引«而不是»重建索引«?这似乎对我有用

相关问题 更多 >