Bug 43320: Don't quoted already quoted searches and add feedback

Bug 31213 added a quoted search when no results were found,
this patch builds on that to:
1 - Notify the user when their search is repeated quoted
2 - Not repeat a search when already quoted

To test:
 0 - Set system preferences
     RedirectToSoleResult to 'Don't redirect'
     IntranetAddMastheadLibraryPulldown to Show
     IntranetCatalogSearchPulldown to Show
 1 - Add the sample records to your catalog
 2 - Search for the quoted phrase "happy family big" in the 'title' index
 3 - Note you get a result
 4 - Check the record - the phrase is not found, but the record contains all the terms
 5 - Search for the unquoted phrase: 6:20 man
 6 - Confirm search is quoted and result found
 7 - Apply patch, restart all
 8 - Repeat 5
 9 - Confirm you are now told search was quoted and result found
10 - Repeat 2
11 - Confirm no result found, no notice of repeated search

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2026-08-18 12:48:14 +00:00 committed by Lucas Gass
parent 199e65af66
commit 8bf971217c
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 12 additions and 1 deletions

View File

@ -556,7 +556,8 @@ if ( $@ || $error ) {
}
my $hits = $results_hashref->{$server}->{"hits"} // 0;
if ( $hits == 0 && $basic_search ) {
if ( $hits == 0 && $basic_search && $operands[0] !~ /^\".*\"$/ ) {
my $og_query = $query_desc;
$operands[0] = '"' . $operands[0] . '"'; #quote it
## I. BUILD THE QUERY
(
@ -585,6 +586,10 @@ if ( $hits == 0 && $basic_search ) {
};
my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
if ($quoted_hits) {
$template->param(
quoted_hits => 1,
og_query => $og_query,
);
$results_hashref->{$server} = $quoted_results_hashref->{$server};
$hits = $quoted_hits;
}

View File

@ -72,6 +72,12 @@
<h1>Search results</h1>
[% IF ( total ) %]
[% IF quoted_hits %]
<h4 class="info">
No result(s) found for your original query: [% og_query %]<br />
Your search was retried, quoted
</h4>
[% END %]
<h3>
[% total | html %] result(s) found
[% IF ( query_desc ) %]for <span class="results_query_desc">'[% query_desc | html %]'</span>[% END %][% IF limit_desc %]