From 6fa4e21c5762bacec4b6aae9c393751b295e2b77 Mon Sep 17 00:00:00 2001 From: Andreas Jonsson Date: Thu, 16 May 2024 09:38:09 +0200 Subject: [PATCH] Bug 36879: Spurious warning in QueryBuilder Test plan: With ElasticSearch enabled, * Perform a search using the default sort order (i.e. 'relevance'). * Verify that no warnings are generated in plack-intranet-error.log Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit 347291727dd63cdba508b84336bed4d12efee57d) Signed-off-by: Lucas Gass (cherry picked from commit ab51747dcc8b9a14d73e0efe4763937763f7f622) Signed-off-by: Fridolin Somers --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index edde18cc09..fc5ed59a9a 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -731,10 +731,12 @@ sub _convert_sort_fields { # Convert the fields and orders, drop anything we don't know about. grep { $_->{field} } map { my ( $f, $d ) = /(.+)_(.+)/; - { + defined $f && defined $d + ? { field => $sort_field_convert{$f}, direction => $sort_order_convert{$d} - } + } + : { field => undef }; } @sort_by; } -- 2.39.5