From fe6cce2fc409d104fdc8d4513079fc248c0a638c Mon Sep 17 00:00:00 2001 From: booboy Date: Wed, 20 Mar 2019 00:13:37 -0500 Subject: [PATCH] added a create_mapping method that does not work and a create_mappings.json. i think its the json but ill keep messing with it. --- .../helpers/elastic_search_helper.rb | 9 ++ mappings/create_mappings.json | 114 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 mappings/create_mappings.json diff --git a/lib/pastebinner/helpers/elastic_search_helper.rb b/lib/pastebinner/helpers/elastic_search_helper.rb index b7e4f33..b41f3fb 100644 --- a/lib/pastebinner/helpers/elastic_search_helper.rb +++ b/lib/pastebinner/helpers/elastic_search_helper.rb @@ -22,6 +22,15 @@ module Pastebinner url: "#{server_uri}/#{index}/_mappings?pretty") end + def create_mapping(mapping_json) + header = { 'Content-type': 'application/json' } + response = RestClient::Request.execute( + method: :put, + url: "#{server_uri}/#{index}", + headers: header, + payload: mapping_json) + end + def update_mapping(mapping_json) header = { 'Content-type': 'application/json' } response = RestClient::Request.execute( diff --git a/mappings/create_mappings.json b/mappings/create_mappings.json new file mode 100644 index 0000000..06b0cdf --- /dev/null +++ b/mappings/create_mappings.json @@ -0,0 +1,114 @@ +{ + "settings": { + "number_of_shards": 1 + }, + "mappings": { + "paste": { + "properties": { + "paste_metadata": { + "properties": { + "date": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "expire": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "full_url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "hits": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "key": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "scrape_url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "size": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "syntax": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "title": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "user": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "paste_text": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + } + } + }