Update Search Engine

This commit is contained in:
Manson Wang 2014-03-23 12:13:06 +08:00
parent e8b273ee74
commit 2d34d9edcf
1 changed files with 2 additions and 9 deletions

View File

@ -1,5 +1,5 @@
class SiteSearchController < ApplicationController
include ActionView::Helpers::TextHelper
def search
startTime = Time.now
if params[:keywords].present?
@ -76,14 +76,7 @@ class SiteSearchController < ApplicationController
next
end
index = res[:content].index '<b>'
unless index.nil?
index = index>50 ? index-50 : 0
deadline = 150
res[:content] = res[:content][index, deadline]
else
res[:content] = res[:content][0, 100]
end
res[:content] = truncate(res[:content], length: 150)
end
result = result.sort_by { |k| k[:matches] }.reverse rescue []