Search Engine remove result not matched

This commit is contained in:
Manson Wang 2014-03-19 15:24:29 +08:00
parent 2f4c2c721a
commit 92d882703b
1 changed files with 6 additions and 4 deletions

View File

@ -71,8 +71,10 @@ class SiteSearchController < ApplicationController
res[:content].gsub!(/(#{k})/i, '<b>\1</b>') rescue ""
end
result.delete(res) if res[:matches]==0
next if res[:matches]==0
if res[:matches]==0
result = result - [res]
next
end
index = res[:content].index '<b>'
unless index.nil?
@ -80,7 +82,7 @@ class SiteSearchController < ApplicationController
deadline = 150
res[:content] = res[:content][index, deadline]
else
res[:content] = res[:content][0, 150]
res[:content] = res[:content][0, 100]
end
end