From 35249f48e457e726d687c254f1bcb5e663e28770 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 11 Feb 2008 16:21:45 -0600 Subject: [PATCH] more experimental work on grouping with pazpar2 Signed-off-by: Joshua Ferraro --- C4/Search.pm | 29 ++--- etc/pazpar2/MARC21slimUtils.xsl | 65 +++++++++++ etc/pazpar2/koha-biblios.xml | 2 +- etc/pazpar2/marc21-work-groups.xsl | 173 +++++++++++++++++++++++++++++ etc/pazpar2/pazpar2.xml | 4 +- opac/opac-search.pl | 8 +- 6 files changed, 263 insertions(+), 18 deletions(-) create mode 100644 etc/pazpar2/MARC21slimUtils.xsl create mode 100644 etc/pazpar2/marc21-work-groups.xsl diff --git a/C4/Search.pm b/C4/Search.pm index 1968622820..e586ebf5b3 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -623,6 +623,7 @@ sub pazGetRecords { my $paz = C4::Search::PazPar2->new('http://localhost:10006/search.pz2'); $paz->init(); + #die $simple_query; $paz->search($simple_query); sleep 1; @@ -635,6 +636,7 @@ sub pazGetRecords { HIT: foreach my $hit (@{ $results->{'hit'} }) { warn "hit"; my $recid = $hit->{recid}->[0]; + my $work_title = $hit->{'md-work-title'}->[0]; #if ($recid =~ /[\200-\377]/) { if ($recid =~ /sodot/) { #die "bad $recid\n"; @@ -650,7 +652,7 @@ sub pazGetRecords { warn "look for $recid offset = $i"; my $rec = $paz->record($recid, $i); warn "got record $i"; - push @{ $results_hashref->{'biblioserver'}->{'RECORDS'} }, $paz->record($recid, $i); + push @{ $results_hashref->{'biblioserver'}->{$work_title}->{'RECORDS'} }, $paz->record($recid, $i); } } warn "past hits"; @@ -659,18 +661,19 @@ sub pazGetRecords { my $termlist_xml = $paz->termlist('author,subject'); my $terms = XMLin($termlist_xml, forcearray => 1); my @facets_loop = (); - foreach my $list (sort keys %{ $terms->{'list'} }) { - my @facets = (); - foreach my $facet (sort @{ $terms->{'list'}->{$list}->{'term'} } ) { - push @facets, { - facet_label_value => $facet->{'name'}->[0], - }; - } - push @facets_loop, ( { - type_label => $list, - facets => \@facets, - } ); - } + #die Dumper($results); +# foreach my $list (sort keys %{ $terms->{'list'} }) { +# my @facets = (); +# foreach my $facet (sort @{ $terms->{'list'}->{$list}->{'term'} } ) { +# push @facets, { +# facet_label_value => $facet->{'name'}->[0], +# }; +# } +# push @facets_loop, ( { +# type_label => $list, +# facets => \@facets, +# } ); +# } return ( undef, $results_hashref, \@facets_loop ); } diff --git a/etc/pazpar2/MARC21slimUtils.xsl b/etc/pazpar2/MARC21slimUtils.xsl new file mode 100644 index 0000000000..27c40eeb71 --- /dev/null +++ b/etc/pazpar2/MARC21slimUtils.xsl @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/etc/pazpar2/koha-biblios.xml b/etc/pazpar2/koha-biblios.xml index 2872b2a8ea..b1a7a003be 100644 --- a/etc/pazpar2/koha-biblios.xml +++ b/etc/pazpar2/koha-biblios.xml @@ -25,6 +25,6 @@ - + diff --git a/etc/pazpar2/marc21-work-groups.xsl b/etc/pazpar2/marc21-work-groups.xsl new file mode 100644 index 0000000000..b7dab22236 --- /dev/null +++ b/etc/pazpar2/marc21-work-groups.xsl @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + electronic resource + + + article + + + book + + + + + + + + + + adfgkmnoprs + + + + + + + adfgkmnoprs + + + + + + + + + + abnp + + + + + + + + + + + + + + + + + + + + + abcd + + + + + + + + titlekey + + + namemainentry + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/pazpar2/pazpar2.xml b/etc/pazpar2/pazpar2.xml index 81a887b606..59a4911b3a 100644 --- a/etc/pazpar2/pazpar2.xml +++ b/etc/pazpar2/pazpar2.xml @@ -37,7 +37,7 @@ - + @@ -52,7 +52,7 @@ - diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 30075eed7b..30dc8a1542 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -306,7 +306,7 @@ if (C4::Context->preference('NoZebra')) { }; } else { eval { - ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan); + ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan); }; } if ($@ || $error) { @@ -323,7 +323,11 @@ for (my $i=0;$i<=@servers;$i++) { if ($server =~/biblioserver/) { # this is the local bibliographic server $hits = $results_hashref->{$server}->{"hits"}; my $page = $cgi->param('page') || 0; - my @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}}); + my @newresults; + for my $work_title (keys %{ $results_hashref->{$server} }) { + next if $work_title eq "hits"; + push @newresults, searchResults( $query_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{$work_title}->{"RECORDS"}}); + } $total = $total + $results_hashref->{$server}->{"hits"}; if ($hits) { $template->param(total => $hits); -- 2.39.5