Bugzilla – Attachment 136805 Details for
Bug 31076
Bug 22605 breaks date of publication range search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31076: Handle year limits with equal sign or colon
Bug-31076-Handle-year-limits-with-equal-sign-or-co.patch (text/plain), 2.85 KB, created by
Nick Clemens (kidclamp)
on 2022-07-01 11:14:38 UTC
(
hide
)
Description:
Bug 31076: Handle year limits with equal sign or colon
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-07-01 11:14:38 UTC
Size:
2.85 KB
patch
obsolete
>From b9a8ce39a012ff53fa29c99617478bf3521b34d9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 1 Jul 2022 11:08:57 +0000 >Subject: [PATCH] Bug 31076: Handle year limits with equal sign or colon > >To test: >1 - Enable ES and index >2 - Set expandedSearchOption to 'show' >3 - Advanced search on staff and opac using Year field on staff and Publication date range on OPAC for: > 2005 > 2005- > -2005 > <2005 > >2005 > 2005-2010 >4 - Confirm ranges don't work on staff side, but do on opac >5 - Apply patch >6 - Repeat searches - they work on both staff and opac >7 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 ++-- > .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 10 +++++++++- > 2 files changed, 11 insertions(+), 3 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 7250ea6048..462e50a027 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -1061,8 +1061,8 @@ sub _fix_limit_special_cases { > next unless defined($start) && defined($end); > push @new_lim, "date-of-publication:[$start TO $end]"; > } >- elsif ( $l =~ /^yr,st-numeric=/ ) { >- my ($date) = ( $l =~ /^yr,st-numeric=(.*)$/ ); >+ elsif ( $l =~ /^yr,st-numeric[=:]/ ) { >+ my ($date) = ( $l =~ /^yr,st-numeric[=:](.*)$/ ); > next unless defined($date); > $date = $self->_modify_string_by_type(type => 'st-year', operand => $date); > push @new_lim, "date-of-publication:$date"; >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index 4e8964e682..7a0d942fab 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -215,7 +215,7 @@ subtest 'build_authorities_query_compat() tests' => sub { > }; > > subtest 'build_query tests' => sub { >- plan tests => 57; >+ plan tests => 58; > > my $qb; > >@@ -339,6 +339,14 @@ subtest 'build_query tests' => sub { > 'Open end year in year range of an st-year search is handled properly' > ); > >+ ( undef, $query ) = $qb->build_query_compat( undef, ['2019-'], ['yr,st-year'], >+ ['yr,st-numeric:-2019','yr,st-numeric:2005','yr,st-numeric:1984-2022'] ); >+ is( >+ $query->{query}{query_string}{query}, >+ '(date-of-publication:[2019 TO *]) AND (date-of-publication:[* TO 2019]) AND (date-of-publication:2005) AND (date-of-publication:[1984 TO 2022])', >+ 'Limit on year search is handled properly when colon used' >+ ); >+ > # Enable auto-truncation > t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '1' ); > >-- >2.30.2
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 31076
:
136805
|
139405
|
139437
|
139520