elasticsearch安装及简介请参考:
https://blog.csdn.net/qq_16688265/article/details/83957179
问题
(pro_res) pyvip@VIP:~/project_res/pro_res$ python manage.py rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
...................(省略)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 95, in perform_request
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/util/retry.py", line 344, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/connectionpool.py", line 355, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/connection.py", line 183, in connect
conn = self._new_conn()
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fae4d8fe898>: Failed to establish a new connection: [Errno 111] Connection refused
^[[A^[[A^H^H^H^H^H^H^H^H^H^H^H^H^H^C[ERROR/MainProcess] Error updating allres using default
Traceback (most recent call last):
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 97, in do_update
backend.update(index, current_qs, commit=commit)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/backends/elasticsearch_backend.py", line 168, in update
prepped_data = index.full_prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 208, in full_prepare
self.prepared_data = self.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 199, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 206, in prepare
return self.convert(super(CharField, self).prepare(obj))
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 83, in prepare
return self.prepare_template(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 183, in prepare_template
t = loader.select_template(template_names)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: search/indexes/allres/resdetail_text.txt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 230, in handle
self.update_backend(label, using)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 276, in update_backend
last_max_pk=max_pk)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 128, in do_update
time.sleep(2 ** retries)
KeyboardInterrupt
Traceback (most recent call last):
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 97, in do_update
backend.update(index, current_qs, commit=commit)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/backends/elasticsearch_backend.py", line 168, in update
prepped_data = index.full_prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 208, in full_prepare
self.prepared_data = self.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 199, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 206, in prepare
return self.convert(super(CharField, self).prepare(obj))
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 83, in prepare
return self.prepare_template(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 183, in prepare_template
t = loader.select_template(template_names)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: search/indexes/allres/resdetail_text.txt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/rebuild_index.py", line 42, in handle
call_command('update_index', **update_options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command
return command.execute(*args, **defaults)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 230, in handle
self.update_backend(label, using)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 276, in update_backend
last_max_pk=max_pk)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 128, in do_update
time.sleep(2 ** retries)
KeyboardInterrupt
错误原因
连接失败
解决方法
1、docker start elasticsearch (开启elasticsearch)
2、查看settings.py 的ip地址是否正确,然后输入命令 curl -X GET http://10.0.2.15:9200/_cat/indices 查看是否连接
问题
(pro_res) pyvip@VIP:~/project_res/pro_res$ python manage.py rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
Indexing 1645 资源详情页
GET /pro_res/_mapping [status:404 request:0.008s]
[ERROR/MainProcess] Failed indexing 1 - 1000 (retry 5/5): search/indexes/allres/resdetail_text.txt (pid 5379): search/indexes/allres/resdetail_text.txt
Traceback (most recent call last):
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 97, in do_update
backend.update(index, current_qs, commit=commit)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/backends/elasticsearch_backend.py", line 168, in update
prepped_data = index.full_prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 208, in full_prepare
self.prepared_data = self.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 199, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 206, in prepare
return self.convert(super(CharField, self).prepare(obj))
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 83, in prepare
return self.prepare_template(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 183, in prepare_template
t = loader.select_template(template_names)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: search/indexes/allres/resdetail_text.txt
[ERROR/MainProcess] Error updating allres using default
Traceback (most recent call last):
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 230, in handle
self.update_backend(label, using)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 276, in update_backend
last_max_pk=max_pk)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 97, in do_update
backend.update(index, current_qs, commit=commit)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/backends/elasticsearch_backend.py", line 168, in update
prepped_data = index.full_prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 208, in full_prepare
self.prepared_data = self.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 199, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 206, in prepare
return self.convert(super(CharField, self).prepare(obj))
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 83, in prepare
return self.prepare_template(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 183, in prepare_template
t = loader.select_template(template_names)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: search/indexes/allres/resdetail_text.txt
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/rebuild_index.py", line 42, in handle
call_command('update_index', **update_options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command
return command.execute(*args, **defaults)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 230, in handle
self.update_backend(label, using)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 276, in update_backend
last_max_pk=max_pk)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/management/commands/update_index.py", line 97, in do_update
backend.update(index, current_qs, commit=commit)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/backends/elasticsearch_backend.py", line 168, in update
prepped_data = index.full_prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 208, in full_prepare
self.prepared_data = self.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/indexes.py", line 199, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 206, in prepare
return self.convert(super(CharField, self).prepare(obj))
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 83, in prepare
return self.prepare_template(obj)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/haystack/fields.py", line 183, in prepare_template
t = loader.select_template(template_names)
File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: search/indexes/allres/resdetail_text.txt
错误原因
txt命名出错
解决方法
模型_text.txt