【问题标题】:Django-Haystack/Whoosh - Rebuild Index ErrorDjango-Haystack/Whoosh - 重建索引错误
【发布时间】:2011-03-26 08:15:08
【问题描述】:

Python 2.5、Django 1.2.1、最近的干草堆、最近的嗖嗖

这是我第一次深入研究 Django-Haystack。我按照 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 试过这个,得到了同样的错误。有没有我没有做过的 Whoosh 配置?

更新: 使用 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'

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

更新: 原来是版本问题。目前,Haystack 与 whoosh 0.3.18 相关联

【问题讨论】:

    标签: python django django-haystack whoosh


    【解决方案1】:

    我刚才也遇到了同样的问题。您是否尝试过 »update_index« 而不是 »rebuild_index«?这似乎对我有用……

    【讨论】:

    • 嗯,这让我到了某个地方......不幸的是,它只是让我遇到了一个新错误...... TypeError: __init__() got an unexpected keyword argument 'postlimit'
    • 请提供完整的回溯。
    • 有同样的错误。更新而不是重建对我有用。谢谢。
    • @MikeMeyer,当我触发命令manage.py rebuild_index 时,我得到了NotImplementedError: You must provide a 'model' method for the '&lt;searchcollege.search_indexes.CollegeIndex object at 0x7f2664c94db8&gt;' index 的异常,我不明白为什么它来了,你能告诉我我错过了什么吗?
    • @MegaBytes 哦,伙计,我不知道。我的评论已经快五年了。你用谷歌搜索过错误信息吗?我通过一个谷歌搜索找到了这个:github.com/django-haystack/django-haystack/blob/master/haystack/…
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      如果您在尝试从索引中删除条目时发现此问题,您可能需要使用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()
      

      【讨论】:

        猜你喜欢
        • 2018-07-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多