Commit 7a197b386a21d78115dea72c9cd2e123b3c8da53
Exists in
master
and in
21 other branches
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,7 +36,7 @@ module Searchkick | ||
36 | begin | 36 | begin |
37 | client.indices.get_alias(name: name).keys | 37 | client.indices.get_alias(name: name).keys |
38 | rescue Elasticsearch::Transport::Transport::Errors::NotFound | 38 | rescue Elasticsearch::Transport::Transport::Errors::NotFound |
39 | - [] | 39 | + {} |
40 | end | 40 | end |
41 | actions = old_indices.map { |old_name| {remove: {index: old_name, alias: name}} } + [{add: {index: new_name, alias: name}}] | 41 | actions = old_indices.map { |old_name| {remove: {index: old_name, alias: name}} } + [{add: {index: new_name, alias: name}}] |
42 | client.indices.update_aliases body: {actions: actions} | 42 | client.indices.update_aliases body: {actions: actions} |
@@ -146,7 +146,7 @@ module Searchkick | @@ -146,7 +146,7 @@ module Searchkick | ||
146 | begin | 146 | begin |
147 | client.indices.get_aliases | 147 | client.indices.get_aliases |
148 | rescue Elasticsearch::Transport::Transport::Errors::NotFound | 148 | rescue Elasticsearch::Transport::Transport::Errors::NotFound |
149 | - [] | 149 | + {} |
150 | end | 150 | end |
151 | indices = all_indices.select { |k, v| (v.empty? || v["aliases"].empty?) && k =~ /\A#{Regexp.escape(name)}_\d{14,17}\z/ }.keys | 151 | indices = all_indices.select { |k, v| (v.empty? || v["aliases"].empty?) && k =~ /\A#{Regexp.escape(name)}_\d{14,17}\z/ }.keys |
152 | indices.each do |index| | 152 | indices.each do |index| |