Bugzilla – Attachment 174491 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: (QA follow-up) tidy
Bug-30745-QA-follow-up-tidy.patch (text/plain), 8.04 KB, created by
David Cook
on 2024-11-14 05:58:35 UTC
(
hide
)
Description:
Bug 30745: (QA follow-up) tidy
Filename:
MIME Type:
Creator:
David Cook
Created:
2024-11-14 05:58:35 UTC
Size:
8.04 KB
patch
obsolete
>From eaf9767cd2dd1066c50d7fc3828761897624438e Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Thu, 14 Nov 2024 05:44:59 +0000 >Subject: [PATCH] Bug 30745: (QA follow-up) tidy > >Signed-off-by: David Cook <dcook@prosentient.com.au> >--- > .../Elasticsearch/QueryBuilder.pm | 12 +++--- > labels/label-item-search.pl | 40 +++++++++---------- > .../SearchEngine/Elasticsearch/QueryBuilder.t | 28 ++++++++----- > 3 files changed, 42 insertions(+), 38 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 874f73316a..ad240bdde6 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -854,10 +854,9 @@ sub _modify_string_by_type { > my $until = $2 || '*'; > $str = "[$from TO $until]"; > } >- } >- elsif($type eq 'st-date-normalized'){ >- if ($str =~ /^(.*) - (.*)$/) { >- my $from = $1 || '*'; >+ } elsif ( $type eq 'st-date-normalized' ) { >+ if ( $str =~ /^(.*) - (.*)$/ ) { >+ my $from = $1 || '*'; > my $until = $2 || '*'; > $str = "[$from TO $until]"; > } >@@ -1171,11 +1170,10 @@ sub _fix_limit_special_cases { > else { > push @new_lim, $term; > } >- } >- elsif ($l =~ /^acqdate,st-date-normalized=/ ) { >+ } elsif ( $l =~ /^acqdate,st-date-normalized=/ ) { > my ($date) = ( $l =~ /^acqdate,st-date-normalized=(.*)$/ ); > next unless defined($date); >- $date = $self->_modify_string_by_type(type => 'st-date-normalized', operand => $date); >+ $date = $self->_modify_string_by_type( type => 'st-date-normalized', operand => $date ); > push @new_lim, "date-of-acquisition.raw:$date"; > } > else { >diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl >index 46a36c6e93..6de50862f1 100755 >--- a/labels/label-item-search.pl >+++ b/labels/label-item-search.pl >@@ -40,7 +40,7 @@ my $query = CGI->new; > my $type = $query->param('type'); > my $op = $query->param('op') || ''; > my $batch_id = $query->param('batch_id'); >-my @limits = split(" AND ", $query->param('limits') || ""); >+my @limits = split( " AND ", $query->param('limits') || "" ); > my $startfrom = $query->param('startfrom') || 1; > my ($template, $loggedinuser, $cookie) = (undef, undef, undef); > my ( >@@ -63,33 +63,31 @@ if ( $op eq "do_search" ) { > $datefrom = $query->param('datefrom'); > $dateto = $query->param('dateto'); > >- my $builder = Koha::SearchEngine::QueryBuilder->new( >- { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >- my $searcher = Koha::SearchEngine::Search->new( >- { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >+ my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >+ my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > >- if (!@limits) { >- push(@limits, "acqdate,st-date-normalized=$datefrom - $dateto"); >+ if ( !@limits ) { >+ push( @limits, "acqdate,st-date-normalized=$datefrom - $dateto" ); > } > >- 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 ( >+ $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, $results, $facets ) = $searcher->search_compat( >- $query, $simple_query, [], ['biblioserver'], $resultsperpage, $offset, >- undef, undef, $query_type, undef >+ $query, $simple_query, [], ['biblioserver'], $resultsperpage, $offset, >+ undef, undef, $query_type, undef > ); > >- if (!defined $error && defined($results) && @{$results->{biblioserver}{RECORDS}} > 0 ) { >- $show_results = grep { defined $_ } @{$results->{biblioserver}{RECORDS}}; >- $marcresults = [ grep { defined $_ } @{$results->{biblioserver}{RECORDS}} ]; >- $total_hits = $results->{biblioserver}{hits}; >- } >- else { >+ if ( !defined $error && defined($results) && @{ $results->{biblioserver}{RECORDS} } > 0 ) { >+ $show_results = grep { defined $_ } @{ $results->{biblioserver}{RECORDS} }; >+ $marcresults = [ grep { defined $_ } @{ $results->{biblioserver}{RECORDS} } ]; >+ $total_hits = $results->{biblioserver}{hits}; >+ } else { > Koha::Logger->get->warn("ERROR label-item-search: no results from simple_search_compat"); > > # leave $show_results undef >@@ -192,13 +190,13 @@ if ($show_results) { > ); > > $template->param( >- results => ($show_results ? 1 : 0), >+ results => ( $show_results ? 1 : 0 ), > result_set => \@results_set, > batch_id => $batch_id, > type => $type, > idx => $idx, > ccl_textbox => $ccl_textbox, >- limits => join(" AND ", @limits), >+ limits => join( " AND ", @limits ), > ); > } > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index 340eb41424..ca0e3666b6 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -671,34 +671,42 @@ subtest 'build_query tests' => sub { > is( $limit_cgi,'&limit=author%3ADillinger%20Escaplan&limit=mc-itype%2Cphr%3ABOOK&limit=mc-itype%2Cphr%3ACD', "Limit CGI formed correctly when no search terms"); > is( $limit_desc,'(author:("Dillinger Escaplan")) AND itype:(("BOOK") OR ("CD"))',"Limit desc formed correctly when no search terms"); > >- ( undef, $query ) = $qb->build_query_compat( undef, ['barcode123123'], ['bc'], >- ['acqdate,st-date-normalized= - '] ); >+ ( undef, $query ) = $qb->build_query_compat( >+ undef, ['barcode123123'], ['bc'], >+ ['acqdate,st-date-normalized= - '] >+ ); > is( > $query->{query}{query_string}{query}, > '(barcode:barcode123123) AND date-of-acquisition.raw:[* TO *]', > 'If no date all date-of-acquisition are selected' > ); > >- ( undef, $query ) = $qb->build_query_compat( undef, ['barcode123123'], ['bc'], >- ['acqdate,st-date-normalized=2024-08-01 - '] ); >+ ( undef, $query ) = $qb->build_query_compat( >+ undef, ['barcode123123'], ['bc'], >+ ['acqdate,st-date-normalized=2024-08-01 - '] >+ ); > is( > $query->{query}{query_string}{query}, > '(barcode:barcode123123) AND date-of-acquisition.raw:[2024-08-01 TO *]', > 'Open start date in date range of an st-date-normalized search is handled properly' > ); > >- ( undef, $query ) = $qb->build_query_compat( undef, ['barcode123123'], ['bc'], >- ['acqdate,st-date-normalized= - 2024-08-30'] ); >+ ( undef, $query ) = $qb->build_query_compat( >+ undef, ['barcode123123'], ['bc'], >+ ['acqdate,st-date-normalized= - 2024-08-30'] >+ ); > is( > $query->{query}{query_string}{query}, > '(barcode:barcode123123) AND date-of-acquisition.raw:[* TO 2024-08-30]', > 'Open end date in date range of an st-date-normalized search is handled properly' > ); > >- ( undef, $query ) = $qb->build_query_compat( undef, ['barcode123123'], ['bc'], >- ['acqdate,st-date-normalized=2024-08-01 - 2024-08-30'] ); >- is( >- $query->{query}{query_string}{query}, >+ ( undef, $query ) = $qb->build_query_compat( >+ undef, ['barcode123123'], ['bc'], >+ ['acqdate,st-date-normalized=2024-08-01 - 2024-08-30'] >+ ); >+ is( >+ $query->{query}{query_string}{query}, > '(barcode:barcode123123) AND date-of-acquisition.raw:[2024-08-01 TO 2024-08-30]', > 'Date range in an st-date-normalized search is handled properly' > ); >-- >2.39.5
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