Change naive ILIKE search to full text (unindexed) on lists and campaigns. Closes #1058.

This commit is contained in:
Kailash Nadh 2022-11-27 23:01:15 +05:30
parent 93260396c6
commit 8e3e1b9af8

View file

@ -400,7 +400,7 @@ WITH ls AS (
CASE CASE
WHEN $1 > 0 THEN id = $1 WHEN $1 > 0 THEN id = $1
WHEN $2 != '' THEN uuid = $2::UUID WHEN $2 != '' THEN uuid = $2::UUID
WHEN $3 != '' THEN name ILIKE $3 WHEN $3 != '' THEN to_tsvector(name) @@ to_tsquery ($3)
ELSE true ELSE true
END END
OFFSET $4 LIMIT (CASE WHEN $5 = 0 THEN NULL ELSE $5 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 FROM campaigns c
WHERE ($1 = 0 OR id = $1) 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 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); ORDER BY %s %s OFFSET $4 LIMIT (CASE WHEN $5 = 0 THEN NULL ELSE $5 END);
-- name: get-campaign -- name: get-campaign