|
|
|
@ -8,11 +8,12 @@ json.shixun_list do
|
|
|
|
|
# 去除开头标点符号
|
|
|
|
|
reg = /^[,。?:;‘’!“”—……、]/
|
|
|
|
|
# 附件的替换
|
|
|
|
|
atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
|
|
|
|
|
highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
|
|
|
|
|
Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}")
|
|
|
|
|
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
|
|
|
|
|
|
|
|
|
|
highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
|
|
|
|
|
highlights[:description]&.first&.sub!(reg, '')
|
|
|
|
|
highlights[:description]&.map{|des| des.gsub!(atta_reg, '')}
|
|
|
|
|
highlights[:content]&.first&.sub!(reg, '')
|
|
|
|
|
highlights[:content]&.map{|des| des.gsub!(atta_reg, '')}
|
|
|
|
|
|
|
|
|
|
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
|
|
|
|
|
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '')
|
|
|
|
|