Bugzilla – Attachment 171003 Details for
Bug 30745
Elasticsearch: Search never returns with after-date and/or before-date in label batch item search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30745: handle ES ranges for date of acquisition
Bug-30745-handle-ES-ranges-for-date-of-acquisition.patch (text/plain), 4.25 KB, created by
Hammat wele
on 2024-09-03 21:38:50 UTC
(
hide
)
Description:
Bug 30745: handle ES ranges for date of acquisition
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2024-09-03 21:38:50 UTC
Size:
4.25 KB
patch
obsolete
>From 71660324c03d90fff272bd013621ccefe925c1ad Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 12 May 2022 17:29:52 +0200 >Subject: [PATCH] Bug 30745: handle ES ranges for date of acquisition > >Test plan: > - Enable elasticsearch > - git to labels/label-item-search.pl > - search using after date only > => check you get items with date-of-acquisition greater than after >date > - search using before date only > => check you get items with date-of-acquisition less than before >date > - search using after and before date > => check you get items with date-of-acquisition between after and >before > - Combine this searches with a specified index > - enable zebra and repeat these tests > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> > >https://bugs.koha-community.org/show_bug.cgi?id=30845 >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 17 +++++++++++++++++ > labels/label-item-search.pl | 14 ++++++++------ > 2 files changed, 25 insertions(+), 6 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index bd0ba28197..8298520835 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -1087,6 +1087,7 @@ sub _fix_limit_special_cases { > my ( $self, $limits ) = @_; > > my @new_lim; >+ my $ranges; > foreach my $l (@$limits) { > # This is set up by opac-search.pl > if ( $l =~ /^yr,st-numeric,ge[=:]/ ) { >@@ -1154,6 +1155,16 @@ sub _fix_limit_special_cases { > push @new_lim, $term; > } > } >+ elsif ($l =~ /^acqdate,(ge|le),st-date-normalized=/ ) { >+ my ($fromdate) = ( $l =~ /^acqdate,ge,st-date-normalized=(.*)$/ ); >+ my ($todate) = ( $l =~ /^acqdate,le,st-date-normalized=(.*)$/ ); >+ $fromdate ||= '*'; >+ $todate ||= '*'; >+ $ranges->{'date-of-acquisition.raw'} = { >+ from => $fromdate, >+ to => $todate >+ } >+ } > else { > my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/; > $field =~ s/,phr$//; #We are quoting all the limits as phrase, this prevents from quoting again later >@@ -1164,6 +1175,12 @@ sub _fix_limit_special_cases { > push @new_lim, $l; > } > } >+ >+ if ( $ranges ) { >+ foreach my $index ( keys %$ranges ) { >+ push @new_lim, "$index:[$ranges->{$index}{from} TO $ranges->{$index}{to}]" >+ } >+ } > } > return \@new_lim; > } >diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl >index d0624e4e2d..b07e4e1c93 100755 >--- a/labels/label-item-search.pl >+++ b/labels/label-item-search.pl >@@ -32,6 +32,7 @@ use C4::Creators::Lib qw( html_table ); > use Koha::Logger; > use Koha::Items; > use Koha::ItemTypes; >+use Koha::SearchEngine::QueryBuilder; > use Koha::SearchEngine::Search; > > my $query = CGI->new; >@@ -76,20 +77,21 @@ if ( $op eq "do_search" ) { > push(@limits, "acqdate,le,st-date-normalized=$dateto"); > } > >- my ( $error, $query, $simple_query, $query_cgi, >+ my ( $build_error, $query, $simple_query, $query_cgi, > $query_desc, $limit, $limit_cgi, $limit_desc, > $query_type ) > = $builder->build_query_compat( undef, [$ccl_textbox], [$idx], \@limits); > > my $offset = $startfrom > 1 ? $startfrom - 1 : 0; > >- my ( $error, $marcresults, $facets ) = $searcher->search_compat( >- $query, $simple_query, undef, ['biblioserver'], $resultsperpage, $offset, >+ my ( $error, $results, $facets ) = $searcher->search_compat( >+ $query, $simple_query, [], ['biblioserver'], $resultsperpage, $offset, > undef, undef, $query_type, undef >- ); >+ ); > >- if (!defined $error && $marcresults->{biblioserver}{RECORDS} ) { >- $show_results = $marcresults->{biblioserver}{RECORDS}; >+ if (!defined $error && @{$results->{biblioserver}{RECORDS}} ) { >+ $show_results = @{$results->{biblioserver}{RECORDS}}; >+ $marcresults = $results->{biblioserver}{RECORDS}; > } > else { > Koha::Logger->get->warn("ERROR label-item-search: no results from simple_search_compat"); >-- >2.34.1
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 30745
:
134952
|
134953
|
135784
|
135785
|
135966
|
135967
|
157192
|
157194
|
157195
|
157934
|
162855
|
163955
|
170677
|
170678
|
170679
|
170680
|
170681
|
170682
|
170683
|
170684
|
170729
|
170730
|
170731
|
170732
|
170733
|
171002
|
171003
|
171004
|
171005
|
171006
|
173280
|
173943
|
173944
|
173945
|
173946
|
173947
|
174486
|
174487
|
174488
|
174489
|
174490
|
174491