0

I'm trying to use AWS ElasticBeanStalk to deploy a Django app using django-elasticsearch-dsl and I need to run ./manage.py search_index --rebuild the first time I load it. So within my container commands I've got:

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

The problem is it is waiting for a n/Y to the question Are you sure you want to delete the 'hjsm-local' indexes? [n/Y]:

How do I rebuild my indecies?

UPDATE

When I use

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

I get this error

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)

1 Answer 1

1

As per the source code, include the -f parameter in your command to force the acceptance of the prompt.

Sign up to request clarification or add additional context in comments.

6 Comments

I've tried that but I get the attached error when I do that
@HenryM are you able to delete and then rebuild the indices? If so, that would indicate there's an error in the way the app rebuilds indices.
I don't know elasticsearch and I'm just trying to set it up. When I run locally using a local elasticsearch it works so I think the issue is with how I'm connecting to AWS elasticsearch or how I've set up the aws elasticsearch
@HenryM I mean what happens if you add another command before the one that's failing where you run manage.py search_index --delete -f before you do the rebuild one.
I don't run --delete because it does that as part of rebuild. other commands work fine (for example manage.py migrate). It is crashing when trying to create the index
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.