Commit 7a197b386a21d78115dea72c9cd2e123b3c8da53

Authored by Andrew Kane
2 parents 5ef7bde1 1352b808

Merge pull request #645 from habermeier/fix_no_indicies

reindexing models on an ES cluster that is totally new / empty throws…
Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
lib/searchkick/index.rb
... ... @@ -36,7 +36,7 @@ module Searchkick
36 36 begin
37 37 client.indices.get_alias(name: name).keys
38 38 rescue Elasticsearch::Transport::Transport::Errors::NotFound
39   - []
  39 + {}
40 40 end
41 41 actions = old_indices.map { |old_name| {remove: {index: old_name, alias: name}} } + [{add: {index: new_name, alias: name}}]
42 42 client.indices.update_aliases body: {actions: actions}
... ... @@ -146,7 +146,7 @@ module Searchkick
146 146 begin
147 147 client.indices.get_aliases
148 148 rescue Elasticsearch::Transport::Transport::Errors::NotFound
149   - []
  149 + {}
150 150 end
151 151 indices = all_indices.select { |k, v| (v.empty? || v["aliases"].empty?) && k =~ /\A#{Regexp.escape(name)}_\d{14,17}\z/ }.keys
152 152 indices.each do |index|
... ...