summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-04-19 00:42:21 -0700
committerIvan Kohler <ivan@freeside.biz>2013-04-19 00:42:21 -0700
commit110a9f8a594aa5cf5ac1cc9c91aee90fea67c949 (patch)
treeca40a3f06124b8112a6e2877e16c7c565b4d0d69
parentcd4196b482d216fe8a0e132d2e156134a3b56407 (diff)
add fuzzy-fuzziness config, RT#22519
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/cust_main/Search.pm7
2 files changed, 13 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 76f29bd59..6a19ff475 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3823,6 +3823,13 @@ and customer address. Include units.',
'type' => 'checkbox',
},
+ {
+ 'key' => 'fuzzy-fuzziness',
+ 'section' => 'UI',
+ 'description' => 'Set the "fuzziness" of fuzzy searching (see the String::Approx manpage for details). Defaults to 10%',
+ 'type' => 'text',
+ },
+
{ 'key' => 'pkg_referral',
'section' => '',
'description' => 'Enable package-specific advertising sources.',
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 9ec40cdd3..7dbb7a859 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -954,6 +954,11 @@ sub fuzzy_search {
my @cust_main = ();
+ my @fuzzy_mod = 'i';
+ my $conf = new FS::Conf;
+ my $fuzziness = $conf->config('fuzzy-fuzziness');
+ push @fuzzy_mod, $fuzziness if $fuzziness;
+
check_and_rebuild_fuzzyfiles();
foreach my $field ( keys %$fuzzy ) {
@@ -961,7 +966,7 @@ sub fuzzy_search {
next unless scalar(@$all);
my %match = ();
- $match{$_}=1 foreach ( amatch( $fuzzy->{$field}, ['i'], @$all ) );
+ $match{$_}=1 foreach ( amatch( $fuzzy->{$field}, \@fuzzy_mod, @$all ) );
next if !keys(%match);
my $in_matches = 'IN (' .