Bugzilla – Attachment 68068 Details for
Bug 18374
Respect QueryAutoTruncate syspref in Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18374: (QA follow-up) Fix auto truncation for field:"value"
Bug-18374-QA-follow-up-Fix-auto-truncation-for-fie.patch (text/plain), 2.59 KB, created by
Julian Maurice
on 2017-10-13 10:08:45 UTC
(
hide
)
Description:
Bug 18374: (QA follow-up) Fix auto truncation for field:"value"
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2017-10-13 10:08:45 UTC
Size:
2.59 KB
patch
obsolete
>From b2931c62268e713605522977d6e1345ebe0c4172 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 13 Oct 2017 10:05:08 +0000 >Subject: [PATCH] Bug 18374: (QA follow-up) Fix auto truncation for > field:"value" > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 8 ++++---- > t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t | 9 ++++++++- > 2 files changed, 12 insertions(+), 5 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index b8dc257278..7092e0fae4 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -795,9 +795,9 @@ operands and double quoted strings. > sub _truncate_terms { > my ( $self, $query ) = @_; > >- # '"donald duck" "the mouse" and peter" get split into >- # ['', '"donald duck"', '', ' ', '', '"the mouse"', '', ' ', 'and', ' ', 'pete'] >- my @tokens = split /("[^"]+"|\s+)/, $query; >+ # '"donald duck" title:"the mouse" and peter" get split into >+ # ['', '"donald duck"', '', ' ', '', 'title:"the mouse"', '', ' ', 'and', ' ', 'pete'] >+ my @tokens = split /((?:\w+:)?"[^"]+"|\s+)/, $query; > > # Filter out empty tokens > my @words = grep { $_ !~ /^\s*$/ } @tokens; >@@ -806,7 +806,7 @@ sub _truncate_terms { > # terminated by '*' and not a keyword > my @terms = map { > my $w = $_; >- (/^"/ or /\*$/ or grep {lc($w) eq $_} qw/and or not/) ? $_ : "$_*"; >+ (/"$/ or /\*$/ or grep {lc($w) eq $_} qw/and or not/) ? $_ : "$_*"; > } @words; > > return join ' ', @terms; >diff --git a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t b/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t >index b54a5f0401..74d5069150 100644 >--- a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t >+++ b/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t >@@ -81,7 +81,7 @@ subtest 'json2marc' => sub { > }; > > subtest 'build_query tests' => sub { >- plan tests => 15; >+ plan tests => 16; > > t::lib::Mocks::mock_preference('DisplayLibraryFacets','both'); > my $query = $builder->build_query(); >@@ -171,5 +171,12 @@ subtest 'build_query tests' => sub { > '(barcode:123456*)', > "query of specific field is truncated" > ); >+ >+ ( undef, $query ) = $builder->build_query_compat( undef, ['title:"donald duck"'] ); >+ is( >+ $query->{query}{query_string}{query}, >+ '(title:"donald duck")', >+ "query of specific field is not truncated when surrouned by quotes" >+ ); > }; > >-- >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 18374
:
61806
|
61952
|
61953
|
61954
|
61955
|
61983
|
64903
|
64904
|
67098
|
67099
|
67100
|
67467
|
67468
|
67469
|
67470
|
67727
|
68062
|
68063
|
68064
|
68065
|
68066
|
68067
| 68068