From fa7d93df7236721ed97f1f85d974eb1c91a01537 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <gitlab@cmatte.me>
Date: Fri, 22 Oct 2021 16:32:04 +0200
Subject: [PATCH] Search: bugfix: replace sites.baseurl with sites.hostname

---
 tools/search/sql/functions.sql | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/search/sql/functions.sql b/tools/search/sql/functions.sql
index 9ee5c4a5..b3dcc6c4 100644
--- a/tools/search/sql/functions.sql
+++ b/tools/search/sql/functions.sql
@@ -20,9 +20,9 @@ BEGIN
 
     SELECT INTO pagecount sites.pagecount FROM sites WHERE id=1;
     IF _suburl IS NULL THEN
-        OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
+        OPEN curs FOR SELECT sites.id AS siteid, sites.hostname AS baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
     ELSE
-        OPEN curs FOR SELECT sites.id AS siteid, sites.baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND webpages.suburl LIKE _suburl||'%' AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
+        OPEN curs FOR SELECT sites.id AS siteid, sites.hostname AS baseurl, webpages.suburl, ts_rank_cd(fti,tsq) * relprio AS ts_rank_cd FROM webpages INNER JOIN sites ON webpages.site=sites.id WHERE fti @@ tsq AND site=1 AND webpages.suburl LIKE _suburl||'%' AND (includeinternal OR NOT isinternal) ORDER BY ts_rank_cd(fti,tsq) * relprio DESC LIMIT 1000;
     END IF;
     LOOP
        FETCH curs INTO hit;
-- 
2.33.1

