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
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit a11633379f)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
4cf509b248
commit
a72ecc3b27
|
|
@ -1062,14 +1062,14 @@ sub _fix_limit_special_cases {
|
|||
foreach my $l (@$limits) {
|
||||
|
||||
# This is set up by opac-search.pl
|
||||
if ( $l =~ /^yr,st-numeric,ge=/ ) {
|
||||
if ( $l =~ /^yr,st-numeric,ge[=:]/ ) {
|
||||
my ( $start, $end ) =
|
||||
( $l =~ /^yr,st-numeric,ge=(.*) and yr,st-numeric,le=(.*)$/ );
|
||||
( $l =~ /^yr,st-numeric,ge[=:](.*) and yr,st-numeric,le[=:](.*)$/ );
|
||||
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";
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ subtest 'build_authorities_query_compat() tests' => sub {
|
|||
};
|
||||
|
||||
subtest 'build_query tests' => sub {
|
||||
plan tests => 59;
|
||||
plan tests => 60;
|
||||
|
||||
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' );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue