From 13c3b5911514e5209e27fa5da5a5d7bd2b925d92 Mon Sep 17 00:00:00 2001
From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Thu, 11 Feb 2010 18:22:32 +0000
Subject: [PATCH] forward-porting r15501: Normalization for ratio-like strings
 -- specifically for map scale ratios; allow the default search class (as
 specified in the basic search dropdown) to target a specific index

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15503 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm                | 5 +++++
 Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm         | 2 +-
 Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/fts.pm | 6 ++++++
 Open-ILS/web/opac/skin/default/js/rresult.js                       | 6 +++++-
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm b/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm
index f794479d90..30892b517b 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm
@@ -900,6 +900,11 @@ sub class_index_string_xml {
             $value =~ s/\pC+//sgo;
             $value =~ s/\W+$//sgo;
 
+            # hack to normalize ratio-like strings
+            while ($term =~ /\b\d{1}:[, ]?\d+(?:[ ,]\d+[^:])+/o) {
+                $term = $` . join ('', split(/[, ]/, $&)) . $';
+            }
+
             $value =~ s/\b\.+\b//sgo;
             $value = lc($value);
 
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
index 0ef938b17c..49bccda695 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
@@ -612,7 +612,7 @@ sub multiclass_query {
         # Add this data to the default search class
         my $type = $arghash->{default_class} || 'keyword';
         $type = ($type eq '-') ? 'keyword' : $type;
-        $type = ($type !~ /^(title|author|keyword|subject|series)$/o) ? 'keyword' : $type;
+        $type = ($type !~ /^(title|author|keyword|subject|series)(?:\|\w+)?$/o) ? 'keyword' : $type;
         $search->{$type} =  {} unless $search->{$type};
         $search->{$type}->{term} =
             ($search->{$type}->{term}) ? $search->{$type}->{term} . " $query" : $query;
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/fts.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/fts.pm
index c7c307a59e..055266a8fe 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/fts.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/fts.pm
@@ -23,6 +23,12 @@
 
 		$term =~ s/(\pM+)//gos;
 		$term =~ s/(\b\.\b)//gos;
+
+		# hack to normalize ratio-like strings
+		while ($term =~ /\b\d{1}:[, ]?\d+(?:[ ,]\d+[^:])+/o) {
+			$term = $` . join ('', split(/[, ]/, $&)) . $';
+		}
+
 		$self->decompose($term);
 
 		my $newterm = '';
diff --git a/Open-ILS/web/opac/skin/default/js/rresult.js b/Open-ILS/web/opac/skin/default/js/rresult.js
index d93aa45471..4a7fb35957 100644
--- a/Open-ILS/web/opac/skin/default/js/rresult.js
+++ b/Open-ILS/web/opac/skin/default/js/rresult.js
@@ -30,7 +30,11 @@ function rresultDoSearch() {
 function rresultCollectIds() {
 	var ids;
 
-	switch(getRtype()) {
+    var rtype = getRtype();
+    if (rtype.indexOf('|') > -1)
+        rtype = rtype.substring(0,rtype.indexOf('|'));
+
+	switch(rtype) {
 
 		case RTYPE_COOKIE:
 			ids = JSON2js(cookieManager.read(COOKIE_RIDS));
-- 
2.11.0