made a mapping that worked and some more stuff to the elastic search helper

This commit is contained in:
booboy 2019-02-01 23:49:35 -06:00
parent 2a39616379
commit ee93b17576
3 changed files with 22 additions and 27 deletions

View file

@ -14,29 +14,21 @@ class ElasticSearchHelper
response = RestClient::Request.execute(
method: :put,
url: "#{server_uri}/#{index}",
header: header
headers: header,
payload: self.mappings.to_json)
end
def mappings
{
"mappings": {
"mappings": {
"_doc": {
"properties": {
"type": { "type": 'keyword' },
"paste_metadata": { "type": 'nested' },
"properties": [{
"scrape_url": { "type": 'string' },
"full_url": { "type": 'string' },
"date": { "type": 'string' },
"size": { "type": 'string' },
"expire": { "type": 'string' },
"title": { "type": 'string' },
"syntax": { "type": 'string' },
"user": { "type": 'string' },
"hits": { "type": 'string' }
}],
"paste_text": { "type": 'string' }
"properties": {
"paste_metadata": {
"type": "nested"
},
"paste_text": {
"type": "text"
}
}
}
}
@ -63,7 +55,7 @@ class ElasticSearchHelper
def json_to_es_bulk(array_of_paste_json)
array_of_paste_json.each do |paste_json|
self.to_es(paste_json)
self.json_to_es(paste_json)
end
end

View file

@ -1,9 +0,0 @@
require 'elasticsearch'
client = Elasticsearch::Client.new url: 'http://192.168.1.9200', log: true
client.transport.reload_connections!
client.cluster.health
client.index index: 'paste', type: 'pastes'

12
lib/mappings.json Normal file
View file

@ -0,0 +1,12 @@
{
"mappings": {
"_doc": {
"properties": {
"paste_metadata": {
"type": "nested"
},
"paste_text": { "type": "text" }
}
}
}
}