Bug 31213 - When performing a basic search with no results, repeat the search with term quoted
Summary: When performing a basic search with no results, repeat the search with term q...
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-21 18:16 UTC by Nick Clemens
Modified: 2022-07-26 14:45 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement adds a second, automatic, search with the search terms between quotation marks when a search returns no results. For example, searches with special characters don't work with Elasticsearch. A search for Ivy + Bean will return no results. But a search for "Ivy + Bean" will return results. With this enhancement, if a user searches for Ivy + Bean without quotation marks and gets no results, Koha will automatically search for "Ivy + Bean" and return those results. This targets both Zebra and Elasticsearch, but is more relevant for Elasticsearch.
Version(s) released in:
22.11.00


Attachments
Bug 31213: Auto search simple term quoted (5.65 KB, patch)
2022-07-21 18:19 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31213: Auto search simple term quoted (5.71 KB, patch)
2022-07-22 08:13 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 31213: Auto search simple term quoted (5.77 KB, patch)
2022-07-22 08:30 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2022-07-21 18:16:12 UTC
Under elastic, when searching for some special characters a search may fail:
Ivy + Bean
The 6:20 man
etc.

These terms work when quoted:
"Ivy + Bean"

It would be nice if we just tried this automatically for the user
Comment 1 Nick Clemens 2022-07-21 18:19:56 UTC
Created attachment 137993 [details] [review]
Bug 31213: Auto search simple term quoted

This patch does a second search if the first had no results and was a simple single term search

We simply quote the term, rebuild the query, and rerun the search

This targets both Zebra and ES, but is more relevant for ES

To test:
0 - Have Koha running using ES
1 - Add titles your system "Ivy + Bean" "The 6:20 Man"
2 - Search for these titles without quotes - NO results under ES
3 - Search with quotes - you find them
4 - Apply patch, restart all
5 - Search again without quotes
6 - Success!
7 - Confirm search still works under Zebra
Comment 2 ByWater Sandboxes 2022-07-22 08:13:58 UTC
Created attachment 138002 [details] [review]
Bug 31213: Auto search simple term quoted

This patch does a second search if the first had no results and was a simple single term search

We simply quote the term, rebuild the query, and rerun the search

This targets both Zebra and ES, but is more relevant for ES

To test:
0 - Have Koha running using ES
1 - Add titles your system "Ivy + Bean" "The 6:20 Man"
2 - Search for these titles without quotes - NO results under ES
3 - Search with quotes - you find them
4 - Apply patch, restart all
5 - Search again without quotes
6 - Success!
7 - Confirm search still works under Zebra

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 3 Sally 2022-07-22 08:14:25 UTC
Works great, thanks Nick - signed off.
Comment 4 Martin Renvoize 2022-07-22 08:27:30 UTC
Great idea
Comment 5 Martin Renvoize 2022-07-22 08:30:10 UTC
Created attachment 138004 [details] [review]
Bug 31213: Auto search simple term quoted

This patch does a second search if the first had no results and was a simple single term search

We simply quote the term, rebuild the query, and rerun the search

This targets both Zebra and ES, but is more relevant for ES

To test:
0 - Have Koha running using ES
1 - Add titles your system "Ivy + Bean" "The 6:20 Man"
2 - Search for these titles without quotes - NO results under ES
3 - Search with quotes - you find them
4 - Apply patch, restart all
5 - Search again without quotes
6 - Success!
7 - Confirm search still works under Zebra

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2022-07-22 08:31:05 UTC
Works as described and the QA scripts are happy..

I wondered if we could possibly move it up a level into the modules but decided that's either a silly idea, or something for a future piece..

Passing QA
Comment 7 Katrin Fischer 2022-07-22 08:31:57 UTC
+1 from me as well.
Comment 8 Tomás Cohen Arazi 2022-07-22 15:29:48 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!