LP#1522538: Improper detection of jtitle search type
authorMike Rylander <mrylander@gmail.com>
Thu, 3 Dec 2015 21:13:09 +0000 (16:13 -0500)
committerKathy Lussier <klussier@masslnc.org>
Wed, 13 Jan 2016 13:44:51 +0000 (08:44 -0500)
Before this change, the system would only check the first qtype URL parameter
to see if it needed to apply the journal title "bib_level(s)" filter.  Instead
it should check each qtype in turn while it turns an advanced search into a
simple search string.  Here the code is moved into place to accomplish that.

To test, load all test datasets into a fresh database.  Perform an advanced
search on journal title for "proceedings" (no quotes) using the second search
input row.  Before this commit, two records are retrieved.  After, only one
is retrieved.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm

index ccd8471..ecd1bad 100644 (file)
@@ -26,8 +26,10 @@ sub _prepare_biblio_search_basics {
         next unless $query =~ /\S/;
 
         # Hack for journal title
+        my $jtitle = 0;
         if ($qtype eq 'jtitle') {
             $qtype = 'title';
+            $jtitle = 1;
         }
 
         # This stuff probably will need refined or rethought to better handle
@@ -49,6 +51,12 @@ sub _prepare_biblio_search_basics {
             $query = '^' . $query;
             $query = ('"' . $query . '"') if index $query, ' ';
         }
+
+        # Journal title hackery complete
+        if ($jtitle) {
+            $query = "bib_level(s) $query";
+        }
+
         $query = "$qtype:$query" unless $qtype eq 'keyword' and $i == 0;
 
         $bool = ($bool and $bool eq 'or') ? '||' : '&&';
@@ -91,11 +99,6 @@ sub _prepare_biblio_search {
         $query = "container(bre,bookbag," . int($cgi->param("bookbag")) . ") $query";
     }
 
-    # Journal title hackery complete
-    if ($cgi->param("qtype") && $cgi->param("qtype") eq "jtitle") {
-        $query = "bib_level(s) $query";
-    }
-
     if ($cgi->param('pubdate') && $cgi->param('date1')) {
         if ($cgi->param('pubdate') eq 'between') {
             my $btw = 'between(' . $cgi->param('date1');