From 9278e2165d83fa0e5c17027ad9a498c17efdcdbd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 26 Feb 2020 14:30:17 +0000 Subject: [PATCH] Bug 24155: Make wieghting 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 Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Bob Bennhoff --- catalogue/search.pl | 3 ++- cataloguing/addbooks.pl | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt | 10 +++++++--- koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 1 + koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt | 4 ++++ opac/opac-search.pl | 3 ++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 756dd4c2a4..af822bf652 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -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'); diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl index bd7961ffb3..fdc04b2c2e 100755 --- a/cataloguing/addbooks.pl +++ b/cataloguing/addbooks.pl @@ -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'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index 8c555441e1..afde713912 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -93,9 +93,13 @@
Search for - [% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %] - - + [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %] + [% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %] + + + [% END %] + + [% END %] [% FOREACH search_box IN search_boxes_loop %] [% IF ( search_boxes_label ) %]
[% ELSE %]
[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index c1f8b0d82b..35ba5b9f51 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -158,6 +158,7 @@