]> cat aescling's git repositories - mastodon.git/blobdiff - app/services/account_search_service.rb
Fix search error when ElasticSearch is enabled but not available (#11954)
[mastodon.git] / app / services / account_search_service.rb
index 01caaefa94fe2a6afa9df4bad8d4f41a57636532..40c5f8590c9888a5278adf7ca1485b4c35a3ca56 100644 (file)
@@ -42,11 +42,9 @@ class AccountSearchService < BaseService
     return [] if limit_for_non_exact_results.zero?
 
     @search_results ||= begin
-      if Chewy.enabled?
-        from_elasticsearch
-      else
-        from_database
-      end
+      results = from_elasticsearch if Chewy.enabled?
+      results ||= from_database
+      results
     end
   end
 
@@ -92,6 +90,8 @@ class AccountSearchService < BaseService
     ActiveRecord::Associations::Preloader.new.preload(records, :account_stat)
 
     records
+  rescue Faraday::ConnectionFailed, Parslet::ParseFailed
+    nil
   end
 
   def reputation_score_function
This page took 0.123647 seconds and 4 git commands to generate.