capturing any preceding search terms and appending them to the default search class...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Nov 2007 22:01:45 +0000 (22:01 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Nov 2007 22:01:45 +0000 (22:01 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8069 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm

index 1e7aa4a..86cfdb3 100644 (file)
@@ -463,9 +463,7 @@ sub multiclass_query {
     $query =~ s/name(:|\|)/author$1/og;
 
     $logger->debug("cleansed query string => $query");
-
-    my $search = $arghash->{searches}; 
-    $arghash->{searches} = $search = {} unless $search;
+    my $search = $arghash->{searches} = {};
 
     while ($query =~ s/((?:keyword(?:\|\w+)?|title(?:\|\w+)?|author(?:\|\w+)?|subject(?:\|\w+)?|series(?:\|\w+)?|site|dir|sort|lang|available):[^:]+)$//so) {
         my($type, $value) = split(':', $1);
@@ -503,6 +501,15 @@ sub multiclass_query {
         }
     }
 
+    if($query) {
+        # This is the front part of the string before any special tokens were parsed. 
+        # Add this data to the default search class
+        my $type = $arghash->{default_class} || 'keyword';
+        $search->{$type} =  {} unless $search->{$type};
+        $search->{$type}->{term} =
+            ($search->{$type}->{term}) ? $search->{$type}->{term} . " $query" : $query;
+    }
+
     # capture the original limit because the search method alters the limit internally
     my $ol = $arghash->{limit};
 
@@ -512,7 +519,9 @@ sub multiclass_query {
 
     $arghash->{limit} = $ol if $ol;
     $data->{compiled_search} = $arghash;
+
     $logger->info("compiled search is " . OpenSRF::Utils::JSON->perl2JSON($arghash));
+
     return $data;
 }