Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.66 KB

elasticsearch.md

File metadata and controls

64 lines (47 loc) · 1.66 KB

Overview

Wagtail supports the use of Elasticsearch as a search backend, to speed up searches and remove the burden of searching from the relational database.

Setup

The outline of the setup process is as follows.

  1. Create an Elasticsearch cluster
  2. Configure Wagtail to use Elasticsearch
  3. Create the search index

Create Elasticsearch cluster

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.

Configure Wagtail to use Elasticsearch

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.

Create the search index

To create and subsequently update the ElasticSearch index.

docker compose run --rm django python manage.py update_index