new port-search wildcarding - bad idea?
* for an exact match use "quoting", a bit like what Google does to enforce a search term * otherwise terms are assumed to be wildcard bounded and case insensitive * without quotes, * and ? characters are supported for multi and single character wildcards. we could revert this commit if we don't like it.
This commit is contained in:
@@ -31,9 +31,19 @@ ajax '/ajax/content/device/ports' => require_login sub {
|
||||
return unless $set->count;
|
||||
}
|
||||
else {
|
||||
$f =~ s/\*/%/g if index($f, '*') >= 0;
|
||||
$f =~ s/\?/_/g if index($f, '?') >= 0;
|
||||
$f = { '-ilike' => $f };
|
||||
# Google-style search. Quoted means exact, otherwise wildcard.
|
||||
# but still supoort manual wildcarding.
|
||||
if ($f =~ m/^['"]/ and $f =~ m/['"]$/) {
|
||||
$f =~ s/^['"]//;
|
||||
$f =~ s/['"]$//;
|
||||
}
|
||||
else {
|
||||
$f =~ s/\*/%/g;
|
||||
$f =~ s/\?/_/g;
|
||||
$f =~ s/^\%*/%/;
|
||||
$f =~ s/\%*$/%/;
|
||||
$f = { '-ilike' => $f };
|
||||
}
|
||||
|
||||
if ($set->search({'me.port' => $f})->count) {
|
||||
$set = $set->search({'me.port' => $f});
|
||||
|
||||
Reference in New Issue
Block a user