From 6f937e333105e3e0c573d4a719c8be941296151a Mon Sep 17 00:00:00 2001 From: dbs Date: Mon, 20 Sep 2010 20:22:34 +0000 Subject: [PATCH] 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/branches/rel_1_6@17847 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 750dc248c8..2fb8b7710a 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -553,12 +553,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 = $arghash->{searches} = {}; -- 2.11.0