-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Skip full text search if failed #9654
Conversation
app/services/search_service.rb
Outdated
results[:hashtags] = perform_hashtags_search! if hashtag_searchable? | ||
begin | ||
results[:statuses] = perform_statuses_search! if full_text_searchable? | ||
rescue Faraday::ConnectionFailed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more elegant to just add a rescue block to the perform_statuses_search!
method
app/services/search_service.rb
Outdated
@@ -62,7 +62,12 @@ def url_resource_symbol | |||
|
|||
def full_text_searchable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not the right method. Also, def/end blocks can have a rescue clause without extra begin/end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this?
def method
do_something
rescue Exception
fallback
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, like that. 👍
* Skip full text search if failed * Move rescue block to "perform_statuses_search!"
Sometimes, ES server are dead while main server is live.
We should give general search results(accounts, hashtags) even if ES server is dead.