Bug 39770 - Limiting subtypes by Braille doesn't work when searching with Elasticsearch
Summary: Limiting subtypes by Braille doesn't work when searching with Elasticsearch
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Peter Vashchuk
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-29 09:38 UTC by Peter Vashchuk
Modified: 2025-05-13 02:27 UTC (History)
4 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 39770: Fix wrong Braille format search for Elasticsearch (2.98 KB, patch)
2025-04-29 09:56 UTC, Peter Vashchuk
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Vashchuk 2025-04-29 09:38:17 UTC
When trying to use ElasticSearch to find books that have Braille it doesn't find anything: No results match your search  with limit(s): 'ff7-01-02:("tc or fb")'.

To reproduce:
1. Have ElasticSearch enabled and you have books that have books with braille, or make up one yourself by adding "tc" (text - Braille) or "fb" (tactile material - braille) to 007 MARC field.
2. Go to catalogue/advanced search and select format: braille from the dropdown.
3. Try to find anything, if you are using ElasticSearch you will see: No results match your search  with limit(s): 'ff7-01-02:("tc or fb")'
Comment 1 Peter Vashchuk 2025-04-29 09:56:03 UTC
Created attachment 181640 [details] [review]
Bug 39770: Fix wrong Braille format search for Elasticsearch

ElasticSearch couldn't find any books that have Braille: No results match your search  with limit(s): 'ff7-01-02:("tc or fb")'. It was a problem because the "l-format:tc or fb" only works for Zebra and is incorrect way to search with OR for ElasticSearch.

Elastic requires the syntax to be l-format:"tc" OR "fb” (uppercase OR and each format in double quotes) instead.

This patch fixes it by checking which search engine you use depending on the current syspref SearchEngine and provides the correctly formatted format.

To reproduce:
1. Have ElasticSearch enabled and check that you have books with braille, or make up one yourself by adding "tc" (text - Braille) or "fb" (tactile material - braille) to 007 MARC field.
2. Go to catalogue/advanced search and select format: braille, from the dropdown.
3. Try to find anything, if you are using ElasticSearch you will see: No results match your search  with limit(s): 'ff7-01-02:("tc or fb")'
4. Do the same with Zebra instead of Elastic, it should work properly and you should see all the books that have Braille.
5. Apply the patch.
6. Repeat same search both using ElasticSearch and then Zebra. Both ElasticSearch and Zebra should work without any issues.
Comment 2 Katrin Fischer 2025-05-06 17:10:57 UTC
Do we really need the check on SearchEngine here? AFAIK Zebra also works with both upper and lower case boolean, so we could just switch this like we did in other places?
Comment 3 Peter Vashchuk 2025-05-07 11:08:20 UTC
Unfortunately, yes, because it's not just about the OR being upper case, Elasticsearch needs the terms to be quoted like: "tc" OR "fb", to parse them properly, otherwise it treats it as a singular term "tc OR fb" and finds nothing.
Comment 4 Katrin Fischer 2025-05-07 11:15:46 UTC
(In reply to Peter Vashchuk from comment #3)
> Unfortunately, yes, because it's not just about the OR being upper case,
> Elasticsearch needs the terms to be quoted like: "tc" OR "fb", to parse them
> properly, otherwise it treats it as a singular term "tc OR fb" and finds
> nothing.

Thanks for explaining :)
Comment 5 Lin Wei 2025-05-12 18:54:27 UTC
# Test Results

- ElasticSearch: Expected behavior.
- Zebra: Does not work.

# Test Execution

0. Create new Catalog with "fb" in 007.
1. Advanced search > Subtype limits > Format > Braille (Default search engine: ElasticSearch).
2. No results match your search  with limit(s): 'ff7-01-02:("tc or fb")'.
3. Switch search engine to Zebra.
4. No results match your search  with limit(s): 'l-format:tc or fb'.
5. Apply patch.
6. No results match your search  with limit(s): 'l-format:tc or fb'.
7. Switch search engine back to ElasticSearch.
8. ElasticSearch finds my Catalog.

# Notes

- Zebra seems to not work at all for me (even on simple searches that I know should work), so it's likely be a problem on my end.
- I can sign-off for ElasticSearch, but I don't know for Zebra.
- Someone else might be able to verify that Zebra still works with Braille after the patch.
- I will leave the status as "Needs Signoff."
Comment 6 David Nind 2025-05-13 02:27:54 UTC
I tested in Zebra and Elasticsearch:

1. Zebra: works as expected before and after the patch, for both the staff interface and the OPAC.

2. Elasticsearch:
   - Before the patch: no results in staff interface and OPAC before the patch
   - After the patch: results in the staff interface, no results in the OPAC:
     . URL for the OPAC, in case that helps troubleshoot:
       /cgi-bin/koha/opac-search.pl?advsearch=1&weight_search=on&limit=branch%3ACPL&sort_by=relevance&limit=l-format%3Atc+or+l-format%3Afb&do=Search
     . Message displayed in the OPC:
         No results found!
         No results found for that in catalog. 
    - I reindexed, in case that makes a difference (it didn't for my testing)

I've failed QA, as I think this should be fixed for the OPAC as well.