首页 > 解决方案 > django-elasticsearch-dsl 与 AWS elasticsearch

问题描述

我正在尝试使用 AWS ElasticBeanStalk 来部署一个 Django 应用程序django-elasticsearch-dsl,我需要./manage.py search_index --rebuild在第一次加载它时运行它。所以在我的容器命令中,我得到了:

03_elasticsearch:
  command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild"

问题是它正在等待问题的/ YAre you sure you want to delete the 'hjsm-local' indexes? [n/Y]:

我如何重建我的不道德?

更新

当我使用

03_elasticsearch:   
    command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild -f"

我收到这个错误

Traceback (most recent call last):
  File "./src/manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
  File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
  utility.execute()
  File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
  self.execute(*args, **cmd_options)
  File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 353, in execute
  output = self.handle(*args, **options)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 134, in handle
  self._rebuild(models, options)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 114, in _rebuild
  self._create(models, options)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 84, in _create
  index.create()
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch_dsl/index.py", line 102, in create
  self.connection.indices.create(index=self._name, body=self.to_dict(), **kwargs)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
  return func(*args, params=params, **kwargs)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/indices.py", line 110, in create
  params=params, body=body)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 327, in perform_request
  status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 110, in perform_request
  self._raise_error(response.status, raw_data)
  File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 114, in _raise_error
  raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
  elasticsearch.exceptions.TransportError: <exception str() failed>
   (ElasticBeanstalk::ExternalInvocationError)

标签: djangoelasticsearch

解决方案


根据源代码,在命令中包含-f参数以强制接受提示。


推荐阅读