ElasticSearch doesn't work with synonym server

Thank you for your reply! I’ve done some tests and the solution that worked was indeed to change dns IP in docker compose file to 192.168.65.7 in both dnsresolver and elasticsearch configurations. Now everything is working!

I’m attaching the updated file for future reference:

# Docker compose below sets up the containers needed to run Litium locally
# Same as https://docs.litium.com/documentation/get-started/shared-dependencies
# With additional containers for SQL Server and Mailhog

version: '3'
services:
  dnsresolver:
    # https://github.com/cytopia/docker-bind
    image: cytopia/bind:stable-0.28
    container_name: dnsresolver
    ports:
    - "53:53/tcp"
    - "53:53/udp"
    environment: 
    - DNS_CNAME=*.localtest.me=host.docker.internal
    - DNS_FORWARDER=192.168.65.7
    dns: 192.168.65.7
    restart: unless-stopped
     ## After update of docker desktop changing from 192.168.65.5 to 192.168.65.7 may be needed.

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch
    depends_on:
    - dnsresolver
    dns: 
    - 192.168.65.7
    restart: unless-stopped
    ports:
    - "9200:9200"
    environment:
    - discovery.type=single-node
    # Allocate 2GB RAM instead of the default 512MB
    # comment out the line below for additional memory allocation
    # - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
    volumes:
    - ./volumes/elasticsearch/data:/usr/share/elasticsearch/data
    entrypoint: 
    - /bin/sh
    - -c
    # The accelerator implementation of Elasticsearch require the analysis-dynamic-synonym.
    # The plugin refreshes the list of synonyms in Elasticsearch every minute allowing synonyms 
    # to be added/modified in Litium backoffice and updated in Elasticsearch without downtime.
    - "./bin/elasticsearch-plugin list | grep -q analysis-dynamic-synonym || ./bin/elasticsearch-plugin install -b https://github.com/Tasteful/elasticsearch-analysis-dynamic-synonym/releases/download/v7.6.2/elasticsearch-analysis-dynamic-synonym.zip; /usr/local/bin/docker-entrypoint.sh"
  
  kibana:
    # The Kibana image tries, by default, to connect to a host/container called elasticsearch.
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana
    depends_on:
    - elasticsearch
    restart: unless-stopped
    ports:
    - "5601:5601"

  synonymserver:
    # Synonym server to provide elasticsearch with synonyms without needing that the customer application is running.
    image: registry.litium.cloud/apps/synonym-server:1.2.0
    container_name: synonymserver
    restart: unless-stopped
    ports:
    - "9210:80"
    environment:
    - DataFolder=/app_data
    volumes:
    - ./volumes/synonymserver/data:/app_data

  redis:
    image: redis:5.0.5-alpine
    container_name: redis
    restart: unless-stopped
    ports:
    - "6379:6379"

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-latest
    environment:
      - SA_PASSWORD=Pass@word
      - ACCEPT_EULA=Y
    restart: unless-stopped
    ports:
      # Make the SQL Container available on port 5434 to not conflict with a previously installed local SQL instance.
      # If you do not have SQL Server installed you can use 1433:1433 as mapping and skip port number in connectionstrings.
      - "5434:1433"
    volumes:
      # Map [local directory:container directory] - this is so that db/log files are
      # stored on the "host" (your local computer, outside of container) and thereby 
      # persisted when container restarts.
      # by starting local path with "." it gets relative to current folder, meaning that the database
      # files will be on your computer in the same directory as you have this docker-compose.yaml file
      - ./data/mssql/data:/var/opt/mssql/data
      - ./data/mssql/log:/var/opt/mssql/log
    entrypoint: 
      # Due to an issue with the sqlserver image, permissions to db-files may be lost on container restart
      # by using the specific permissions_check entrypoint you assert that permissions are set on every restart
      - /bin/sh
      - -c
      - "/opt/mssql/bin/permissions_check.sh && /opt/mssql/bin/sqlservr"

  mailhog:
    image: mailhog/mailhog:latest
    restart: unless-stopped
    logging:
      driver: 'none'
    ports:
      - 1025:1025 # SMTP-server
      - 8025:8025 # Web UI

I’ve also had the issue with type mismatch but I’ve changed the Get method instead:

public IList<string> GetProductFilteringFields()
        {
            return _settingsService.Get<ICollection<string>>(_key).ToList() ?? new List<string>();
        }

I don’t know which is better. :grin:

2 Likes