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
23 24 25 26 27 28 29 30 31 |
# File 'lib/ej/commands.rb', line 23 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
105 106 107 |
# File 'lib/ej/commands.rb', line 105 def aggs puts_with_format(@core.aggs([:terms], [:size], [:query])) end |
#aliases ⇒ Object
149 150 151 |
# File 'lib/ej/commands.rb', line 149 def aliases puts_with_format(@indices.aliases) end |
#bulk ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/ej/commands.rb', line 128 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
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ej/commands.rb', line 75 def copy @core.copy( [:source], [:dest], [:query], [:per], [:scroll], [:dest_index], [:slice_max] ) end |
#count(query = ) ⇒ Object
56 57 58 |
# File 'lib/ej/commands.rb', line 56 def count(query = [:query]) puts_with_format(@core.search([:type], query, 0, 0, false)) end |
#create_aliases ⇒ Object
198 199 200 |
# File 'lib/ej/commands.rb', line 198 def create_aliases @indices.create_aliases([:alias], [:indices]) end |
#delete ⇒ Object
211 212 213 214 |
# File 'lib/ej/commands.rb', line 211 def delete query = [:query] ? eval([:query]) : nil @indices.delete([:index], [:type], query) end |
#delete_template ⇒ Object
218 219 220 |
# File 'lib/ej/commands.rb', line 218 def delete_template @indices.delete_template([:name]) end |
#distinct(term) ⇒ Object
63 64 65 |
# File 'lib/ej/commands.rb', line 63 def distinct(term) puts_with_format(@core.distinct(term, [:type], [:query])) end |
#dump ⇒ Object
90 91 92 |
# File 'lib/ej/commands.rb', line 90 def dump @core.dump([:query], [:per]) end |
#facet(term) ⇒ Object
97 98 99 |
# File 'lib/ej/commands.rb', line 97 def facet(term) puts_with_format(@core.facet(term, [:size], [:query])) end |
#health ⇒ Object
144 145 146 |
# File 'lib/ej/commands.rb', line 144 def health puts_with_format(@cluster.health) end |
#indices ⇒ Object
159 160 161 |
# File 'lib/ej/commands.rb', line 159 def indices puts_with_format(@indices.indices) end |
#mapping ⇒ Object
169 170 171 |
# File 'lib/ej/commands.rb', line 169 def mapping puts_with_format(@indices.mapping) end |
#max ⇒ Object
117 118 119 |
# File 'lib/ej/commands.rb', line 117 def max puts_with_format(@core.max([:term])) end |
#min ⇒ Object
111 112 113 |
# File 'lib/ej/commands.rb', line 111 def min puts_with_format(@core.min([:term])) end |
#nodes_info ⇒ Object
243 244 245 |
# File 'lib/ej/commands.rb', line 243 def nodes_info puts_with_format @nodes.nodes_info end |
#nodes_stats ⇒ Object
248 249 250 |
# File 'lib/ej/commands.rb', line 248 def nodes_stats puts_with_format @nodes.nodes_stats end |
#not_analyzed ⇒ Object
174 175 176 177 178 |
# File 'lib/ej/commands.rb', line 174 def not_analyzed json = File.read(File.('../../../template/not_analyze_template.json', __FILE__)) hash = JSON.parse(json) puts_with_format(@indices.put_template('ej_init', hash)) end |
#put_routing ⇒ Object
184 185 186 187 |
# File 'lib/ej/commands.rb', line 184 def put_routing body = { [:type] => {"_routing"=>{"required"=>true, "path"=>[:path]}}} puts_with_format(@indices.put_mapping([:index], [:type], body)) end |
#put_template(name) ⇒ Object
190 191 192 193 |
# 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 ⇒ Object
203 204 205 |
# File 'lib/ej/commands.rb', line 203 def recovery @indices.recovery end |
#refresh ⇒ Object
238 239 240 |
# File 'lib/ej/commands.rb', line 238 def refresh puts_with_format(@indices.refresh) end |
#search(query = ) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ej/commands.rb', line 41 def search(query = [:query]) puts_with_format(@core.search([:type], query, [:size], [:from], [:meta], nil, [:fields], [:sort] )) end |
#settings ⇒ Object
228 229 230 |
# File 'lib/ej/commands.rb', line 228 def settings puts_with_format(@indices.settings) end |
#state ⇒ Object
154 155 156 |
# File 'lib/ej/commands.rb', line 154 def state puts_with_format(@cluster.state) end |
#stats ⇒ Object
164 165 166 |
# File 'lib/ej/commands.rb', line 164 def stats puts_with_format(@indices.stats) end |
#template ⇒ Object
223 224 225 |
# File 'lib/ej/commands.rb', line 223 def template puts_with_format(@indices.template) end |
#version ⇒ Object
253 254 255 |
# File 'lib/ej/commands.rb', line 253 def version puts VERSION end |
#warmer ⇒ Object
233 234 235 |
# File 'lib/ej/commands.rb', line 233 def warmer puts_with_format(@indices.warmer) end |