bug 744687: fix multi-field MARC expert search
authorgmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 29 Mar 2011 02:06:43 +0000 (02:06 +0000)
committergmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 29 Mar 2011 02:06:43 +0000 (02:06 +0000)
Fixes bug where a bib that has multiple subfields
meeting one condition of a 2+ field MARC expert
search could end up in the results list even if
it didn't meet the other conditions (currently multi-field
MARC expert searches use implicit 'AND').

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19880 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index ede8cd0..e14cca5 100644 (file)
@@ -458,7 +458,7 @@ sub biblio_multi_search_full_rec {
                }
                my $where = join(' OR ', @wheres);
 
-               push @selects, "SELECT id, record, $rank as sum FROM $search_table WHERE $where";
+               push @selects, "SELECT record, AVG($rank) as sum FROM $search_table WHERE $where GROUP BY record";
 
        }
 
@@ -475,7 +475,7 @@ sub biblio_multi_search_full_rec {
        my $cl_table = asset::copy_location->table;
        my $br_table = biblio::record_entry->table;
 
-       my $cj = 'HAVING COUNT(x.id) = ' . scalar(@selects) if ($class_join eq 'AND');
+       my $cj = 'HAVING COUNT(x.record) = ' . scalar(@selects) if ($class_join eq 'AND');
        my $search_table =
                '(SELECT x.record, sum(x.sum) FROM (('.
                        join(') UNION ALL (', @selects).