Skip to content

Instantly share code, notes, and snippets.

@cannikin
Created December 5, 2014 18:44
Show Gist options
  • Save cannikin/c10103f1b294c6c72abe to your computer and use it in GitHub Desktop.
Save cannikin/c10103f1b294c6c72abe to your computer and use it in GitHub Desktop.
Delete all of the annoying .marvel indexes from Elasticsearch
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
@nicnilov
Copy link

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] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment