From 8bf953a617228083378d9d924e29834855bbb978 Mon Sep 17 00:00:00 2001 From: dbs Date: Wed, 22 Sep 2010 02:12:32 +0000 Subject: [PATCH] Forward port r17847: 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@17883 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 98ffbf626f..7dad749036 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -689,12 +689,13 @@ sub multiclass_query { $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 = {}; -- 2.11.0