Bugzilla – Attachment 99650 Details for
Bug 24155
Weights should be (optionally) applied to Advanced search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24155: Make wieghting an option on advanced search
Bug-24155-Make-wieghting-an-option-on-advanced-sea.patch (text/plain), 6.01 KB, created by
Nick Clemens (kidclamp)
on 2020-02-26 15:12:51 UTC
(
hide
)
Description:
Bug 24155: Make wieghting an option on advanced search
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-02-26 15:12:51 UTC
Size:
6.01 KB
patch
obsolete
>From 87ea90df2bca0f232cf771cdba7436c5e7e74a5f Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 >--- > catalogue/search.pl | 3 ++- > cataloguing/addbooks.pl | 2 +- > koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt | 2 ++ > koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 1 + > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt | 2 ++ > opac/opac-search.pl | 3 ++- > 6 files changed, 10 insertions(+), 3 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 6e5d929413..e42092a09a 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -472,6 +472,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; >@@ -491,7 +492,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 f3b2e43fbb..66a8c00bf8 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -81,7 +81,7 @@ if ($query) { > $query_cgi = "q=".uri_escape_utf8($query); > } else { > ( 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 33ec5241cf..5d0b72d26b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >@@ -117,6 +117,8 @@ > [% END %] > </div> > [% END %] >+ <label for="weight_search">Apply field weightings to search</label> >+ <input type="checkbox" name="weight_search" checked> > </fieldset> > <!-- /BOOLEAN SEARCH OPTIONS --> > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index cef392338a..c0e289f8df 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -172,6 +172,7 @@ > [% END %] > [% IF Koha.Preference('OpacCustomSearch') == '' %] > <form name="searchform" method="get" action="/cgi-bin/koha/opac-search.pl" id="searchform" class="form-inline"> >+ <input type="hidden" name="weight_search" value="1"> > <label for="masthead_search"> Search > [% UNLESS ( Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 ) %] > [% IF ( mylibraryfirst ) %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >index 6248b360b6..1f26e03eb2 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >@@ -107,6 +107,8 @@ > </p> > [% END # FOREACH search_box %] > </fieldset> >+ <label for="weighted_search">Apply field weightings to search</label> >+ <input type="checkbox" name="weight_search" checked> > </div> <!-- /BOOLEAN SEARCH OPTIONS --> > </div> <!-- / .span12 --> > </div> <!-- / .row-fluid --> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index a3a766ac7d..ceb6c96c90 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -530,6 +530,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 > } > ); > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24155
:
99650
|
99667
|
100959
|
104441
|
105033
|
105038
|
105039
|
105041
|
105042
|
109264
|
109360
|
110405
|
110406
|
110407
|
110408
|
110409
|
110431
|
110432
|
110433
|
110434
|
111039