0

I'm writing a site on Flask, I decided to make a search system on the site using Elasticsearch, I did it according to the guide https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-full-text-search .

Here is my code:

es = Elasticsearch(os.environ.get('ELASTICSEARCH_URL'))
app.elasticsearch = Elasticsearch([app.config['ELASTICSEARCH_URL']]) if app.config['ELASTICSEARCH_URL'] else None

But I get an error:

app.elasticsearch = Elasticsearch([app.config['ELASTICSEARCH_URL']]) if app.config['ELASTICSEARCH_URL'] else None
KeyError: 'ELASTICSEARCH_URL'

Please help to fix this.

1 Answer 1

1

I think you have simply not degined the elasticsearch key inside your app config. According to the documentation you should first make

app.config['ELASTICSEARCH_URL'] = os.environ.get('ELASTICSEARCH_URL')

In the end the app config behaves as a dictionary, and you are trying to access a key that does not exist

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

Comments

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.