Bugzilla – Attachment 112562 Details for
Bug 24567
Elasticsearch: CCL syntax does not allow for multiple indexes to be searched at once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24567: Don't strip spaces along with dangling colons
Bug-24567-Dont-strip-spaces-along-with-dangling-co.patch (text/plain), 3.04 KB, created by
Nick Clemens (kidclamp)
on 2020-10-27 11:31:36 UTC
(
hide
)
Description:
Bug 24567: Don't strip spaces along with dangling colons
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-10-27 11:31:36 UTC
Size:
3.04 KB
patch
obsolete
>From 9e06ccc4bcd3ae759d66e9ccfa2996105cee0be5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 27 Oct 2020 11:26:53 +0000 >Subject: [PATCH] Bug 24567: Don't strip spaces along with dangling colons > >This updates the regex used for removing colons to capture those with space on either side, and remove the colon >while preserving the space > >To test: > 1 - Have Koha using ES > 2 - Search for: > ti:chess AND chess > 3 - You should get a result in sample data, otherwise replace 'chess' with a title in your catalogue > 4 - Search for: > ti:chess AND kw:chess > 5 - No result > 6 - Enable DumpTemplateVarsIntranet and DumpSearchQueryTemplate > 7 - Repeate search and check page source > 8 - search_query has: > title:chess ANDchess > 9 - Apply patch >10 - Repeat >11 - Seaerch works! >12 - query is now: > title:chess AND chess >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 2 +- > t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 9 ++++++--- > 2 files changed, 7 insertions(+), 4 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index edd0b1b42a..a0d8d65df4 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -940,7 +940,7 @@ sub _clean_search_term { > } > > # Remove unquoted colons that have whitespace on either side of them >- $term =~ s/(\:[:\s]+|[:\s]+:)$lookahead//g; >+ $term =~ s/((:+)(\s+)|(\s+)(:+))$lookahead/\3\4/g; > > $term = $self->_query_regex_escape_process($term); > >diff --git a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index 2057138431..3e515bb340 100755 >--- a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -187,7 +187,7 @@ subtest '_split_query() tests' => sub { > }; > > subtest '_clean_search_term() tests' => sub { >- plan tests => 10; >+ plan tests => 11; > > my $qb; > ok( >@@ -208,10 +208,10 @@ subtest '_clean_search_term() tests' => sub { > is($res, ' unbalanced quotes ', 'unbalanced quotes removed'); > > $res = $qb->_clean_search_term('test : query'); >- is($res, 'test query', 'dangling colon removed'); >+ is($res, 'test query', 'dangling colon removed'); > > $res = $qb->_clean_search_term('test :: query'); >- is($res, 'test query', 'dangling double colon removed'); >+ is($res, 'test query', 'dangling double colon removed'); > > $res = $qb->_clean_search_term('test "another : query"'); > is($res, 'test "another : query"', 'quoted dangling colon not removed'); >@@ -221,6 +221,9 @@ subtest '_clean_search_term() tests' => sub { > > $res = $qb->_clean_search_term('test {another part'); > is($res, 'test another part', 'unbalanced curly brackets replaced correctly'); >+ >+ $res = $qb->_clean_search_term('ti:test AND kw:test'); >+ is($res, 'title:test AND test', 'ti converted to title, kw converted to empty string, dangling colon removed with space preserved'); > }; > > subtest '_join_queries' => sub { >-- >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 24567
:
112562
|
112564
|
112832
|
112903
|
112904
|
112906