From 53ed15d383d2a9b7771dd126e9950c4e91c30f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Tue, 7 Oct 2025 11:36:53 -0300 Subject: [PATCH] Bug 40966: Make sure 'whole_record' and 'weighted_fields' are passed around The ES query builder correctly handles this parameters (passed from search.pl and opac-search.pl) when it builds the ES query. But the returned 'query_cgi' that is used later for keeping the search results query context for building things like facets, just doesn't pass this values around, leading to a loss of them on the generated links. This patch makes sure they are passed around. To test: 1. Set ElasticsearchMARCFormat="Searchable array" 2. Reindex all the things: $ ktd --shell k$ koha-elasticsearch --rebuild -d -v kohadev 3. Go to advanced search, using the 'More options' option. 4. Check 'Search entire MARC record' and 'Apply weights to search' 5. Perform a search on 'FULL TEXT' => SUCCESS: The URL contains `whole_record=on` and `weighted_fields=on` 6. Hover on any facet and look at the link => FAIL: It doesn't contain them! 7. Apply this patch 8. Restart all k$ restart_all 9. Refresh the search results 10. Repeat 6 => SUCCESS: Links have the needed parameters! 11. Sign off :-D --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 8ee830c6498..42eed857f8f 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -352,7 +352,9 @@ sub build_query_compat { $query_cgi .= 'idx=' . uri_escape_utf8( $index // '' ) . '&q=' . uri_escape_utf8($oand); $query_cgi .= '&op=' . uri_escape_utf8($otor) if $otor; } - $query_cgi .= '&scan=1' if ($scan); + $query_cgi .= '&scan=1' if ($scan); + $query_cgi .= '&weighted_fields=1' if ( $params->{weighted_fields} ); + $query_cgi .= '&whole_record=1' if ( $params->{whole_record} ); my $simple_query; $simple_query = $operands->[0] if @$operands == 1; -- 2.51.0