Class: Estool::Actions::Index
- Inherits:
-
Object
- Object
- Estool::Actions::Index
- Defined in:
- lib/estool/actions/index.rb
Instance Method Summary collapse
- #format_options(data) ⇒ Object
- #index(action, options, server) ⇒ Object
-
#initialize(command, options) ⇒ Index
constructor
A new instance of Index.
- #run ⇒ Object
Constructor Details
#initialize(command, options) ⇒ Index
Returns a new instance of Index.
8 9 10 11 12 |
# File 'lib/estool/actions/index.rb', line 8 def initialize(command, ) @cmd = command @data = .except(:host, :port) @server = .slice(:host, :port) end |
Instance Method Details
#format_options(data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/estool/actions/index.rb', line 14 def (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) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/estool/actions/index.rb', line 29 def index(action, , server) client = Estool::Connections.start_conn(server[:host], server[:port]) Estool::Connections.test_conn(client) begin puts client.indices.send(action, ) rescue ArgumentError => args puts " #{args} Usage: 'estool index help #{action}' for more information " exit 1 end end |
#run ⇒ Object
43 44 45 46 |
# File 'lib/estool/actions/index.rb', line 43 def run params = (@data) index(@cmd, params, @server) end |