Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to query-time boosting to support Solr 7 and better #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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