From fc836256bacf40e32661ae04805ea7d388a7c868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Thu, 15 Aug 2019 16:19:26 +0200 Subject: [PATCH] clean up ES config --- CHANGELOG.md | 2 ++ backend/config/config.exs | 11 +---------- backend/lib/backend/elasticsearch/cluster.ex | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 492acd5..a6d826d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Cleaned up ElasticSearch configuration in backend. + ## [2.6.1 - 2019-08-10] ### Fixed diff --git a/backend/config/config.exs b/backend/config/config.exs index b2cff12..d7e00ea 100644 --- a/backend/config/config.exs +++ b/backend/config/config.exs @@ -28,16 +28,7 @@ instances_config_path = config :backend, Backend.Elasticsearch.Cluster, url: "http://localhost:9200", api: Elasticsearch.API.HTTP, - json_library: Jason, - indexes: %{ - instances: %{ - settings: instances_config_path, - store: Backend.Elasticsearch.Store, - sources: [Backend.Instance], - bulk_page_size: 1000, - bulk_wait_interval: 1_000 - } - } + json_library: Jason # Configures Elixir's Logger config :logger, :console, diff --git a/backend/lib/backend/elasticsearch/cluster.ex b/backend/lib/backend/elasticsearch/cluster.ex index 3f130c9..fd436d9 100644 --- a/backend/lib/backend/elasticsearch/cluster.ex +++ b/backend/lib/backend/elasticsearch/cluster.ex @@ -1,3 +1,21 @@ defmodule Backend.Elasticsearch.Cluster do use Elasticsearch.Cluster, otp_app: :backend + + def init(config) do + indexes = %{ + instances: %{ + settings: Application.app_dir(:backend, "priv/elasticsearch/instances.json"), + store: Backend.Elasticsearch.Store, + sources: [Backend.Instance], + bulk_page_size: 1000, + bulk_wait_interval: 1000 + } + } + + config = + config + |> Map.put(:indexes, indexes) + + {:ok, config} + end end