lib/ej/commands.rb in ej-0.0.8 vs lib/ej/commands.rb in ej-0.0.9
- old
+ new
@@ -14,11 +14,11 @@
class_option :host, aliases: '-h', type: :string, default: 'localhost', desc: 'host'
class_option :debug, aliases: '-d', type: :string, default: false, desc: 'debug mode'
map '-s' => :search
map '-f' => :facet
map '-c' => :count
- map '-I' => :bulk
+ map '-b' => :bulk
map '-l' => :indices
map '-a' => :aliases
map '-m' => :mapping
map '-e' => :debug_eval
map '--j2h' => :json_to_hash
@@ -32,37 +32,47 @@
desc '-s [lucene query]', 'search'
option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
option :size, type: :numeric, aliases: '-n', default: nil, desc: 'size'
option :from, type: :numeric, aliases: '--from', default: 0, desc: 'from'
+ option :fields, type: :array, aliases: '--fields', default: nil, desc: 'fields'
option :source_only, type: :boolean, aliases: '--so', default: true, desc: 'from'
- def search(query = nil)
- puts_json(@core.search(options['type'], query, options['size'], options['from'], options['source_only']))
+ option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
+ def search(query = options['query'])
+ puts_json(@core.search(options['type'],
+ query,
+ options['size'],
+ options['from'],
+ options['source_only'],
+ query,
+ options['fields']
+ ))
end
desc 'total [lucene query]', 'total'
option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
- def count(query = nil)
+ option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
+ def count(query = options['query'])
puts_json(@core.search(options['type'], query, 0, 0, false))
end
desc 'distinct [lucene query]', 'distinct'
option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
def distinct(term)
puts_json(@core.distinct(term, options['type'], options['query']))
end
- desc 'move', 'move index'
+ desc 'copy', 'copy index'
option :source, type: :string, aliases: '--source', required: true, desc: 'source host'
option :dest, type: :string, aliases: '--dest', required: true, desc: 'dest host'
option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
- def move
- @core.move(options['source'], options['dest'], options['query'])
+ def copy
+ @core.copy(options['source'], options['dest'], options['query'])
end
- desc 'dump', 'move index'
+ desc 'dump', 'dump index'
option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
def dump
@core.dump(options['query'])
end
@@ -90,11 +100,11 @@
option :term, type: :string, aliases: '-k', desc: 'terms'
def max
puts_json(@core.max(options['term']))
end
- desc '-I', 'bulk import STDIN JSON'
+ desc '-b', 'bulk import STDIN JSON'
option :index, aliases: '-i', type: :string, default: "logstash-#{Time.now.strftime('%Y.%m.%d')}", required: true, desc: 'index'
option :type, type: :string, aliases: '-t', default: nil, required: true, desc: 'type'
option :timestamp_key, aliases: '--timestamp_key', type: :string, desc: 'timestamp key', default: nil
option :add_timestamp, type: :boolean, default: true, desc: 'add_timestamp'
option :id_keys, type: :array, aliases: '--id', default: nil, desc: 'id'
@@ -196,9 +206,19 @@
end
desc 'refresh', 'refresh'
def refresh
puts_json(@core.refresh)
+ end
+
+ desc 'info', 'view nodes info'
+ def nodes_info
+ puts_json @core.nodes_info
+ end
+
+ desc 'stats', 'view nodes stats'
+ def nodes_stats
+ puts_json @core.nodes_stats
end
desc '--j2h', 'json to hash'
def json_to_hash
pp Yajl::Parser.parse(STDIN.read)