From a70b2c5f0ee018460e4560a4c7ff8f65c99a2b33 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Mon, 15 Mar 2021 02:00:05 -0700 Subject: [PATCH] Sort body search results by rank properly --- Rocksolid_Light/rocksolid/search.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Rocksolid_Light/rocksolid/search.php b/Rocksolid_Light/rocksolid/search.php index a94b95b..c103fce 100644 --- a/Rocksolid_Light/rocksolid/search.php +++ b/Rocksolid_Light/rocksolid/search.php @@ -278,7 +278,7 @@ function get_body_search($group, $terms) { $group=$name[0]; $database = $spooldir.'/'.$group.'-articles.db3'; $dbh = article_db_open($database); - $stmt = $dbh->prepare("SELECT snippet(search_fts, 6, '', '', '...', 50) as snippet, newsgroup, number, name, date, subject FROM search_fts WHERE search_fts MATCH 'search_snippet:$terms' ORDER BY rank"); + $stmt = $dbh->prepare("SELECT snippet(search_fts, 6, '', '', '...', 50) as snippet, newsgroup, number, name, date, subject, rank FROM search_fts WHERE search_fts MATCH 'search_snippet:$terms' ORDER BY rank"); $stmt->execute(); while ($row = $stmt->fetch()) { @@ -286,6 +286,9 @@ function get_body_search($group, $terms) { } $dbh = null; } + usort($overview, function($a, $b) { + return $a['rank'] <=> $b['rank']; + }); return $overview; }