Divio's default version of Elasticsearch is version 2.3. Other versions can be made available on request.

How to enable Elasticsearch

In your project's Subscription, add as many Elastic search instances as you think you will need. One you have applied the new subscription, we will provision it on your cloud project.

We will apply a DEFAULT_HAYSTACK_URL variable to your environments; this takes the form:

DEFAULT_HAYSTACK_URL=es+http://hostname:9200/my-index-name

Support for AWS Elasticsearch-style connections is also available:

DEFAULT_HAYSTACK_URL=es+https+aws://AWS_ACCESS_KEY:AWS_SECRET_KEY@cluster-name.us-east-1.amazonaws.com/my-index-name

Other options are also available, so if you have special requirements please contact our support.

Usage for Python projects using Django Haystack

Scheduled indexing

Set up a cron job, for example in a Python project using Django Haystack:

python manage.py rebuild_index --noinput

Debugging

Set the ALDRYN_HAYSTACK_DEBUG environment variable to True  to get detailed logs from Haystack.

Local environment set-up

For local development add an ElasticSearch service to docker-compose.yml:

es:
    image: elasticsearch:2.3

and add a link to it from the web service:

web:
    links:
      - "es:es"

Then add the environment variable to configure the connection (on the default aldryn setup: add to .env-local):

DEFAULT_HAYSTACK_URL=es+http://es:9200/local-*

Test the connection:

docker-compose run --rm web python manage.py shell
>>> from haystack.query import SearchQuerySet
>>> list(SearchQuerySet())
[]

There won't be any results yet, since nothing has so far been indexed. However you will get an error if the connection does not work.

For further information

To learn more about how to setup your project, please see the Aldryn Haystack GitHub Repository.

Did this answer your question?