Improve PostgreSQL serach a little

This commit is contained in:
Michał Gątkowski 2022-08-07 22:14:26 +02:00
parent 82ca499e32
commit c1f5815b4b

View File

@ -229,10 +229,15 @@ func (db *postgresDatabase) QueryTorrents(
{{ else }}
similarity(name, '{{ .Query }}') * -1
{{ end }}
{{GTEorLTE .Ascending}} {{.LastOrderedValue}}
{{ if .QueryExists }} AND {{ end }}
{{GTEorLTE .Ascending}} {{.LastOrderedValue}}
{{ if .QueryExists }}
AND
{{ end }}
{{ end }}
{{ if and .QueryExists .FirstPage }} WHERE {{ end }}
{{ if .QueryExists }}
to_tsvector(replace(replace(name, '.', ' '), '-', ' ')) @@ plainto_tsquery('{{ .Query }}')
{{ end }}
{{ if and .QueryExists .FirstPage }} WHERE {{ end }}{{ if .QueryExists }} to_tsvector(replace(name, '.', ' ')) @@ plainto_tsquery('{{ .Query }}') {{ end }}
ORDER BY {{.OrderOn}} {{AscOrDesc .Ascending}}
LIMIT {{.Limit}};
`, struct {