Wagtail supports the use of Elasticsearch as a search backend, to speed up searches and remove the burden of searching from the relational database.
The outline of the setup process is as follows.
- Create an Elasticsearch cluster
- Configure Wagtail to use Elasticsearch
- Create the search index
Create the file docker-compose.override.yml
. Add the following to the file.
version: '3'
services:
search:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.1
environment:
- discovery.type=single-node
volumes:
- search:/usr/share/elasticsearch/data
ports:
- "9200:9200"
volumes:
search:
If you already have a docker-compose.override.yml
, you will need to merge the snippet above into it, in which case, you will probably not need the first two lines.
Create the file iogt/settings/local.py
. Add the following to the file.
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.search.backends.elasticsearch7',
'URLS': ['http://search:9200'],
'INDEX': 'iogt',
'TIMEOUT': 5,
'OPTIONS': {},
'INDEX_SETTINGS': {},
'AUTO_UPDATE': True,
'ATOMIC_REBUILD': True
}
}
More information about the available configuration options can be found in the search backends section of the Wagtail documentation.
To create and subsequently update the ElasticSearch index.
docker compose run --rm django python manage.py update_index