Bugzilla – Attachment 18010 Details for
Bug 9961
Truncation and QueryAutoTruncate not working properly with new QueryParser
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 9961: Add truncation support to QP driver
PASSED-QA-Bug-9961-Add-truncation-support-to-QP-dr.patch (text/plain), 5.12 KB, created by
Katrin Fischer
on 2013-05-08 06:25:27 UTC
(
hide
)
Description:
[PASSED QA] Bug 9961: Add truncation support to QP driver
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2013-05-08 06:25:27 UTC
Size:
5.12 KB
patch
obsolete
>From b53f9ef06b112c6edfefad985ec4627ed05e6ea8 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Thu, 2 May 2013 11:53:36 -0400 >Subject: [PATCH] [PASSED QA] Bug 9961: Add truncation support to QP driver > >The original implementation of QueryParser did not handle truncation >based on the QueryAutoTruncate system preference. This patch adds support. > >To test: >1) Apply patch. >2) Turn on UseQueryParser. >3) Set QueryAutoTruncate to "automatically." >4) Search for "har". Note that it returns results with words > like "Harry" (i.e. with right truncation). >5) Search for "har*". Note that it still returns results with right > truncation. >6) Set QueryAutoTruncate to "only when * is added." >7) Search for "har". Note that it returns only records that have the > exact word "har" in them (most likely there will be none unless you > have Hebrew items). >8) Search for "har*". Note that once again it returns results for "Harry" > (i.e. right truncated results). >9) Sign off. > >This patch also reindents a hash in Koha/QueryParser/Driver/PQF.pm >because it was hard to read before. > >Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >All tests and QA script pass. >Thx for fixing this Jared! >--- > C4/Search.pm | 5 +++++ > Koha/QueryParser/Driver/PQF.pm | 26 ++++++++++++------------ > Koha/QueryParser/Driver/PQF/query_plan/node.pm | 4 ++++ > 3 files changed, 22 insertions(+), 13 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index da729ad..aec024b 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -112,6 +112,7 @@ sub FindDuplicate { > $titleindex = 'title|exact'; > $authorindex = 'author|exact'; > $op = '&&'; >+ $QParser->custom_data->{'QueryAutoTruncate'} = C4::Context->preference('QueryAutoTruncate'); > } else { > $titleindex = 'ti,ext'; > $authorindex = 'au,ext'; >@@ -233,6 +234,9 @@ sub SimpleSearch { > > my $QParser; > $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') && ! ($query =~ m/\w,\w|\w=\w/)); >+ if ($QParser) { >+ $QParser->custom_data->{'QueryAutoTruncate'} = C4::Context->preference('QueryAutoTruncate'); >+ } > > # Initialize & Search Zebra > for ( my $i = 0 ; $i < @servers ; $i++ ) { >@@ -1177,6 +1181,7 @@ sub parseQuery { > > if ($QParser) > { >+ $QParser->custom_data->{'QueryAutoTruncate'} = C4::Context->preference('QueryAutoTruncate'); > $query = ''; > for ( my $ii = 0 ; $ii <= @operands ; $ii++ ) { > next unless $operands[$ii]; >diff --git a/Koha/QueryParser/Driver/PQF.pm b/Koha/QueryParser/Driver/PQF.pm >index 3007333..d4551f0 100644 >--- a/Koha/QueryParser/Driver/PQF.pm >+++ b/Koha/QueryParser/Driver/PQF.pm >@@ -349,23 +349,23 @@ not want to use it. > sub clear_all_configuration { > my ($self) = @_; > %OpenILS::QueryParser::parser_config = ( >- 'OpenILS::QueryParser' => { >+ 'OpenILS::QueryParser' => { > filters => [], > modifiers => [], > operators => { >- 'and' => '&&', >- 'or' => '||', >- float_start => '{{', >- float_end => '}}', >- group_start => '(', >- group_end => ')', >- required => '+', >- disallowed => '-', >- modifier => '#', >- negated => '!' >+ 'and' => '&&', >+ 'or' => '||', >+ float_start => '{{', >+ float_end => '}}', >+ group_start => '(', >+ group_end => ')', >+ required => '+', >+ disallowed => '-', >+ modifier => '#', >+ negated => '!' > } >- } >- ); >+ } >+ ); > return $self; > } > >diff --git a/Koha/QueryParser/Driver/PQF/query_plan/node.pm b/Koha/QueryParser/Driver/PQF/query_plan/node.pm >index 7d05937..e88ef84 100644 >--- a/Koha/QueryParser/Driver/PQF/query_plan/node.pm >+++ b/Koha/QueryParser/Driver/PQF/query_plan/node.pm >@@ -57,6 +57,7 @@ sub target_syntax { > $phrase =~ s/"/\\"/g; > $pqf .= ' @or ' x (scalar(@fields) - 1); > foreach my $attributes (@fields) { >+ $attributes->{'attr_string'} ||= ''; > $pqf .= $attributes->{'attr_string'} . ($attributes->{'4'} ? '' : ' @attr 4=1') . ' "' . $phrase . '" '; > } > $atom_count++; >@@ -70,6 +71,9 @@ sub target_syntax { > $pqf .= ' @or ' x (scalar(@fields) - 1); > foreach my $attributes (@fields) { > $attributes->{'attr_string'} ||= ''; >+ if ($self->plan->QueryParser->custom_data->{'QueryAutoTruncate'} || $atom->suffix eq '*') { >+ $attributes->{'attr_string'} .= ($attributes->{'5'} ? '' : ' @attr 5=1 '); >+ } > $pqf .= $attributes->{'attr_string'} . ($attributes->{'4'} ? '' : ' @attr 4=6 ') . $atom_content . ' '; > } > $atom_count++; >-- >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 9961
:
17904
|
17935
|
17976
| 18010 |
29866