Class: Ej::Commands
- Inherits:
-
Thor
- Object
- Thor
- Ej::Commands
- Defined in:
- lib/ej/commands.rb
Instance Method Summary collapse
- #aggs ⇒ Object
- #aliases ⇒ Object
- #bulk ⇒ Object
- #copy ⇒ Object
- #count(query = ) ⇒ Object
- #create_aliases ⇒ Object
- #delete ⇒ Object
- #delete_template ⇒ Object
- #distinct(term) ⇒ Object
- #dump ⇒ Object
- #facet(term) ⇒ Object
- #health ⇒ Object
- #indices ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Commands
constructor
A new instance of Commands.
- #mapping ⇒ Object
- #max ⇒ Object
- #min ⇒ Object
- #nodes_info ⇒ Object
- #nodes_stats ⇒ Object
- #not_analyzed ⇒ Object
- #put_routing ⇒ Object
- #put_template(name) ⇒ Object
- #recovery ⇒ Object
- #refresh ⇒ Object
- #search(query = ) ⇒ Object
- #settings ⇒ Object
- #state ⇒ Object
- #stats ⇒ Object
- #template ⇒ Object
- #version ⇒ Object
- #warmer ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Commands
Returns a new instance of Commands.
21 22 23 24 25 26 27 28 29 |
# File 'lib/ej/commands.rb', line 21 def initialize(args = [], = {}, config = {}) super(args, , config) @global_options = config[:shell].base. 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 |
Instance Method Details
#aggs ⇒ Object
99 100 101 |
# File 'lib/ej/commands.rb', line 99 def aggs puts_with_format(@core.aggs([:terms], [:size], [:query])) end |
#aliases ⇒ Object
143 144 145 |
# File 'lib/ej/commands.rb', line 143 def aliases puts_with_format(@indices.aliases) end |
#bulk ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ej/commands.rb', line 122 def bulk inputs = [:inputs].empty? ? [STDIN] : [:inputs] inputs.each do |key| buffer = (key.class == STDIN.class) ? STDIN.read : File.read(key) @core.bulk( [:timestamp_key], [:type], [:add_timestamp], [:id_keys], [:index], Util.parse_json(buffer) ) end end |
#copy ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/ej/commands.rb', line 71 def copy @core.copy( [:source], [:dest], [:query], [:per], [:scroll] ) end |
#count(query = ) ⇒ Object
54 55 56 |
# File 'lib/ej/commands.rb', line 54 def count(query = [:query]) puts_with_format(@core.search([:type], query, 0, 0, false)) end |
#create_aliases ⇒ Object
192 193 194 |
# File 'lib/ej/commands.rb', line 192 def create_aliases @indices.create_aliases([:alias], [:indices]) end |
#delete ⇒ Object
205 206 207 208 |
# File 'lib/ej/commands.rb', line 205 def delete query = [:query] ? eval([:query]) : nil @indices.delete([:index], [:type], query) end |
#delete_template ⇒ Object
212 213 214 |
# File 'lib/ej/commands.rb', line 212 def delete_template @indices.delete_template([:name]) end |
#distinct(term) ⇒ Object
61 62 63 |
# File 'lib/ej/commands.rb', line 61 def distinct(term) puts_with_format(@core.distinct(term, [:type], [:query])) end |
#dump ⇒ Object
84 85 86 |
# File 'lib/ej/commands.rb', line 84 def dump @core.dump([:query], [:per]) end |
#facet(term) ⇒ Object
91 92 93 |
# File 'lib/ej/commands.rb', line 91 def facet(term) puts_with_format(@core.facet(term, [:size], [:query])) end |
#health ⇒ Object
138 139 140 |
# File 'lib/ej/commands.rb', line 138 def health puts_with_format(@cluster.health) end |
#indices ⇒ Object
153 154 155 |
# File 'lib/ej/commands.rb', line 153 def indices puts_with_format(@indices.indices) end |
#mapping ⇒ Object
163 164 165 |
# File 'lib/ej/commands.rb', line 163 def mapping puts_with_format(@indices.mapping) end |
#max ⇒ Object
111 112 113 |
# File 'lib/ej/commands.rb', line 111 def max puts_with_format(@core.max([:term])) end |
#min ⇒ Object
105 106 107 |
# File 'lib/ej/commands.rb', line 105 def min puts_with_format(@core.min([:term])) end |
#nodes_info ⇒ Object
237 238 239 |
# File 'lib/ej/commands.rb', line 237 def nodes_info puts_with_format @nodes.nodes_info end |
#nodes_stats ⇒ Object
242 243 244 |
# File 'lib/ej/commands.rb', line 242 def nodes_stats puts_with_format @nodes.nodes_stats end |
#not_analyzed ⇒ Object
168 169 170 171 172 |
# File 'lib/ej/commands.rb', line 168 def not_analyzed json = File.read(File.('../../../template/not_analyze_template.json', __FILE__)) hash = Yajl::Parser.parse(json) puts_with_format(@indices.put_template('ej_init', hash)) end |
#put_routing ⇒ Object
178 179 180 181 |
# File 'lib/ej/commands.rb', line 178 def put_routing body = { [:type] => {"_routing"=>{"required"=>true, "path"=>[:path]}}} puts_with_format(@indices.put_mapping([:index], [:type], body)) end |
#put_template(name) ⇒ Object
184 185 186 187 |
# File 'lib/ej/commands.rb', line 184 def put_template(name) hash = Yajl::Parser.parse(STDIN.read) puts_with_format(@indices.put_template(name, hash)) end |
#recovery ⇒ Object
197 198 199 |
# File 'lib/ej/commands.rb', line 197 def recovery @indices.recovery end |
#refresh ⇒ Object
232 233 234 |
# File 'lib/ej/commands.rb', line 232 def refresh puts_with_format(@indices.refresh) end |
#search(query = ) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ej/commands.rb', line 39 def search(query = [:query]) puts_with_format(@core.search([:type], query, [:size], [:from], [:meta], nil, [:fields], [:sort] )) end |
#settings ⇒ Object
222 223 224 |
# File 'lib/ej/commands.rb', line 222 def settings puts_with_format(@indices.settings) end |
#state ⇒ Object
148 149 150 |
# File 'lib/ej/commands.rb', line 148 def state puts_with_format(@cluster.state) end |
#stats ⇒ Object
158 159 160 |
# File 'lib/ej/commands.rb', line 158 def stats puts_with_format(@indices.stats) end |
#template ⇒ Object
217 218 219 |
# File 'lib/ej/commands.rb', line 217 def template puts_with_format(@indices.template) end |
#version ⇒ Object
247 248 249 |
# File 'lib/ej/commands.rb', line 247 def version puts VERSION end |
#warmer ⇒ Object
227 228 229 |
# File 'lib/ej/commands.rb', line 227 def warmer puts_with_format(@indices.warmer) end |