From b88b3f5de8e64fa5cbe69905558402e2704393d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C4=85tkowski?= Date: Mon, 8 Aug 2022 01:16:45 +0200 Subject: [PATCH] Refactor postgres search --- pkg/persistence/postgres.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/persistence/postgres.go b/pkg/persistence/postgres.go index 3665c25..0902be8 100644 --- a/pkg/persistence/postgres.go +++ b/pkg/persistence/postgres.go @@ -236,7 +236,7 @@ func (db *postgresDatabase) QueryTorrents( {{ end }} {{ if and .QueryExists .FirstPage }} WHERE {{ end }} {{ if .QueryExists }} - to_tsvector(replace(replace(name, '.', ' '), '-', ' ')) @@ websearch_to_tsquery('{{ .Query }}') + to_tsvector(regexp_replace(name, '\W+', ' ', 'g')) @@ websearch_to_tsquery('{{ .Query }}') {{ end }} ORDER BY {{.OrderOn}} {{AscOrDesc .Ascending}} LIMIT {{.Limit}};