fixing rank breakage
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 28 Feb 2006 03:33:19 +0000 (03:33 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 28 Feb 2006 03:33:19 +0000 (03:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3221 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm

index c9a12cb..3c6dd18 100644 (file)
@@ -1026,23 +1026,25 @@ sub postfilter_search_class_fts {
        my $rank = $relevance;
        if (lc($sort) eq 'pubdate') {
                $rank = <<"             RANK";
-                       (
-                               SELECT  FIRST(COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'9999')::INT)
+                       ( FIRST ((
+                               SELECT  COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'9999')::INT
                                  FROM  $metabib_full_rec frp
                                  WHERE frp.record = mr.master_record
                                        AND frp.tag = '260'
                                        AND frp.subfield = 'c'
-                       )
+                                 LIMIT 1
+                       )) )
                RANK
        } elsif (lc($sort) eq 'title') {
                $rank = <<"             RANK";
-                       (
-                               SELECT  FIRST(COALESCE(LTRIM(SUBSTR( frt.value, frt.ind2::text::int )),'zzzzzzzz'))
+                       ( FIRST ((
+                               SELECT  COALESCE(LTRIM(SUBSTR( frt.value, frt.ind2::text::int )),'zzzzzzzz')
                                  FROM  $metabib_full_rec frt
                                  WHERE frt.record = mr.master_record
                                        AND frt.tag = '245'
                                        AND frt.subfield = 'a'
-                       )
+                                 LIMIT 1
+                       )) )
                RANK
        } elsif (lc($sort) eq 'author') {
                $rank = <<"             RANK";
@@ -1052,7 +1054,7 @@ sub postfilter_search_class_fts {
                                  WHERE fra.record = mr.master_record
                                        AND fra.tag LIKE '1%'
                                        AND fra.subfield = 'a'
-                                       ORDER BY fra.tag::text::int
+                                 ORDER BY fra.tag::text::int
                                  LIMIT 1
                        )) )
                RANK
@@ -1349,22 +1351,24 @@ sub postfilter_search_multi_class_fts {
        my $rank = $relevance;
        if (lc($sort) eq 'pubdate') {
                $rank = <<"             RANK";
-                       (
-                               SELECT  FIRST(COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'9999')::INT)
+                       ( FIRST ((
+                               SELECT  COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'9999')::INT
                                  FROM  $metabib_full_rec frp
                                  WHERE frp.record = mr.master_record
                                        AND frp.tag = '260'
                                        AND frp.subfield = 'c'
-                       )
+                                 LIMIT 1
+                       )) )
                RANK
        } elsif (lc($sort) eq 'title') {
                $rank = <<"             RANK";
-                       (
-                               SELECT  FIRST(COALESCE(LTRIM(SUBSTR( frt.value, frt.ind2::text::int )),'zzzzzzzz'))
+                       ( FIRST ((
+                               SELECT  COALESCE(LTRIM(SUBSTR( frt.value, frt.ind2::text::int )),'zzzzzzzz')
                                  FROM  $metabib_full_rec frt
                                  WHERE frt.record = mr.master_record
                                        AND frt.tag = '245'
                                        AND frt.subfield = 'a'
+                                 LIMIT 1
                        )) )
                RANK
        } elsif (lc($sort) eq 'author') {
@@ -1375,7 +1379,7 @@ sub postfilter_search_multi_class_fts {
                                  WHERE fra.record = mr.master_record
                                        AND fra.tag LIKE '1%'
                                        AND fra.subfield = 'a'
-                                       ORDER BY fra.tag::text::int
+                                 ORDER BY fra.tag::text::int
                                  LIMIT 1
                        )) )
                RANK