use Koha::DateUtils;
use Koha::Libraries;
use Lingua::Stem;
-use C4::Search::PazPar2;
use XML::Simple;
use C4::XSLT;
use C4::Reserves; # GetReserveStatus
use Koha::Libraries;
use Koha::Patrons;
use Koha::RecordProcessor;
-use YAML;
use URI::Escape;
use Business::ISBN;
use MARC::Record;
$result->{title} =~ s /\(//g;
$result->{title} =~ s /\)//g;
- # FIXME: instead of removing operators, could just do
- # quotes around the value
- $result->{title} =~ s/(and|or|not)//g;
$query = "$titleindex:\"$result->{title}\"";
if ( $result->{author} ) {
$result->{author} =~ s /\\//g;
$result->{author} =~ s /\(//g;
$result->{author} =~ s /\)//g;
- # remove valid operators
- $result->{author} =~ s/(and|or|not)//g;
$query .= " $op $authorindex:\"$result->{author}\"";
}
}
return $facets_info;
}
-sub pazGetRecords {
- my (
- $koha_query, $simple_query, $sort_by_ref, $servers_ref,
- $results_per_page, $offset, $branches, $query_type,
- $scan
- ) = @_;
- #NOTE: Parameter $branches is not used here !
-
- my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url'));
- $paz->init();
- $paz->search($simple_query);
- sleep 1; # FIXME: WHY?
-
- # do results
- my $results_hashref = {};
- my $stats = XMLin($paz->stat);
- my $results = XMLin($paz->show($offset, $results_per_page, 'work-title:1'), forcearray => 1);
-
- # for a grouped search result, the number of hits
- # is the number of groups returned; 'bib_hits' will have
- # the total number of bibs.
- $results_hashref->{'biblioserver'}->{'hits'} = $results->{'merged'}->[0];
- $results_hashref->{'biblioserver'}->{'bib_hits'} = $stats->{'hits'};
-
- HIT: foreach my $hit (@{ $results->{'hit'} }) {
- my $recid = $hit->{recid}->[0];
-
- my $work_title = $hit->{'md-work-title'}->[0];
- my $work_author;
- if (exists $hit->{'md-work-author'}) {
- $work_author = $hit->{'md-work-author'}->[0];
- }
- my $group_label = (defined $work_author) ? "$work_title / $work_author" : $work_title;
-
- my $result_group = {};
- $result_group->{'group_label'} = $group_label;
- $result_group->{'group_merge_key'} = $recid;
-
- my $count = 1;
- if (exists $hit->{count}) {
- $count = $hit->{count}->[0];
- }
- $result_group->{'group_count'} = $count;
-
- for (my $i = 0; $i < $count; $i++) {
- # FIXME -- may need to worry about diacritics here
- my $rec = $paz->record($recid, $i);
- push @{ $result_group->{'RECORDS'} }, $rec;
- }
-
- push @{ $results_hashref->{'biblioserver'}->{'GROUPS'} }, $result_group;
- }
-
- # pass through facets
- my $termlist_xml = $paz->termlist('author,subject');
- my $terms = XMLin($termlist_xml, forcearray => 1);
- my @facets_loop = ();
- #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 );
-}
-
# TRUNCATION
sub _detect_truncation {
my ( $operand, $index ) = @_;
warn "FIELD WEIGHTED OPERAND: >$weighted_operand<" if $DEBUG;
+ #Use relevance ranking when not using a weighted query (which adds relevance ranking of its own)
+
+ #N.B. Truncation is mutually exclusive with Weighted Queries,
+ #so even if QueryWeightFields is turned on, QueryAutoTruncate will turn it off, thus
+ #the need for this relevance wrapper.
+ $operand = "(rk=($operand))" unless $weight_fields;
+
($query,$query_cgi,$query_desc,$previous_operand) = _build_initial_query({
query => $query,
query_cgi => $query_cgi,
$onloan_items->{$key}->{due_date} = $item->{onloan};
$onloan_items->{$key}->{count}++ if $item->{$hbranch};
$onloan_items->{$key}->{branchname} = $item->{branchname};
- $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} };
+ $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location};
$onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
$onloan_items->{$key}->{description} = $item->{description};
$onloan_items->{$key}->{imageurl} =