Text search now properly weighted and ranked
Default order by 'name' removed so that ranking can actually work.
This commit is contained in:
parent
3ffe975686
commit
e2671d2545
2 changed files with 23 additions and 4 deletions
|
|
@ -0,0 +1,14 @@
|
|||
# PostregreSQL text searches are now using weights. So the index has to reflect that.
|
||||
class MakeFulltextSearchIndexWeighted < ActiveRecord::Migration
|
||||
def change
|
||||
execute "drop index packages_fts"
|
||||
|
||||
execute "create index packages_fts on packages using gin((
|
||||
setweight( to_tsvector('english', coalesce(\"packages\".\"name\"::text, '')), 'A' )
|
||||
||
|
||||
setweight( to_tsvector('english', coalesce(\"packages\".\"description\"::text, '')), 'B' )
|
||||
||
|
||||
setweight( to_tsvector('english', coalesce(\"packages\".\"long_description\"::text, '')), 'C' )
|
||||
))"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue