Python django haystack运行时出错"/manage.py重建索引
我在运行时遇到以下类型错误:Python django haystack运行时出错"/manage.py重建索引,python,django,solr,django-haystack,Python,Django,Solr,Django Haystack,我在运行时遇到以下类型错误: 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/virt
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
ERROR:root:使用默认值更新日志时出错
回溯(最近一次呼叫最后一次):
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update\u index.py”,第221行,在句柄标签中
self.update\u后端(标签,使用)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update_index.py”,第267行,在update_backend中
do_更新(后端、索引、qs、开始、结束、总计、自身详细信息)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update\u index.py”,第89行,在do\u update中
backend.update(索引、当前目录)
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/backends/solr_backend.py”,第68行,在更新中
self.conn.add(docs,commit=commit,boost=index.get\u field\u weights())
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第779行,添加
返回self.\u更新(m,commit=commit,waitFlush=waitFlush,waitSearcher=waitSearcher)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第387行,在更新中
返回self.\u发送请求('post',路径,消息,{'Content-type':'text/xml;charset=utf-8'})
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第318行,在发送请求中
错误消息=self.\u提取错误(resp)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第397行,在“提取”错误中
原因,完整html=self.\u scrape\u响应(响应标题、响应内容)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第467行,在“scrape”响应中
full_html=full_html.replace('\n','')
TypeError:应为字节、字节数组或与缓冲区兼容的对象
回溯(最近一次呼叫最后一次):
文件“manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/__init___;.py”,第399行,从命令行执行
utility.execute()
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/_init__.py”,第392行,在execute中
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/base.py”,第242行,运行时从
self.execute(*args,**选项._dict__;
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/base.py”,第285行,在execute中
输出=self.handle(*args,**选项)
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/rebuild_index.py”,第16行,在handle中
调用命令('更新索引',**选项)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/_init___;.py”,第159行,在call_命令中
返回klass.execute(*args,**默认值)
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/base.py”,第285行,在execute中
输出=self.handle(*args,**选项)
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update_index.py”,第195行,在handle中
返回super(命令,self).handle(*项,**选项)
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/django/core/management/base.py”,第385行,在handle中
label\u output=self.handle\u标签(标签,**选项)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update\u index.py”,第221行,在句柄标签中
self.update\u后端(标签,使用)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update_index.py”,第267行,在update_backend中
do_更新(后端、索引、qs、开始、结束、总计、自身详细信息)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/management/commands/update\u index.py”,第89行,在do\u update中
backend.update(索引、当前目录)
文件“/Users/aron/Documents/virtualenvs/three/lib/python3.4/site packages/haystack/backends/solr_backend.py”,第68行,在更新中
self.conn.add(docs,commit=commit,boost=index.get\u field\u weights())
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第779行,添加
返回self.\u更新(m,commit=commit,waitFlush=waitFlush,waitSearcher=waitSearcher)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第387行,在更新中
返回self.\u发送请求('post',路径,消息,{'Content-type':'text/xml;charset=utf-8'})
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第318行,在发送请求中
错误消息=self.\u提取错误(resp)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第397行,在“提取”错误中
原因,完整html=self.\u scrape\u响应(响应标题、响应内容)
文件“/Users/aaron/Documents/virtualenvs/three/lib/python3.4/site packages/pysolr.py”,第467行,在“scrape”响应中
full_html=full_html.replace('\n','')
TypeError:应为字节、字节数组或与缓冲区兼容的对象
在我的案例中,django_id出现了问题。帮助我的是这个问题。我做了以下几件事:
- 将模式放在solr-x.y.z/example/solr/collection1/conf/schema.xml中
- 将版本字段(如下所述)添加到中的架构中
<field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>