Commit 2d0258fa055658c11cd476adc4637ebb2ce3d1f5

Authored by Andrew Kane
1 parent 502cf12a

Rescue 404 for get_aliases - closes #569

Showing 1 changed file with 6 additions and 1 deletions   Show diff stats
lib/searchkick/index.rb
... ... @@ -132,7 +132,12 @@ module Searchkick
132 132  
133 133 # remove old indices that start w/ index_name
134 134 def clean_indices
135   - all_indices = client.indices.get_aliases
  135 + all_indices =
  136 + begin
  137 + client.indices.get_aliases
  138 + rescue Elasticsearch::Transport::Transport::Errors::NotFound
  139 + []
  140 + end
136 141 indices = all_indices.select { |k, v| (v.empty? || v["aliases"].empty?) && k =~ /\A#{Regexp.escape(name)}_\d{14,17}\z/ }.keys
137 142 indices.each do |index|
138 143 Searchkick::Index.new(index).delete
... ...