djano-haystack rebuild_index命令失败

时间:2016-03-31 16:43:53

标签: python django elasticsearch django-haystack

我尝试通过django-haystack为我的项目安装Elasticsearch。我使用此tutorial,但是当我运行命令时

  

./ manage.py rebuild_index

我收到此错误:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/app/venv/local/lib/python2.7/site-packages/haystack/management/commands/rebuild_index.py", line 26, in handle
    call_command('update_index', **options)
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 119, in call_command
    return command.execute(*args, **defaults)
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/app/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 195, in handle
    return super(Command, self).handle(*items, **options)
  File "/app/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 548, in handle
    label_output = self.handle_label(label, **options)
  File "/app/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 200, in handle_label
    self.update_backend(label, using)
  File "/app/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 243, in update_backend
    commit=self.commit, max_retries=self.max_retries)
  File "/app/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 107, in do_update
    LOG.error(error_msg, exc_info=True, **error_context)
  File "/usr/lib/python2.7/logging/__init__.py", line 1174, in error
    self._log(ERROR, msg, args, **kwargs)
TypeError: _log() got an unexpected keyword argument 'retries'

models.py

class Company(models.Model):
    name = models.CharField(max_length=50)
    short_description = models.CharField(max_length=255)
    description = models.TextField()
    email = models.EmailField(unique=True)
    full_address = models.TextField(null=True)
    user = models.OneToOneField(User, null=True, related_name='company', on_delete=models.CASCADE)

search_indexes.py

class CompanyIndex(indexes.SearchIndex, indexes.Indexable):

    text = indexes.CharField(document=True, use_template=True)
    name = indexes.CharField(model_attr='name')
    short_description = indexes.CharField(model_attr='short_description')
    description = indexes.CharField(model_attr='description')
    email = indexes.CharField(model_attr='email')
    full_address = indexes.CharField(model_attr='full_address')

    def get_model(self):
        return Company

环境:

  • 的Django == 1.9.2
  • Django的干草堆== 2.5.dev0
  • elasticsearch == 2.3.0
  • elasticsearch-DSL == 2.0.0
  • 测井== 0.4.9.6
  • pyelasticsearch == 1.4
  • urllib3 == 1.14

1 个答案:

答案 0 :(得分:0)

我认为,这是haystack==2.5.dev0的具体错误。 原因是您没有创建(或名称错误)模板search/indexes/myapp/modelname_text.txt