Skip to content

Commit d1419f8

Browse files
committed
Bug 908387: product/component searching should sort hits on product/component name before hits on descriptions
1 parent 014dc85 commit d1419f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

extensions/ProdCompSearch/lib/WebService.pm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ sub prod_comp_search {
9292
push @terms, _build_terms($component, 0, 1);
9393
push @order, "products.name != " . $dbh->quote($product) if $product ne '';
9494
push @order, "components.name != " . $dbh->quote($component) if $component ne '';
95+
push @order, _build_like_order($product . ' ' . $component);
9596
push @order, "products.name";
9697
push @order, "components.name";
9798
} else {
9899
push @terms, _build_terms($search, 1, 1);
99100
push @order, "products.name != " . $dbh->quote($search);
100101
push @order, "components.name != " . $dbh->quote($search);
102+
push @order, _build_like_order($search);
101103
push @order, "products.name";
102104
push @order, "components.name";
103105
}
@@ -147,4 +149,17 @@ sub _build_terms {
147149
return @terms;
148150
}
149151

152+
sub _build_like_order {
153+
my ($query) = @_;
154+
my $dbh = Bugzilla->dbh;
155+
156+
my @terms;
157+
foreach my $word (split(/[\s,]+/, $query)) {
158+
push @terms, "CONCAT(products.name, components.name) LIKE " . $dbh->quote('%' . $word . '%')
159+
if $word ne '';
160+
}
161+
162+
return 'NOT(' . join(' AND ', @terms) . ')';
163+
}
164+
150165
1;

0 commit comments

Comments
 (0)