Bug 21719: Fix typos
[srvgit] / catalogue / search.pl
index 7e2e300..af70dac 100755 (executable)
@@ -94,7 +94,7 @@ weighting, koha-specific relevance ranking, and stemming. When I have a chance
 I'll try to flesh out this section to better explain.
 
 This query incorporates query profiles that aren't compatible with most non-Zebra 
-Z39.50 targets to acomplish the field weighting and relevance ranking.
+Z39.50 targets to accomplish the field weighting and relevance ranking.
 
 =item 2 $simple_query - a simple query that doesn't contain the field weighting,
 stemming, etc., suitable to pass off to other search targets
@@ -155,6 +155,7 @@ use Koha::Patrons;
 use Koha::SearchEngine::Search;
 use Koha::SearchEngine::QueryBuilder;
 use Koha::Virtualshelves;
+use Koha::SearchFields;
 
 use URI::Escape;
 
@@ -293,7 +294,7 @@ if ( $template_type eq 'advsearch' ) {
     # shouldn't appear on the first one, scan indexes should, adding a new
     # box should only appear on the last, etc.
     my @search_boxes_array;
-    my $search_boxes_count = 3; # begin whith 3 boxes
+    my $search_boxes_count = 3; # begin with 3 boxes
     # FIXME: all this junk can be done in TMPL using __first__ and __last__
     for (my $i=1;$i<=$search_boxes_count;$i++) {
         # if it's the first one, don't display boolean option, but show scan indexes
@@ -383,7 +384,7 @@ my @indexes = map uri_unescape($_), $cgi->multi_param('idx');
 # if a simple index (only one)  display the index used in the top search box
 if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
     my $idx = "ms_".$indexes[0];
-    $idx =~ s/\,/comma/g;  # template toolkit doesnt like variables with a , in it
+    $idx =~ s/\,/comma/g;  # template toolkit doesn't like variables with a , in it
     $template->param($idx => 1);
 }
 
@@ -455,6 +456,11 @@ my $expanded_facet = $params->{'expand'};
 # Define some global variables
 my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
 
+my $build_params;
+unless ( $cgi->param('advsearch') ) {
+    $build_params->{weighted_fields} = 1;
+}
+
 my $builder = Koha::SearchEngine::QueryBuilder->new(
     { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
 my $searcher = Koha::SearchEngine::Search->new(
@@ -467,7 +473,7 @@ my $searcher = Koha::SearchEngine::Search->new(
     $query_type
   )
   = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
-    \@sort_by, $scan, $lang );
+    \@sort_by, $scan, $lang, $build_params );
 
 ## parse the query_cgi string and put it into a form suitable for <input>s
 my @query_inputs;
@@ -541,7 +547,7 @@ for (my $i=0;$i<@servers;$i++) {
     if ($server =~/biblioserver/) { # this is the local bibliographic server
         my $hits = $results_hashref->{$server}->{"hits"} // 0;
         my $page = $cgi->param('page') || 0;
-        my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
+        my @newresults = searchResults({ 'interface' => 'intranet' }, $query_desc, $hits, $results_per_page, $offset, $scan,
                                        $results_hashref->{$server}->{"RECORDS"});
         $total = $total + $hits;
 
@@ -619,7 +625,9 @@ for (my $i=0;$i<@servers;$i++) {
             ## FIXME: add a global function for this, it's better than the current global one
             ## Build the page numbers on the bottom of the page
             my @page_numbers;
-            my $hits_to_paginate = C4::Context->preference('SearchEngine') eq 'Elasticsearch' ? 10000 : $hits;
+            my $max_result_window = $searcher->max_result_window;
+            my $hits_to_paginate = ($max_result_window && $max_result_window < $hits) ? $max_result_window : $hits;
+            $template->param( hits_to_paginate => $hits_to_paginate );
             # total number of pages there will be
             my $pages = ceil($hits_to_paginate / $results_per_page);
             my $last_page_offset = ( $pages -1 ) * $results_per_page;