fixed some things with hashing the paste method and sending data to es
This commit is contained in:
parent
107c1ff559
commit
ba20e8dc41
1 changed files with 11 additions and 19 deletions
|
@ -130,10 +130,10 @@ class Pastebinner
|
|||
##### PREPARING THE PASTES FOR SERIALIZATION FOR ES CONFORMING TO PER INDEX SEARCHING
|
||||
##### SEE - https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_custom_type_field
|
||||
|
||||
def puts_to_es(es_uri, payload)
|
||||
def http_to_es(es_uri, payload, method)
|
||||
header = { 'Content-type': 'application/json' }
|
||||
response = RestClient::Request.execute(
|
||||
method: :put,
|
||||
method: method,
|
||||
url: es_uri,
|
||||
headers: header,
|
||||
payload: payload)
|
||||
|
@ -145,31 +145,23 @@ class Pastebinner
|
|||
url: es_uri + index)
|
||||
end
|
||||
|
||||
def hash_pastes(keys, pb)
|
||||
def hash_pastes(keys)
|
||||
keys.map do |key|
|
||||
raw_paste = pb.raw_paste_data(key).body
|
||||
raw_paste_metadata = pb.raw_paste_metadata(key).body
|
||||
hash = pb.hash_paste(raw_paste, raw_paste_metadata)
|
||||
raw_paste = self.raw_paste_data(key).body
|
||||
raw_paste_metadata = self.raw_paste_metadata(key).body
|
||||
hash = self.hash_paste(raw_paste, raw_paste_metadata)
|
||||
end
|
||||
end
|
||||
|
||||
def hash_paste(raw_paste, raw_paste_metadata)
|
||||
def hash_paste(raw_paste_data, raw_paste_metadata)
|
||||
{ "paste_metadata": raw_paste_metadata,
|
||||
"paste_text": raw_paste }
|
||||
"paste_text": raw_paste_data }
|
||||
end
|
||||
|
||||
def post_to_es(es_uri, payload)
|
||||
header = { 'Content-type': 'application/json' }
|
||||
response = RestClient::Request.execute(
|
||||
method: :post,
|
||||
url: es_uri,
|
||||
headers: header,
|
||||
payload: payload)
|
||||
end
|
||||
|
||||
def send_es_bulk(esi_uri, json_data)
|
||||
json_data.each do |data|
|
||||
self.post_to_es(esi_uri, data)
|
||||
method = :post
|
||||
json_data.each do |payload|
|
||||
self.http_to_es(esi_uri, payload, method)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue