From 8e3e1b9af860f10879dda2339f5ca9204d1241db Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 27 Nov 2022 23:01:15 +0530 Subject: [PATCH] Change naive ILIKE search to full text (unindexed) on lists and campaigns. Closes #1058. --- queries.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries.sql b/queries.sql index 7ff286bd4..69d4ecfb6 100644 --- a/queries.sql +++ b/queries.sql @@ -400,7 +400,7 @@ WITH ls AS ( CASE WHEN $1 > 0 THEN id = $1 WHEN $2 != '' THEN uuid = $2::UUID - WHEN $3 != '' THEN name ILIKE $3 + WHEN $3 != '' THEN to_tsvector(name) @@ to_tsquery ($3) ELSE true END OFFSET $4 LIMIT (CASE WHEN $5 = 0 THEN NULL ELSE $5 END) @@ -503,7 +503,7 @@ SELECT c.id, c.uuid, c.name, c.subject, c.from_email, FROM campaigns c WHERE ($1 = 0 OR id = $1) AND status=ANY(CASE WHEN CARDINALITY($2::campaign_status[]) != 0 THEN $2::campaign_status[] ELSE ARRAY[status] END) - AND ($3 = '' OR CONCAT(name, subject) ILIKE $3) + AND ($3 = '' OR TO_TSVECTOR(CONCAT(name, ' ', subject)) @@ TO_TSQUERY($3)) ORDER BY %s %s OFFSET $4 LIMIT (CASE WHEN $5 = 0 THEN NULL ELSE $5 END); -- name: get-campaign