Skip to content

Commit

Permalink
Switch to query-time boosting
Browse files Browse the repository at this point in the history
  • Loading branch information
znerol committed Dec 7, 2020
1 parent 8b8aecb commit cfbb859
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
10 changes: 10 additions & 0 deletions app/controllers/redsun_search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def index
highlight :id
highlight :title
highlight :filename
boost_fields(
:filename => 9,
:subject => 9,
:description => 7,
:comments => 9,
:notes => 9,
:project_name => 10,
:title => 10,
:wiki_content => 8,
)
end

any_of do
Expand Down
4 changes: 2 additions & 2 deletions lib/redmine_redsun/attachment_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def self.included(base) # :nodoc:
end

# Filename
text :filename, stored: true, boost: 9 do
text :filename, stored: true do
filename.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if filename.present?
end

Expand Down Expand Up @@ -92,4 +92,4 @@ def description_for_search

end
end
end
end
6 changes: 3 additions & 3 deletions lib/redmine_redsun/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ def self.included(base) # :nodoc:
boolean :is_private, stored: true

# Subject
text :subject, stored: true, boost: 9 do
text :subject, stored: true do
subject.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if subject.present?
end

# Description
text :description, stored: true, boost: 7 do
text :description, stored: true do
description.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if description.present?
end

# Project ID
integer :project_id

# Journals entries, i.e. status updates, comments, etc.
text :comments, stored: true, boost: 9 do
text :comments, stored: true do
journals.where("journals.notes != ''").map { |j| j.notes.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if j.notes.present? }.join(' ')
end

Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_redsun/journal_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.included(base) # :nodoc:
end

# Notes
text :notes, stored: true, boost: 9 do
text :notes, stored: true do
notes.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if notes.present?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_redsun/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.included(base) # :nodoc:
end

# Name of Project
text :project_name, stored: true, boost: 10 do
text :project_name, stored: true do
name.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if name.present?
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/redmine_redsun/wiki_page_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def self.included(base) # :nodoc:
end

# Page Title
text :title, stored: true, boost: 10 do
text :title, stored: true do
title.gsub(/[[:cntrl:]]/, ' ').gsub(/_/, ' ').scan(/[[:print:][:space:]]/).join
end

# Content of Page
text :wiki_content, stored: true, boost: 8 do
text :wiki_content, stored: true do
content.text.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join unless content.nil?
end

Expand Down

0 comments on commit cfbb859

Please sign in to comment.