(bug #3584) detect ccl queries
[koha.git] / C4 / Matcher.pm
index 210c8fa..512562c 100644 (file)
@@ -661,7 +661,7 @@ sub get_matches {
         # build query
         my $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
         # FIXME only searching biblio index at the moment
-        my ($error, $searchresults) = SimpleSearch($query);
+        my ($error, $searchresults, $total_hits) = SimpleSearch($query, 0, $max_matches);
 
         warn "search failed ($query) $error" if $error;
         foreach my $matched (@$searchresults) {
@@ -786,6 +786,11 @@ sub _get_match_keys {
                     }
                 }
                 $key = _normalize($key);
+                if ($component->{'length'}){
+                   if (length($key) > $component->{'length'}){
+                     $key = _normalize(substr($key,$component->{'offset'},$component->{'length'}));
+                   }
+                }
             }
             if ($i == 0) {
                 push @keys, $key if $key;
@@ -815,10 +820,12 @@ sub _parse_match_component {
 # FIXME - default normalizer
 sub _normalize {
     my $value = uc shift;
+    $value =~ s/.;:,\]\[\)\(\/'"//g;
     $value =~ s/^\s+//;
-    $value =~ s/^\s+$//;
+    #$value =~ s/^\s+$//;
+    $value =~ s/\s+$//;
     $value =~ s/\s+/ /g;
-    $value =~ s/[.;,\]\[\)\(\/"']//g;
+    #$value =~ s/[.;,\]\[\)\(\/"']//g;
     return $value;
 }