elasticsearch常见问题

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
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值