Bug 24155: Make weighting an option on advanced search
Currently we apply weighting to all searches except advanced search. The theory being that when selecting indexes we don't want to apply weights. When searching in ES weights are only applied to relevant results so it doesn't matter. i.e. if weighting author*100 but searching subject, a term matching the subject search in author is not boosted. Given this, we should always apply weights, unless the user wishes not to To test: 1 - Set some weighting 2 - Do some searches 3 - Note your terms and results, try advanced and regular searches specifying indexes or not 4 - Apply patch 5 - Note that opac and staff advanced search have option to apply weights 6 - Compare searches after the patch to see how weighting affects, it should be beneficial or not at all Signed-off-by: Myka Kennedy Stephens <mkstephens@lancasterseminary.edu> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Bob Bennhoff <bbennhoff@clicweb.org> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
88f34a3554
commit
e474df6402
|
|
@ -427,6 +427,7 @@ my $count = C4::Context->preference('numSearchResults') || 20;
|
|||
my $results_per_page = $params->{'count'} || $count;
|
||||
my $offset = $params->{'offset'} || 0;
|
||||
my $whole_record = $params->{'whole_record'} || 0;
|
||||
my $weight_search = $params->{'weight_search'} || 0;
|
||||
$offset = 0 if $offset < 0;
|
||||
my $page = $cgi->param('page') || 1;
|
||||
#my $offset = ($page-1)*$results_per_page;
|
||||
|
|
@ -446,7 +447,7 @@ my $searcher = Koha::SearchEngine::Search->new(
|
|||
$query_type
|
||||
)
|
||||
= $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
|
||||
\@sort_by, $scan, $lang, { weighted_fields => !$cgi->param('advsearch'), whole_record => $whole_record });
|
||||
\@sort_by, $scan, $lang, { weighted_fields => $weight_search, whole_record => $whole_record });
|
||||
|
||||
$template->param( search_query => $query ) if C4::Context->preference('DumpSearchQueryTemplate');
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ if ($query) {
|
|||
my $searcher = Koha::SearchEngine::Search->new(
|
||||
{ index => $Koha::SearchEngine::BIBLIOS_INDEX } );
|
||||
( undef, $builtquery, undef, $query_cgi, undef, undef, undef, undef, undef, undef ) =
|
||||
$builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang );
|
||||
$builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang, { weighted_fields => 1 });
|
||||
|
||||
$template->param( search_query => $builtquery ) if C4::Context->preference('DumpSearchQueryTemplate');
|
||||
|
||||
|
|
|
|||
|
|
@ -93,9 +93,13 @@
|
|||
<!-- BOOLEAN SEARCH OPTIONS -->
|
||||
<fieldset id="searchterms">
|
||||
<legend>Search for </legend>
|
||||
[% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
|
||||
<input type="checkbox" name="whole_record">
|
||||
<label for="whole_record">Search entire MARC record</label>
|
||||
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
|
||||
[% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
|
||||
<input type="checkbox" name="whole_record">
|
||||
<label for="whole_record">Search entire MARC record</label>
|
||||
[% END %]
|
||||
<input type="checkbox" name="weight_search" checked>
|
||||
<label for="weight_search">Apply field weightings to search</label>
|
||||
[% END %]
|
||||
[% FOREACH search_box IN search_boxes_loop %]
|
||||
[% IF ( search_boxes_label ) %]<div style="text-indent: 4.5em;">[% ELSE %]<div>[% END %]
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@
|
|||
<div id="opac-main-search">
|
||||
[% IF Koha.Preference('OpacCustomSearch') == '' %]
|
||||
<form name="searchform" method="get" action="/cgi-bin/koha/opac-search.pl" id="searchform">
|
||||
<input type="hidden" name="weight_search" value="1">
|
||||
<div class="form-row align-items-center">
|
||||
<div class="col-sm-auto order-1 order-sm-1">
|
||||
<label for="masthead_search"> Search
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@
|
|||
<div id="booleansearch" class="maincontent">
|
||||
<fieldset>
|
||||
<legend>Search for:</legend>
|
||||
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
|
||||
<input type="checkbox" name="weight_search" checked>
|
||||
<label for="weighted_search">Apply field weightings to search</label>
|
||||
[% END %]
|
||||
[% IF ( expanded_options ) %]
|
||||
<div class="advanced-search-terms extended">
|
||||
[% ELSE %]
|
||||
|
|
|
|||
|
|
@ -532,6 +532,7 @@ $offset = 0 if $offset < 0;
|
|||
my $page = $cgi->param('page') || 1;
|
||||
$offset = ($page-1)*$results_per_page if $page>1;
|
||||
my $hits;
|
||||
my $weight_search = $cgi->param('weight_search') || 0;
|
||||
|
||||
# Define some global variables
|
||||
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
|
||||
|
|
@ -562,7 +563,7 @@ if (C4::Context->preference('OpacSuppression')) {
|
|||
{
|
||||
suppress => $suppress,
|
||||
is_opac => 1,
|
||||
weighted_fields => !$cgi->param('advsearch')
|
||||
weighted_fields => $weight_search
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue