lib/rubberband_flamethrower/flamethrower.rb
# Batch inserts randomly generated JSON data objects into an Elastic Search server.
# Example of the object inserted:
#  {
#   "message":"utilizing plowed popularizing demeanor anesthesia specializes chaperon pedaling.",
#   "username":"pummeling",
#   "post_date":"20130408T15:41:28"
#  }
# 
# @param [Integer] how_many - how many randomly generated data objects to insert
# @param [Integer] starting_id - starting id for randomly generated data objects, will increment from this number
# @param [String] server_url - url of the Elastic Search server
# @param [String] index - name of the Elastic Search index to insert data into
# @param [String] type - name of the Elastic Search type to insert data into
# @param [Integer] printing_level - 0 = no printing | 1 = progress dots | 2 = debug level
Batch inserts randomly generated JSON data objects into an Elastic Search server.
Batch inserts randomly generated JSON data objects into an Elastic Search server .
def load_dataset(filename, starting_id, server_url, index, type, printing_level=0)
      ($stdout.sync = true) if printing_level == 1
      id = starting_id.to_i
      IO.foreach(filename) do |line|
        unless line.empty?
          (puts insert_data) if printing_level == 2
          response = HTTParty.put("#{server_url}/#{index}/#{type}/#{id}", body: line) 
          (puts response.body) if printing_level == 2
          (print ".") if printing_level == 1
          id = id + 1
        end
      end
    end
def load_dataset ( filename , starting_id , server_url , index , type , printing_level = 0 ) ( $stdout . sync = true ) if printing_level == 1 id = starting_id . to_i IO . foreach ( filename ) do | line | unless line . empty? ( puts insert_data ) if printing_level == 2 response = HTTParty . put ( "#{server_url}/#{index}/#{type}/#{id}" , body : line ) ( puts response . body ) if printing_level == 2 ( print "." ) if printing_level == 1 id = id + 1 end end end
Batch inserts randomly generated JSON data objects into an Elastic Search server.
Batch inserts randomly generated JSON data objects into an Elastic Search server .
# this will constantly flush the printing to the display so the progress dots appear for each insert # a unique ID must be provided for each document stored in Elastic Search # loop through lines in the file and insert each line, each line is a document from the data generator
filename
<not_specific>
starting_id
<not_specific>
server_url
<not_specific>
index
<not_specific>
type
<not_specific>
printing_level
<not_specific>
<not_specific>
0 = no printing | 1 = progress dots | 2 = debug level
0 = no printing | 1 = progress dots | 2 = debug level