Adding autotruncation
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 2 Sep 2009 13:30:12 +0000 (15:30 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 16 Sep 2009 21:19:31 +0000 (23:19 +0200)
Allow autotruncation to be set on its own
This simply reprocess operands in order to add * at lefthandside
It is a problem with non LTR scripts. But works fine with all the latin scripts

Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
C4/Search.pm

index 7c7cb7b..d78f407 100644 (file)
@@ -910,16 +910,6 @@ sub buildQuery {
                 # Some helpful index variants
                 my $index_plus       = $index . $struct_attr . ":" if $index;
                 my $index_plus_comma = $index . $struct_attr . "," if $index;
-                if ($auto_truncation){
-#                                      FIXME Auto Truncation is only valid for LTR languages
-#                                      use C4::Output;
-#                                      use C4::Languages qw(regex_lang_subtags get_bidi);
-#                              $lang = $query->cookie('KohaOpacLanguage') if (defined $query && $query->cookie('KohaOpacLanguage'));
-#                                  my $current_lang = regex_lang_subtags($lang);
-#                                  my $bidi;
-#                                  $bidi = get_bidi($current_lang->{script}) if $current_lang->{script};
-                                       $index_plus_comma .= "rtrn:";
-                               }
 
                 # Remove Stopwords
                 if ($remove_stopwords) {
@@ -930,6 +920,14 @@ sub buildQuery {
                       if ( $stopwords_removed && $DEBUG );
                 }
 
+                if ($auto_truncation){
+                                       #FIXME only valid with LTR scripts
+                                       $operand=join(" ",map{ 
+                                                                                       "$_*" 
+                                                                            }split (/\s+/,$operand));
+                       warn $operand if $DEBUG;
+                               }
+
                 # Detect Truncation
                 my $truncated_operand;
                 my( $nontruncated, $righttruncated, $lefttruncated,