@@ -, +, @@ 2005 2005- -2005 <2005 >2005 2005-2010 --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 8 ++++---- .../Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -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"; --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ a/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 => 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' ); --