Commit 52f44f99 by Your Name

deep search testing 1

parent 5d644862
......@@ -118,8 +118,7 @@ class CommentThread < Content
#thread ids and the original thread search) and merge the results, uniqifying the results in the process.
#so first, find the comment threads associated with comments that hit the query
search = Tire::Search::Search.new 'comment_threads'
search.query {|query| query.text :_all, params["text"]} if params["text"]
search.highlight({title: { number_of_fragments: 0 } } , {body: { number_of_fragments: 0 } }, options: { tag: "<highlight>" })
......@@ -145,6 +144,9 @@ class CommentThread < Content
end
results = search.results
puts "PHASE I RESULTS: #{results.collect{|r| r['id']}}"
#if this is a search query, then also search the comments and harvest the matching comments
if params["text"]
......
require 'spec_helper'
describe "app" do
describe "search" do
describe "GET /api/v1/search/threads" do
it "returns thread with query match" do
user = User.find 1
if not user
user = create_test_user(1)
end
commentable = Commentable.new("question_1")
thread = CommentThread.new(title: "Test title", body: "otter", course_id: "1", commentable_id: commentable.id)
thread.author = user
thread.save!
puts "thread id is #{thread.id}"
get "/api/v1/search/threads", text: "otter"
last_response.should be_ok
threads = parse(last_response.body)['collection']
puts "threads: #{threads.collect{|t| t['id']}}"
threads.select{|t| t["id"].to_s == thread.id.to_s}.first.should_not be_nil
end
end
end
end
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