Text search now properly weighted and ranked

Default order by 'name' removed so that ranking can actually work.
This commit is contained in:
Christoph Haas 2016-08-12 16:40:12 +02:00
parent 3ffe975686
commit e2671d2545
2 changed files with 23 additions and 4 deletions

View file

@ -4,7 +4,12 @@ class Package < ActiveRecord::Base
include PgSearch
# TODO: Make search weighted on users' rating
pg_search_scope :general_search,
:against => [:name, :description, :long_description],
# :against => [:name, :description, :long_description],
:against => [
[:name, 'A'],
[:description, 'B'],
[:long_description, 'C']
],
:using => {
:tsearch => {:dictionary => "english"}
}
@ -14,9 +19,9 @@ class Package < ActiveRecord::Base
# screenshot files from disk.
has_many :screenshots, :inverse_of=>:package, :dependent => :destroy
default_scope {
order('name ASC')
}
# default_scope {
# order('name ASC')
# }
# Return a query of all packages that have screenshots
def self.with_screenshots