Search Engine remove result not matched
This commit is contained in:
parent
2f4c2c721a
commit
92d882703b
|
@ -19,7 +19,7 @@ class SiteSearchController < ApplicationController
|
|||
context = PageContext.where(:page_id=>page.id).first.context rescue nil
|
||||
next if title.nil? and context.nil?
|
||||
|
||||
context = context.gsub(/<\/?[^>]*>/, "").gsub(/ /i," ") rescue ""
|
||||
context = context.gsub(/<\/?[^>]*>/, "").gsub(/ /i,"") rescue ""
|
||||
title_matches = title.match(regex)
|
||||
context_matches = context.match(regex)
|
||||
if title_matches or context_matches
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue