Skip to content

Skip full text search if failed#9654

Merged
Gargron merged 2 commits intomastodon:masterfrom
tribela:fallback-chewy
Dec 30, 2018
Merged

Skip full text search if failed#9654
Gargron merged 2 commits intomastodon:masterfrom
tribela:fallback-chewy

Conversation

@tribela
Copy link
Copy Markdown
Contributor

@tribela tribela commented Dec 29, 2018

Sometimes, ES server are dead while main server is live.
We should give general search results(accounts, hashtags) even if ES server is dead.

Comment thread 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
Copy link
Copy Markdown
Member

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

Comment thread app/services/search_service.rb Outdated
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, like that. 👍

@Gargron Gargron merged commit 511231c into mastodon:master Dec 30, 2018
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Skip full text search if failed

* Move rescue block to "perform_statuses_search!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants