代码之家  ›  专栏  ›  技术社区  ›  Brant

Django Haystack/Whoosh-重建索引错误

  •  3
  • Brant  · 技术社区  · 14 年前

    Python2.5、Django 1.2.1、最近的haystack、最近的whoosh

    这是我第一次深入研究Django Haystack。我在遵循《大海捞针》的“入门”指南,一切似乎都进展顺利,直到我去建立索引。

    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的建议后,第一个错误不再出现,但现在我得到了以下信息:

    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/

    更新 原来是版本问题。目前,Haystack被绑定到whoosh 0.3.18

    3 回复  |  直到 14 年前
        1
  •  6
  •   philippbosch    14 年前

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

        2
  •  1
  •   Nicu Surdu Robert Laverty    14 年前

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

        3
  •  0
  •   duhaime    10 年前

    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()