[open-ils-commits] r15549 - branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Search (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 16 10:41:42 EST 2010
Author: miker
Date: 2010-02-16 10:41:40 -0500 (Tue, 16 Feb 2010)
New Revision: 15549
Modified:
branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Log:
Backporting 15547: ARG! attempted support for search term containing colons ended up breaking multiclass searching
Modified: branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2010-02-16 15:40:36 UTC (rev 15548)
+++ branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2010-02-16 15:41:40 UTC (rev 15549)
@@ -563,12 +563,28 @@
$logger->debug("cleansed query string => $query");
my $search = $arghash->{searches} = {};
- while ($query =~ s/((?:keyword(?:\|\w+)?|title(?:\|\w+)?|author(?:\|\w+)?|subject(?:\|\w+)?|series(?:\|\w+)?|site|dir|sort|lang|available):.+?)$//so) {
+ my $simple_class_re = qr/((?:\w+(?:\|\w+)?):[^:]+?)$/;
+ my $class_list_re = qr/(?:keyword|title|author|subject|series)/;
+ my $modifier_list_re = qr/(?:site|dir|sort|lang|available)/;
+
+ my $tmp_value = '';
+ while ($query =~ s/$simple_class_re//so) {
+
my $qpart = $1;
my $where = index($qpart,':');
my $type = substr($qpart, 0, $where++);
my $value = substr($qpart, $where);
+ if ($type !~ /^(?:$class_list_re|$modifier_list_re)/o) {
+ $tmp_value = "$qpart $tmp_value";
+ next;
+ }
+
+ if ($type =~ /$class_list_re/o ) {
+ $value .= $tmp_value;
+ $tmp_value = '';
+ }
+
next unless $type and $value;
$value =~ s/^\s*//og;
@@ -607,8 +623,11 @@
}
}
+ $query .= " $tmp_value";
+
if($query) {
- # This is the front part of the string before any special tokens were parsed.
+ # This is the front part of the string before any special tokens were
+ # parsed OR colon-separated strings that do not denote a class.
# Add this data to the default search class
my $type = $arghash->{default_class} || 'keyword';
$type = ($type eq '-') ? 'keyword' : $type;
More information about the open-ils-commits
mailing list