class Ej::Commands

Public Class Methods

new(args = [], options = {}, config = {}) click to toggle source
Calls superclass method
# File lib/ej/commands.rb, line 23
def initialize(args = [], options = {}, config = {})
  super(args, options, config)
  @global_options = config[:shell].base.options
  values = Values.new(@global_options)
  @core = Ej::Core.new(values)
  @indices = Ej::Indices.new(values)
  @cluster = Ej::Cluster.new(values)
  @nodes = Ej::Nodes.new(values)
end

Public Instance Methods

aggs() click to toggle source
# File lib/ej/commands.rb, line 105
def aggs
  puts_with_format(@core.aggs(options[:terms], options[:size], options[:query]))
end
aliases() click to toggle source
# File lib/ej/commands.rb, line 149
def aliases
  puts_with_format(@indices.aliases)
end
bulk() click to toggle source
# File lib/ej/commands.rb, line 128
def bulk
  inputs = options[:inputs].empty? ? [STDIN] : options[:inputs]
  inputs.each do |key|
    buffer = (key.class == STDIN.class) ? STDIN.read : File.read(key)
    @core.bulk(
      options[:timestamp_key],
      options[:type],
      options[:add_timestamp],
      options[:id_keys],
      options[:index],
      Util.parse_json(buffer)
    )
  end
end
copy() click to toggle source
# File lib/ej/commands.rb, line 75
def copy
  @core.copy(
    options[:source],
    options[:dest],
    options[:query],
    options[:per],
    options[:scroll],
    options[:dest_index],
    options[:slice_max]
  )
end
count(query = options[:query]) click to toggle source
# File lib/ej/commands.rb, line 56
def count(query = options[:query])
  puts_with_format(@core.search(options[:type], query, 0, 0, false))
end
create_aliases() click to toggle source
# File lib/ej/commands.rb, line 198
def create_aliases
  @indices.create_aliases(options[:alias], options[:indices])
end
delete() click to toggle source
# File lib/ej/commands.rb, line 211
def delete
  query = options[:query] ? eval(options[:query]) : nil
  @indices.delete(options[:index], options[:type], query)
end
delete_template() click to toggle source
# File lib/ej/commands.rb, line 218
def delete_template
  @indices.delete_template(options[:name])
end
distinct(term) click to toggle source
# File lib/ej/commands.rb, line 63
def distinct(term)
  puts_with_format(@core.distinct(term, options[:type], options[:query]))
end
dump() click to toggle source
# File lib/ej/commands.rb, line 90
def dump
  @core.dump(options[:query], options[:per])
end
facet(term) click to toggle source
# File lib/ej/commands.rb, line 97
def facet(term)
  puts_with_format(@core.facet(term, options[:size], options[:query]))
end
health() click to toggle source
# File lib/ej/commands.rb, line 144
def health
  puts_with_format(@cluster.health)
end
indices() click to toggle source
# File lib/ej/commands.rb, line 159
def indices
  puts_with_format(@indices.indices)
end
mapping() click to toggle source
# File lib/ej/commands.rb, line 169
def mapping
  puts_with_format(@indices.mapping)
end
max() click to toggle source
# File lib/ej/commands.rb, line 117
def max
  puts_with_format(@core.max(options[:term]))
end
min() click to toggle source
# File lib/ej/commands.rb, line 111
def min
  puts_with_format(@core.min(options[:term]))
end
nodes_info() click to toggle source
# File lib/ej/commands.rb, line 243
def nodes_info
  puts_with_format @nodes.nodes_info
end
nodes_stats() click to toggle source
# File lib/ej/commands.rb, line 248
def nodes_stats
  puts_with_format @nodes.nodes_stats
end
not_analyzed() click to toggle source
# File lib/ej/commands.rb, line 174
def not_analyzed
  json = File.read(File.expand_path('../../../template/not_analyze_template.json', __FILE__))
  hash = JSON.parse(json)
  puts_with_format(@indices.put_template('ej_init', hash))
end
put_routing() click to toggle source
# File lib/ej/commands.rb, line 184
def put_routing
  body = { options[:type] => {"_routing"=>{"required"=>true, "path"=>options[:path]}}}
  puts_with_format(@indices.put_mapping(options[:index], options[:type], body))
end
put_template(name) click to toggle source
# File lib/ej/commands.rb, line 190
def put_template(name)
  hash = JSON.parse(STDIN.read)
  puts_with_format(@indices.put_template(name, hash))
end
recovery() click to toggle source
# File lib/ej/commands.rb, line 203
def recovery
  @indices.recovery
end
refresh() click to toggle source
# File lib/ej/commands.rb, line 238
def refresh
  puts_with_format(@indices.refresh)
end
settings() click to toggle source
# File lib/ej/commands.rb, line 228
def settings
  puts_with_format(@indices.settings)
end
state() click to toggle source
# File lib/ej/commands.rb, line 154
def state
  puts_with_format(@cluster.state)
end
stats() click to toggle source
# File lib/ej/commands.rb, line 164
def stats
  puts_with_format(@indices.stats)
end
template() click to toggle source
# File lib/ej/commands.rb, line 223
def template
  puts_with_format(@indices.template)
end
version() click to toggle source
# File lib/ej/commands.rb, line 253
def version
  puts VERSION
end
warmer() click to toggle source
# File lib/ej/commands.rb, line 233
def warmer
  puts_with_format(@indices.warmer)
end

Private Instance Methods

puts_with_format(object) click to toggle source
# File lib/ej/commands.rb, line 259
def puts_with_format(object)
  puts JSON.pretty_generate(object)
end