Bugzilla – Attachment 34285 Details for
Bug 13414
Enable right truncation with search by relevance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13414 - Enable automatic right truncation while searching by relevance
0001-Bug-13414-Enable-automatic-right-truncation-while-se.patch (text/plain), 5.22 KB, created by
Koha Team University Lyon 3
on 2014-12-10 19:58:47 UTC
(
hide
)
Description:
Bug 13414 - Enable automatic right truncation while searching by relevance
Filename:
MIME Type:
Creator:
Koha Team University Lyon 3
Created:
2014-12-10 19:58:47 UTC
Size:
5.22 KB
patch
obsolete
>From 8a0b5f990706f2ecb4827a82eaae303e6dacb6a9 Mon Sep 17 00:00:00 2001 >From: kohapreprod <koha@univ-lyon3.fr> >Date: Wed, 10 Dec 2014 20:46:57 +0100 >Subject: [PATCH] Bug 13414 - Enable automatic right truncation while > searching by relevance > >This makes slight modification in build_weighted_query function in order to make >automatic right truncation possible when QueryWeightFields syspref activated (even little ranked) >Modify this syspref type from boolean to choice in order to add >this possiblity as a third option : Search by relevance with automatic right truncation. >--- > C4/Search.pm | 13 ++++++++----- > installer/data/mysql/sysprefs.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 6 ++++++ > .../prog/en/modules/admin/preferences/searching.pref | 8 ++++---- > 4 files changed, 19 insertions(+), 10 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 1326f69..87d0fec 100644 >--- a/C4/Search.pm >+++ b/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 >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index c3e308f..6c4acbf 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/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'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index cf17e0b..7f9596c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/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) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >index c6a19bf..ba26c60 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >+++ b/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 <cite>enabling</cite> would also match <cite>enable</cite> and <cite>enabled</cite>; 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 >-- >1.7.10.4 >
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 13414
:
34199
|
34285
|
34316
|
38024