[open-ils-commits] r17847 - branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Search (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Sep 20 16:22:40 EDT 2010


Author: dbs
Date: 2010-09-20 16:22:34 -0400 (Mon, 20 Sep 2010)
New Revision: 17847

Modified:
   branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Log:
Make query parser a bit more careful when converting convenience classes to search classes

Queries like "Heart disease: a global problem" were getting converted to series searches
due to the trailing "se:" in the search terms. This change ensures that the convenience
class is either at the start of the input or preceded by whitespace.


Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2010-09-20 19:14:28 UTC (rev 17846)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2010-09-20 20:22:34 UTC (rev 17847)
@@ -553,12 +553,13 @@
     $query =~ s/^\s+//go;
 
     # convert convenience classes (e.g. kw for keyword) to the full class name
-    $query =~ s/kw(:|\|)/keyword$1/go;
-    $query =~ s/ti(:|\|)/title$1/go;
-    $query =~ s/au(:|\|)/author$1/go;
-    $query =~ s/su(:|\|)/subject$1/go;
-    $query =~ s/se(:|\|)/series$1/go;
-    $query =~ s/name(:|\|)/author$1/og;
+    # ensure that the convenience class isn't part of a word (e.g. 'playhouse')
+    $query =~ s/(^|\s)kw(:|\|)/$1keyword$2/go;
+    $query =~ s/(^|\s)ti(:|\|)/$1title$2/go;
+    $query =~ s/(^|\s)au(:|\|)/$1author$2/go;
+    $query =~ s/(^|\s)su(:|\|)/$1subject$2/go;
+    $query =~ s/(^|\s)se(:|\|)/$1series$2/go;
+    $query =~ s/(^|\s)name(:|\|)/$1author$2/og;
 
     $logger->debug("cleansed query string => $query");
     my $search = $arghash->{searches} = {};



More information about the open-ils-commits mailing list