Commit ea320fa2 by Kevin Chugh

fix broken elasticsearch index (tire) and fix cohorot union search

parent c1b989c8
...@@ -16,6 +16,7 @@ get "#{APIPREFIX}/:commentable_id/threads" do |commentable_id| ...@@ -16,6 +16,7 @@ get "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
end end
post "#{APIPREFIX}/:commentable_id/threads" do |commentable_id| post "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
puts "**************** commentable_id is #{commentable_id}"
thread = CommentThread.new(params.slice(*%w[title body course_id ]).merge(commentable_id: commentable_id)) thread = CommentThread.new(params.slice(*%w[title body course_id ]).merge(commentable_id: commentable_id))
thread.anonymous = bool_anonymous || false thread.anonymous = bool_anonymous || false
thread.anonymous_to_peers = bool_anonymous_to_peers || false thread.anonymous_to_peers = bool_anonymous_to_peers || false
......
...@@ -40,9 +40,10 @@ class CommentThread < Content ...@@ -40,9 +40,10 @@ class CommentThread < Content
indexes :comment_count, type: :integer, included_in_all: false indexes :comment_count, type: :integer, included_in_all: false
indexes :votes_point, type: :integer, as: 'votes_point', included_in_all: false indexes :votes_point, type: :integer, as: 'votes_point', included_in_all: false
indexes :course_id, type: :string, index: :not_analyzed, incldued_in_all: false indexes :course_id, type: :string, index: :not_analyzed, included_in_all: false
indexes :commentable_id, type: :string, index: :not_analyzed, incldued_in_all: false indexes :commentable_id, type: :string, index: :not_analyzed, included_in_all: false
indexes :author_id, type: :string, as: 'author_id', index: :not_analyzed, incldued_in_all: false 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
end end
belongs_to :author, class_name: "User", inverse_of: :comment_threads, index: true#, autosave: true belongs_to :author, class_name: "User", inverse_of: :comment_threads, index: true#, autosave: true
...@@ -110,14 +111,15 @@ class CommentThread < Content ...@@ -110,14 +111,15 @@ class CommentThread < Content
search.filter(:term, course_id: params["course_id"]) if params["course_id"] search.filter(:term, course_id: params["course_id"]) if params["course_id"]
if params["group_id"] if params["group_id"]
search.filter :or, [ search.filter :or, [
{:not => {:exists => {:field => :group_id}}}, {:not => {:exists => {:field => :group_id}}},
{:term => {:group_id => params["group_id"]}} {:term => {:group_id => params["group_id"]}}
] ]
puts "\n\n\n\n\n*****************-> #{search.filters}"
end end
search.sort {|sort| sort.by sort_key, sort_order} if sort_key && sort_order #TODO should have search option 'auto sort or sth' search.sort {|sort| sort.by sort_key, sort_order} if sort_key && sort_order #TODO should have search option 'auto sort or sth'
search.size per_page search.size per_page
......
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