class Estool::Actions::Index

Public Class Methods

new(command, options) click to toggle source
# File lib/estool/actions/index.rb, line 8
def initialize(command, options)
  @cmd = command
  @data = options.except(:host, :port)
  @server = options.slice(:host, :port)
end

Public Instance Methods

format_options(data) click to toggle source
# File lib/estool/actions/index.rb, line 14
def format_options(data)
  params = {}
  data.each do |k, v|
    case k
    when :update
      params.merge!(update_all_types: v)
    when :wait
      params.merge!(wait_for_active_shards: v)
    else
      params.merge!("#{k}": v)
    end
  end
  return params
end
index(action, options, server) click to toggle source
# File lib/estool/actions/index.rb, line 29
def index(action, options, server)
  client = Estool::Connections.start_conn(server[:host], server[:port])
  Estool::Connections.test_conn(client)
  begin
    puts client.indices.send(action, options)
  rescue ArgumentError => args
      puts "
           #{args}
      Usage: 'estool index help #{action}' for more information
      "
      exit 1
  end
end
run() click to toggle source
# File lib/estool/actions/index.rb, line 43
def run
  params = format_options(@data)
  index(@cmd, params, @server)
end