lib/desi/index_manager.rb in desi-0.2.0 vs lib/desi/index_manager.rb in desi-0.2.1

- old
+ new

@@ -18,11 +18,11 @@ # @option opts [#new] :http_client_factory (Desi::HttpClient) HTTP transport class # to use # # @note The +:http_client_factory+ should return an instance that responds # to #get and #delete - # @return [undefined] + # @return [void] # # @api public def initialize(opts = {}) @host = opts.fetch(:host, 'http://127.0.0.1:9200') @verbose = opts[:verbose] @@ -58,11 +58,11 @@ end # Delete all indices matching the specified pattern # # @param [#to_s] pattern Regexp pattern used to restrict the selection - # @return [undefined] + # @return [void] # # @note No confirmation is needed, so beware! # # @note This method will also output its result on STDOUT if +@verbose+ is # true @@ -75,19 +75,19 @@ warn "You must provide a pattern" and exit if pattern.nil? @outputter.puts "The following indices from host #{@host} are now deleted" if @verbose indices(Regexp.new(pattern)).each do |index| - @client.delete(index) + @client.delete("/#{index}") @outputter.puts " * #{index}" if @verbose end end # Empty (remove all records) from indices matching the specified pattern # # @param [#to_s] pattern Regexp pattern used to restrict the selection - # @return [undefined] + # @return [void] # # @note No confirmation is needed, so beware! # # @note This method will also output its result on STDOUT if +@verbose+ is # true @@ -100,18 +100,18 @@ warn "You must provide a pattern" and exit if pattern.nil? @outputter.puts "The following indices from host #{@host} are now emptied" if @verbose indices(Regexp.new(pattern)).each do |index| - @client.delete("#{index}/_query?q=*") + @client.delete("/#{index}/_query?q=*") @outputter.puts " * #{index}" if @verbose end end private def indices(pattern) - JSON.parse(@client.get('_status').body)["indices"].keys.select {|i| + JSON.parse(@client.get('/_status').body)["indices"].keys.select {|i| i =~ pattern } end end