Tweak the textual search to rank exact name matches higher
Previously, if you searched for packages like Ruby or Guile, the actual Ruby and Guile packages would be low in the rankings, as the terms Ruby or Guile don't appear much in the descriptions. Therefore, change the ordering to make these exact matches appear higher up.
This commit is contained in:
parent
759b75257e
commit
465f262ded
1 changed files with 17 additions and 1 deletions
|
|
@ -118,7 +118,23 @@ WHERE packages.id IN (
|
|||
WHERE guix_revisions.commit = $1
|
||||
)
|
||||
AND to_tsvector(name || ' ' || synopsis) @@ plainto_tsquery($2)
|
||||
ORDER BY ts_rank_cd(to_tsvector(name || ' ' || synopsis), plainto_tsquery($2)) DESC"
|
||||
ORDER BY (
|
||||
ts_rank_cd(
|
||||
to_tsvector(name),
|
||||
plainto_tsquery($2),
|
||||
2 -- divide rank by the document length
|
||||
)
|
||||
* 4 -- as the name is more important
|
||||
) +
|
||||
ts_rank_cd(
|
||||
to_tsvector(synopsis),
|
||||
plainto_tsquery($2),
|
||||
32 -- divide the rank by itself + 1
|
||||
) DESC,
|
||||
-- to make the order stable
|
||||
name,
|
||||
version
|
||||
"
|
||||
(if limit-results
|
||||
(string-append "\nLIMIT " (number->string limit-results))
|
||||
"")))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue