diff --git a/app/lib/admin/system_check/elasticsearch_check.rb b/app/lib/admin/system_check/elasticsearch_check.rb index 406bb5bcb9..ea35807f30 100644 --- a/app/lib/admin/system_check/elasticsearch_check.rb +++ b/app/lib/admin/system_check/elasticsearch_check.rb @@ -76,14 +76,35 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck end def compatible_version? - return false if running_version.nil? - - Gem::Version.new(running_version) >= Gem::Version.new(required_version) || - Gem::Version.new(compatible_wire_version) >= Gem::Version.new(required_version) + running_version_ok? || compatible_wire_version_ok? rescue ArgumentError false end + def running_version_ok? + return false if running_version.blank? + + gem_version_running >= gem_version_required + end + + def compatible_wire_version_ok? + return false if compatible_wire_version.blank? + + gem_version_compatible_wire >= gem_version_required + end + + def gem_version_running + Gem::Version.new(running_version) + end + + def gem_version_required + Gem::Version.new(required_version) + end + + def gem_version_compatible_wire + Gem::Version.new(compatible_wire_version) + end + def mismatched_indexes @mismatched_indexes ||= INDEXES.filter_map do |klass| klass.base_name if Chewy.client.indices.get_mapping[klass.index_name]&.deep_symbolize_keys != klass.mappings_hash