Skip to content

Stop emitting FATAL log when checking existence of indices #982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elasticsearch-model/lib/elasticsearch/model/indexing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def create_index!(options={})
def index_exists?(options={})
target_index = options[:index] || self.index_name

self.client.indices.exists(index: target_index) rescue false
self.client.indices.exists(index: target_index, ignore: 404)
end

# Deletes the index with corresponding name
Expand Down
30 changes: 0 additions & 30 deletions elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -659,36 +659,6 @@ def changes
expect(DummyIndexingModel.index_exists?).to be(false)
end
end

context 'when the index API raises an error' do

let(:client) do
double('client').tap do |cl|
expect(cl).to receive(:indices).and_raise(StandardError)
end
end

it 'returns false' do
expect(DummyIndexingModel.index_exists?).to be(false)
end
end

context 'when the indices.exists API raises an error' do

let(:client) do
double('client', indices: indices)
end

let(:indices) do
double('indices').tap do |ind|
expect(ind).to receive(:exists).and_raise(StandardError)
end
end

it 'returns false' do
expect(DummyIndexingModel.index_exists?).to be(false)
end
end
end

describe '#delete_index!' do
Expand Down