From bf64a2f60e04cd6f59c3b908b9e31e9fb7bc9002 Mon Sep 17 00:00:00 2001 From: booboy Date: Sat, 2 Feb 2019 03:41:39 -0600 Subject: [PATCH] added method to es helper to delete index and get mappings --- lib/elastic_search_helper.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/elastic_search_helper.rb b/lib/elastic_search_helper.rb index 58f470c..d61412a 100644 --- a/lib/elastic_search_helper.rb +++ b/lib/elastic_search_helper.rb @@ -9,7 +9,7 @@ class ElasticSearchHelper @pastebinner = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) end - def create_index + def create_index_with_mappings header = { 'Content-type': 'application/json' } response = RestClient::Request.execute( method: :put, @@ -18,6 +18,19 @@ class ElasticSearchHelper payload: self.mappings.to_json) end + def delete_index + response = RestClient::Request.execute( + method: :delete, + url: "#{server_uri}/#{index}") + end + + def get_mappings + response = RestClient::Request.execute( + method: :get, + url: "#{server_uri}/#{index}/_mappings") + end + + def mappings { "mappings": {