diff --git a/app/models/post.rb b/app/models/post.rb index e07a78f841..76db8ddd76 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -57,7 +57,7 @@ class Post < ActiveRecord::Base validates_with PostValidator, unless: :skip_validation - after_save :index_search + after_commit :index_search # We can pass several creating options to a post via attributes attr_accessor :image_sizes, :quoted_post_numbers, :no_bump, :invalidate_oneboxes, :cooking_options, :skip_unique_check, :skip_validation @@ -898,7 +898,9 @@ class Post < ActiveRecord::Base end def index_search - SearchIndexer.index(self) + Scheduler::Defer.later "Index post for search" do + SearchIndexer.index(self) + end end def locked? diff --git a/app/services/search_indexer.rb b/app/services/search_indexer.rb index 01a24cc5c0..3cf2ff4550 100644 --- a/app/services/search_indexer.rb +++ b/app/services/search_indexer.rb @@ -201,9 +201,9 @@ class SearchIndexer if Post === obj && obj.raw.present? && ( + force || obj.saved_change_to_cooked? || - obj.saved_change_to_topic_id? || - force + obj.saved_change_to_topic_id? ) if topic