运行“./manage.py rebuild_index”时出现django-haystack错误

时间:2014-05-24 21:37:01

标签: python django solr django-haystack

运行时遇到以下TypeError:

python manage.py rebuild_index

我目前的设置是Solr 4.8.1,django-haystack 2.1.0,Django 1.6.2和Python 3.4.0。

有谁知道造成这种情况的原因是什么?这是错误线程:

ERROR:root:Error updating blog using default 
Traceback (most recent call last):
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 221, in handle_label
    self.update_backend(label, using)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 267, in update_backend
    do_update(backend, index, qs, start, end, total, self.verbosity)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 89, in do_update
    backend.update(index, current_qs)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/backends/solr_backend.py", line 68, in update
    self.conn.add(docs, commit=commit, boost=index.get_field_weights())
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 779, in add
    return self._update(m, commit=commit, waitFlush=waitFlush, waitSearcher=waitSearcher)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 387, in _update
    return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 318, in _send_request
    error_message = self._extract_error(resp)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 397, in _extract_error
    reason, full_html = self._scrape_response(resp.headers, resp.content)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 467, in _scrape_response
    full_html = full_html.replace('\n', '')
TypeError: expected bytes, bytearray or buffer compatible object
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/rebuild_index.py", line 16, in handle
    call_command('update_index', **options)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 195, in handle
    return super(Command, self).handle(*items, **options)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/django/core/management/base.py", line 385, in handle
    label_output = self.handle_label(label, **options)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 221, in handle_label
    self.update_backend(label, using)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 267, in update_backend
    do_update(backend, index, qs, start, end, total, self.verbosity)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 89, in do_update
    backend.update(index, current_qs)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/haystack/backends/solr_backend.py", line 68, in update
    self.conn.add(docs, commit=commit, boost=index.get_field_weights())
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 779, in add
    return self._update(m, commit=commit, waitFlush=waitFlush, waitSearcher=waitSearcher)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 387, in _update
    return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 318, in _send_request
    error_message = self._extract_error(resp)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 397, in _extract_error
    reason, full_html = self._scrape_response(resp.headers, resp.content)
  File "/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site-packages/pysolr.py", line 467, in _scrape_response
    full_html = full_html.replace('\n', '')
TypeError: expected bytes, bytearray or buffer compatible object

1 个答案:

答案 0 :(得分:0)

就我而言,django_id存在问题。帮助我的是this问题。我做了以下事情:

  • 将架构放在solr-x.y.z / example / solr / collection1 / conf / schema.xml

  • 将版本字段(如下所述)添加到字段部分中的架构中:

<field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>