From 5db9207ca398c5d77f671109360ca7f63e3f2112 Mon Sep 17 00:00:00 2001 From: Takumasa Ochi Date: Tue, 2 Mar 2021 02:35:54 +0900 Subject: [PATCH] Stop emitting FATAL log when checking existence of indices Passing `ignore: 404` to Elasticsearch::Client can stop FATAL log in addition to stopping exception. This option is supported since the 5.0.4 and 6.0.0 of `elasticsearch-ruby`. https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#600 https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#504 This swallowing was implemented following exception catching as follows. https://github.com/elastic/elasticsearch-ruby/commit/9848c977a4cad6ff638b89828a3e6a6c599fe0d7 --- elasticsearch-model/lib/elasticsearch/model/indexing.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index 16ad1b3e4..9659e3408 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -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