Created
December 5, 2014 18:44
-
-
Save cannikin/c10103f1b294c6c72abe to your computer and use it in GitHub Desktop.
Delete all of the annoying .marvel indexes from Elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'elasticsearch' | |
require 'optparse' | |
client = Elasticsearch::Client.new :host => 'localhost:9200' | |
indices = client.cat.indices.split("\n").collect { |i| i.split(' ')[1] } | |
indices.each do |index| | |
if index =~ /\.marvel/ | |
client.indices.delete :index => index | |
puts "Deleting #{index}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the sharing! Although in my case (elasticsearch 1.5.0) index name is at
[2]
in the array, so the line reads like this:indices = client.cat.indices.split("\n").collect { |i| i.split(' ')[2] }