summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Releases
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-11-18 10:51:58 +0100
committerYorhel <git@yorhel.nl>2021-11-18 10:52:04 +0100
commit5b4bd7befcc80cbaf43c07a356acbd45dfdd5dfa (patch)
tree1fece90a062eb79de5a3060d989225ace66137cb /lib/VNWeb/Releases
parent4a167aaad01fae953ecd72ecccff78ee6248d1fb (diff)
Releases: Experiment with new SQL search implementation
Goal is to use the improved search normalisation mechanism that VN search has had for ages on other database types as well (releases with this commit; producers, staff and characters to come later). Another goal is to do the search cache updates within SQL, removing the Perl search normalization and the round-trip through Multi every time an entry needs to be updated. Requires the 'unaccent' Postgres extension. I considered writing my own unaccent rules file, but decided against it for now. Current approach works pretty well.
Diffstat (limited to 'lib/VNWeb/Releases')
-rw-r--r--lib/VNWeb/Releases/List.pm11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/VNWeb/Releases/List.pm b/lib/VNWeb/Releases/List.pm
index 3f5717a2..a55a7a88 100644
--- a/lib/VNWeb/Releases/List.pm
+++ b/lib/VNWeb/Releases/List.pm
@@ -50,12 +50,11 @@ TUWF::get qr{/r}, sub {
$opt->{f} = advsearch_default 'r' if !$opt->{f}{query} && !defined tuwf->reqGet('f');
- my @search = map {
- my $l = '%'.sql_like($_).'%';
- /^\d+$/ && gtintype($_) ? sql 'r.gtin =', \"$_" :
- length $_ > 0 ? sql '(r.title ILIKE', \$l, 'OR r.original ILIKE', \$l, 'OR r.catalog =', \"$_", ')' : ();
- } split /[ -,._]/, $opt->{q}||'';
- my $where = sql_and 'NOT r.hidden', $opt->{f}->sql_where(), @search;
+ my $where = sql_and 'NOT r.hidden', $opt->{f}->sql_where(),
+ !$opt->{q} ? () : sql_or
+ sql('r.c_search LIKE ALL (search_query(', \$opt->{q}, '))'),
+ $opt->{q} =~ /^\d+$/ && gtintype($opt->{q}) ? sql 'r.gtin =', \$opt->{q} : (),
+ $opt->{q} =~ /^[a-zA-Z0-9-]+$/ ? sql 'r.catalog =', \$opt->{q} : ();
my $time = time;
my($count, $list);