Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Reindex model on elasticsearch bad request exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
nning committed Apr 1, 2014
1 parent 940d982 commit 07b023f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/admin/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ class Admin::SearchesController < AdminController
# Search models for query.
def search
@results = Search.for(current_mailbox, params[:q])
rescue Elasticsearch::Transport::Transport::BadRequest
if @already_retried
raise
else
logger.warn 'Reindexing models, because we cought an bad request exception in elasticsearch transport.'
[Alias, Domain, Mailbox].map(&:reindex)
@already_retried = true
retry
end
end
end

0 comments on commit 07b023f

Please sign in to comment.