added method to es helper to delete index and get mappings

This commit is contained in:
booboy 2019-02-02 03:41:39 -06:00
parent 6f715c3f86
commit bf64a2f60e

View file

@ -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": {