Bug 22801: Advance search yr must use date-of-publication and not copydate
In advanced search with Elasticsearch the limit on years range is actually using copydate :
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm in _fix_limit_special_cases() :
if ( $l =~ /^yr,st-numeric,ge=/ ) {
my ( $start, $end ) =
( $l =~ /^yr,st-numeric,ge=(.*) and yr,st-numeric,le=(.*)$/ );
next unless defined($start) && defined($end);
push @new_lim, "copydate:[$start TO $end]";
}
With Zebra it uses date-of-publication and also in Koha/SearchEngine/Elasticsearch/QueryBuilder.pm :
our %index_field_convert = (
(...)
'yr' => 'date-of-publication',
This patch uses %index_field_convert to perform 'yr' limit.
Test plan:
1) Apply patch
2) Use Elasticsearch searchengine
3) Go to advanced search with 'More options'
4) Perform a search with a year limit (value or range)
5) Check results are correct
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 7ab5837808)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
b2f35c2f0a
commit
2cdf04463c
|
|
@ -995,6 +995,9 @@ The argument should be an arrayref, and it'll return an arrayref.
|
|||
sub _fix_limit_special_cases {
|
||||
my ( $self, $limits ) = @_;
|
||||
|
||||
# yr is usually an alias of a search field
|
||||
my $yrfield = ( exists $index_field_convert{'yr'} ) ? $index_field_convert{'yr'} : 'yr';
|
||||
|
||||
my @new_lim;
|
||||
foreach my $l (@$limits) {
|
||||
|
||||
|
|
@ -1003,13 +1006,13 @@ sub _fix_limit_special_cases {
|
|||
my ( $start, $end ) =
|
||||
( $l =~ /^yr,st-numeric,ge=(.*) and yr,st-numeric,le=(.*)$/ );
|
||||
next unless defined($start) && defined($end);
|
||||
push @new_lim, "copydate:[$start TO $end]";
|
||||
push @new_lim, "$yrfield:[$start TO $end]";
|
||||
}
|
||||
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, "copydate:$date";
|
||||
push @new_lim, "$yrfield:$date";
|
||||
}
|
||||
elsif ( $l =~ /^available$/ ) {
|
||||
push @new_lim, 'onloan:false';
|
||||
|
|
|
|||
Loading…
Reference in New Issue