kmain-384_matches_exactly_dollar_sign
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:06:49 +0000 (17:06 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: b82547b

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm

index 2978fff..f62f06e 100644 (file)
@@ -42,6 +42,8 @@ sub _prepare_biblio_search_basics {
             $jtitle = 1;
         }
 
+               $logger->debug("kmain384 query before: " . $query);
+
         # This stuff probably will need refined or rethought to better handle
         # the weird things Real Users will surely type in.
         $contains = "" unless defined $contains; # silence warning
@@ -53,11 +55,26 @@ sub _prepare_biblio_search_basics {
             $query =~ s/"//g;
             $query = ('"' . $query . '"') if index $query, ' ';
         } elsif ($contains eq 'exact') {
-            $query =~ s/[\^\$]//g;
+                       $query =~ s/"//g;
+                       
+                       # This allows searches that end with $ or start with ^
+                       if ($query =~ m/^\^/ && $query =~ m/\$$/ ){
+                               
+                               $query =~ s/^\^//g;
+                               $query =~ s/\$$//g;
+                       }
+            
+            $query =~ s/\^/\^/g;
+            $query =~ s/\$/\$/g;
+            #$query = '$VERY_UNIQUE_STRING$' . $query . '$VERY_UNIQUE_STRING$';
             $query = '^' . $query . '$';
         } elsif ($contains eq 'starts') {
             $query =~ s/"//g;
-            $query =~ s/[\^\$]//g;
+            $query =~ s/^\^//g;
+            $query =~ s/\$$//g;
+            $query =~ s/\^/\^/g;
+            $query =~ s/\$/\$/g;
+            #$query = '$VERY_UNIQUE_STRING$' . $query . '$VERY_UNIQUE_STRING$';
             $query = '^' . $query;
             $query = ('"' . $query . '"') if index $query, ' ';
         }
@@ -69,6 +86,8 @@ sub _prepare_biblio_search_basics {
 
         $query = "$qtype:$query" unless $qtype eq 'keyword' and $i == 0;
 
+               $logger->debug("kmain384 query after: " . $query);
+
         $bool = ($bool and $bool eq 'or') ? '||' : '&&';
         $full_query = $full_query ? "($full_query $bool $query)" : $query;
     }