Commit 069a5475 by Kevin Chugh

initial commit for attempt at deep search with built in indexing

parent f50e9fde
......@@ -20,6 +20,7 @@ class Comment < Content
belongs_to :comment_thread, index: true
belongs_to :author, class_name: "User", index: true
after_save :update_thread_index
attr_accessible :body, :course_id, :anonymous, :anonymous_to_peers, :endorsed
......@@ -103,4 +104,10 @@ private
self.comment_thread.update_attributes!(last_activity_at: Time.now.utc)
end
def update_thread_index
#after each save of a comment, update it's thread's search index
#t = self.comment_thread
tire.update_index
end
end
......@@ -46,10 +46,13 @@ class CommentThread < Content
indexes :author_id, type: :string, as: 'author_id', index: :not_analyzed, included_in_all: false
indexes :group_id, type: :integer, as: 'group_id', index: :not_analyzed, included_in_all: false
#indexes :pinned, type: :boolean, as: 'pinned', index: :not_analyzed, included_in_all: false
indexes :comments do
indexes :body, analyzer: 'snowball'
end
end
belongs_to :author, class_name: "User", inverse_of: :comment_threads, index: true#, autosave: true
has_many :comments, dependent: :destroy#, autosave: true# Use destroy to envoke callback on the top-level comments TODO async
has_many :comments, dependent: :destroy #, autosave: true# Use destroy to envoke callback on the top-level comments TODO async
has_many :activities, autosave: true
attr_accessible :title, :body, :course_id, :commentable_id, :anonymous, :anonymous_to_peers, :closed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment