Skip to content

Commit adb40ca

Browse files
committed
Better ranking result
1 parent fd05e41 commit adb40ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/krate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,10 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
474474
args.insert(0, query);
475475
("SELECT crates.* FROM crates,
476476
plainto_tsquery($1) q,
477+
ts_rank_cd(to_tsvector('english', name), q, 8) name_rank,
477478
ts_rank_cd(textsearchable_index_col, q) rank
478479
WHERE q @@ textsearchable_index_col
479-
ORDER BY rank DESC, crates.name ASC
480+
ORDER BY name_rank DESC, rank DESC, crates.name ASC
480481
LIMIT $2 OFFSET $3".to_string(),
481482
"SELECT COUNT(crates.*) FROM crates,
482483
plainto_tsquery($1) q

0 commit comments

Comments
 (0)