Bugzilla – Attachment 16182 Details for
Bug 9239
Koha should share Evergreen's QueryParser module for parsing queries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9239: Add syspref to enable QueryParser
Bug-9239-Add-syspref-to-enable-QueryParser.patch (text/plain), 6.33 KB, created by
Jared Camins-Esakov
on 2013-03-17 01:27:07 UTC
(
hide
)
Description:
Bug 9239: Add syspref to enable QueryParser
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2013-03-17 01:27:07 UTC
Size:
6.33 KB
patch
obsolete
>From 8f408efa63bdd284a83e6501eb514b9300f4d014 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Tue, 11 Dec 2012 12:16:20 -0500 >Subject: [PATCH] Bug 9239: Add syspref to enable QueryParser > >In light of the experimental nature of the QueryParser code at this >juncture, it behooves Koha to have the option of disabling QP, at least >for the purpose of comparing results between QP-enabled and QP-disabled >searches. This patch adds a UseQueryParser syspref to do just that. In >cases where the user enables QP without having QP installed, however, >there will be no dramatic failure, and Koha will simply fall back to >using the non-QP search code. > >In order to reduce the overhead added by the introduction of QueryParser, >this patch adds a C4::Context->queryparser accessor to a static >QueryParser object which is initialized the first time it is required >and then reset thereafter. > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >Signed-off-by: Elliott Davis <elliott@bywatersolions.com> >Fixed merge conflict in sysprefs.sql and updatedatabase.sql > >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Fixed merge conflict in sysprefs.sql und updatedatabase.pl >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > C4/Context.pm | 43 ++++++++++++++++++++ > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 9 ++++ > .../en/modules/admin/preferences/searching.pref | 7 ++++ > 4 files changed, 60 insertions(+) > >diff --git a/C4/Context.pm b/C4/Context.pm >index c2b5233..1488413 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -105,6 +105,7 @@ use C4::Boolean; > use C4::Debug; > use POSIX (); > use DateTime::TimeZone; >+use Module::Load::Conditional qw(can_load); > > =head1 NAME > >@@ -941,6 +942,48 @@ sub restore_dbh > # return something, then this function should, too. > } > >+=head2 queryparser >+ >+ $queryparser = C4::Context->queryparser >+ >+Returns a handle to an initialized Koha::QueryParser::Driver::PQF object. >+ >+=cut >+ >+sub queryparser { >+ my $self = shift; >+ unless (defined $context->{"queryparser"}) { >+ $context->{"queryparser"} = &_new_queryparser(); >+ } >+ >+ return $context->{"queryparser"}->new; >+} >+ >+=head2 _new_queryparser >+ >+Internal helper function to create a new QueryParser object. QueryParser >+is loaded dynamically so as to keep the lack of the QueryParser library from >+getting in anyone's way. >+ >+=cut >+ >+sub _new_queryparser { >+ my $qpmodules = { >+ 'OpenILS::QueryParser' => undef, >+ 'Koha::QueryParser::Driver::PQF' => undef >+ }; >+ if ( can_load( 'modules' => $qpmodules ) ) { >+ my $QParser = Koha::QueryParser::Driver::PQF->new(); >+ my $config_file = $context->config('queryparser_config'); >+ $config_file ||= '/etc/koha/searchengine/queryparser.yaml'; >+ if ( $QParser->load_config($config_file) ) { >+ # TODO: allow indexes to be configured in the database >+ return $QParser; >+ } >+ } >+ return; >+} >+ > =head2 marcfromkohafield > > $dbh = C4::Context->marcfromkohafield; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 9c66df0..fd2b77d 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -419,3 +419,4 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('TrackClicks','0','Track links clicked',NULL,'Integer'); > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('PatronSelfRegistrationAdditionalInstructions','','A free text field to display additional instructions to newly self registered patrons.','','free'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '1', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 9b4aa8e..22dea64 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6444,6 +6444,7 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+ > $DBversion = "3.11.00.024"; > if ( CheckVersion($DBversion) ) { > $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice');"); >@@ -6512,6 +6513,14 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.11.00.XXX"; >+if (CheckVersion($DBversion)) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '1', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo')"); >+ print "Upgrade to $DBversion done (Bug 9239: Make it possible for Koha to use QueryParser)\n"; >+ 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 451cbc9..2b1848f 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 >@@ -58,6 +58,13 @@ Searching: > no: "Not using" > - 'ICU Zebra indexing. Please note: This setting will not affect Zebra indexing, it should only be used to tell Koha that you have activated ICU indexing if you have actually done so, since there is no way for Koha to figure this out on its own.' > - >+ - pref: UseQueryParser >+ default: 1 >+ choices: >+ yes: Try >+ no: "Do not try" >+ - 'to use the QueryParser module for parsing queries. Please note: enabling this will have no impact if you do not have QueryParser installed, and everything will continue to work as usual.' >+ - > - pref: IncludeSeeFromInSearches > default: 0 > choices: >-- >1.7.9.5
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 9239
:
14020
|
14021
|
14022
|
14023
|
14172
|
14173
|
14174
|
14175
|
14180
|
14181
|
14182
|
14183
|
14847
|
14949
|
14950
|
14951
|
14952
|
14953
|
15121
|
15437
|
15865
|
15867
|
15929
|
15999
|
16004
|
16051
|
16125
|
16130
|
16131
|
16132
|
16133
|
16136
|
16140
|
16141
|
16142
|
16143
|
16144
|
16145
|
16146
|
16147
|
16148
|
16149
|
16150
|
16151
|
16152
|
16153
|
16154
|
16155
|
16180
|
16181
| 16182 |
16183
|
16184
|
16185
|
16186
|
16187
|
16188
|
16189
|
16190
|
16191
|
16192
|
16193
|
16194
|
16195