Skip to content

Commit cfbb859

Browse files
committed
Switch to query-time boosting
1 parent 8b8aecb commit cfbb859

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

app/controllers/redsun_search_controller.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ def index
5454
highlight :id
5555
highlight :title
5656
highlight :filename
57+
boost_fields(
58+
:filename => 9,
59+
:subject => 9,
60+
:description => 7,
61+
:comments => 9,
62+
:notes => 9,
63+
:project_name => 10,
64+
:title => 10,
65+
:wiki_content => 8,
66+
)
5767
end
5868

5969
any_of do

lib/redmine_redsun/attachment_patch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def self.included(base) # :nodoc:
3434
end
3535

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

@@ -92,4 +92,4 @@ def description_for_search
9292

9393
end
9494
end
95-
end
95+
end

lib/redmine_redsun/issue_patch.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ def self.included(base) # :nodoc:
3131
boolean :is_private, stored: true
3232

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

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

4343
# Project ID
4444
integer :project_id
4545

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

lib/redmine_redsun/journal_patch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def self.included(base) # :nodoc:
2828
end
2929

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

lib/redmine_redsun/project_patch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def self.included(base) # :nodoc:
3737
end
3838

3939
# Name of Project
40-
text :project_name, stored: true, boost: 10 do
40+
text :project_name, stored: true do
4141
name.gsub(/[[:cntrl:]]/, ' ').scan(/[[:print:][:space:]]/).join if name.present?
4242
end
4343
end

lib/redmine_redsun/wiki_page_patch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def self.included(base) # :nodoc:
2727
end
2828

2929
# Page Title
30-
text :title, stored: true, boost: 10 do
30+
text :title, stored: true do
3131
title.gsub(/[[:cntrl:]]/, ' ').gsub(/_/, ' ').scan(/[[:print:][:space:]]/).join
3232
end
3333

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

0 commit comments

Comments
 (0)