@@ -, +, @@ --- C4/Search.pm | 13 ++++++++----- installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 6 ++++++ .../en/modules/admin/preferences/searching.pref | 8 ++++---- 4 files changed, 19 insertions(+), 10 deletions(-) --- a/C4/Search.pm +++ a/C4/Search.pm @@ -1030,11 +1030,14 @@ sub _build_weighted_query { #$weighted_query .=" or kw,wrdl,r5=\"$operand\""; # word list any $weighted_query .= " or wrdl,fuzzy,r8=\"$operand\"" if $fuzzy_enabled; # add fuzzy, word list - $weighted_query .= " or wrdl,right-Truncation,r9=\"$stemmed_operand\"" - if ( $stemming and $stemmed_operand ) + if ( $stemming and $stemmed_operand ) { + $weighted_query .= " or wrdl,right-Truncation,r9=\"$stemmed_operand\"" ; # add stemming, right truncation - $weighted_query .= " or wrdl,r9=\"$operand\""; - + } elsif ( $weight_fields == 2 ) { + $weighted_query .= " or wrdl,right-Truncation,r9=\"$operand\""; + } else { + $weighted_query .= " or wrdl,r9=\"$operand\""; + } # embedded sorting: 0 a-z; 1 z-a # $weighted_query .= ") or (sort1,aut=1"; } @@ -1617,7 +1620,7 @@ sub buildQuery { # Apply Truncation if ( scalar(@$righttruncated) + scalar(@$lefttruncated) + - scalar(@$rightlefttruncated) > 0 ) + scalar(@$rightlefttruncated) > 0 and $weight_fields < 2 ) { # Don't field weight or add the index to the query, we do it here --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -343,7 +343,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'), ('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'), ('QueryStemming','1',NULL,'If ON, enables query stemming','YesNo'), -('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'), +('QueryWeightFields','1','0|1|2','Enable field weighting research','Choice'), ('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'), ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -9585,6 +9585,12 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { +$dbh->do("UPDATE systempreferences set explanation = 'If ON, enables field weighting with or without automatic right truncation', options = '0|1|2', type= 'Choice' where variable = 'QueryWeightFields'"); + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -24,11 +24,11 @@ Searching: - to match words of the same base in a search (for example, a search for enabling would also match enable and enabled; REQUIRES ZEBRA). - - pref: QueryWeightFields - type: boolean + default: 1 choices: - yes: Enable - no: Disable - - ranking of search results by relevance (REQUIRES ZEBRA). + 0: Disable ranking of search results by relevance. + 1: Enable ranking of search results by relevance. + 2: Enable ranking of search results by relevance with automatic right truncation. - - pref: OpacGroupResults default: 0 --