From 85e0cadf33ee6402e732888f9c50cff2f94b8dfd Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Thu, 30 Jan 2020 10:39:45 -0500 Subject: [PATCH] PUT mapping --- lib/philomena/elasticsearch.ex | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/philomena/elasticsearch.ex b/lib/philomena/elasticsearch.ex index 10e151ef..caedda7a 100644 --- a/lib/philomena/elasticsearch.ex +++ b/lib/philomena/elasticsearch.ex @@ -45,6 +45,19 @@ defmodule Philomena.Elasticsearch do Elastix.Index.delete(elastic_url(), index.index_name()) end + def update_mapping!(module) do + index = index_for(module) + + index_name = index.index_name() + doc_type = index.doc_type() + mapping = + index.mapping().mappings + |> Map.get(String.to_atom(doc_type)) + |> Map.get(:properties) + + Elastix.Mapping.put(elastic_url(), index_name, doc_type, %{properties: mapping}) + end + def index_document(doc, module) do index = index_for(module) data = index.as_json(doc)