Skip to content

Latest commit

 

History

History
74 lines (56 loc) · 1.78 KB

es_local.md

File metadata and controls

74 lines (56 loc) · 1.78 KB

Run Elasticsearch local on Docker

Prerequisites

Install ES on Docker

  1. Create a new docker-compose.yml using the following lines

    version: '2'
    services:
      elasticsearch:
        image: elasticsearch:7.14.1
        container_name: eeag_elasticsearch
        environment:
          - discovery.type=single-node
          - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
        volumes:
          - elasticsearch_data:/usr/share/elasticsearch/data
        ports:
          - 9200:9200
        networks:
          - elastic
        restart: "always"
    
    volumes:
      elasticsearch_data:
    
    networks:
      elastic:
  2. Install and start ES service:

docker-compuse up -d
  1. Check if you get a response when hit localhost:9200:, if you get a response, that means ES is running.

  2. Install the requirements or check if you have the latest version of django-haystack

pip install -r requirements.dev.txt

OR

pip install django-haystack -U
  1. Replace HAYSTACK_CONNECTIONS settings in localsettings.py:
HAYSTACK_CONNECTIONS = {
"default": {
    "ENGINE": "haystack.backends.elasticsearch7_backend.Elasticsearch7SearchEngine",
    "URL": "http://localhost:9200/",
    "INDEX_NAME": "eeagrants",
    "BATCH_SIZE": 999,
    "SILENTLY_FAIL": False,
    },
}
  1. Rebuild index using the following command
./manage.py rebuild_index