Bug 20099

Summary: Filtering by Library returns incorrect results
Product: Koha Reporter: Daphne Hoolahan <dch>
Component: Searching - ZebraAssignee: Bugs List <koha-bugs>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P2 CC: bc, jonathan.druart
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Crowdfunding committed: 0
Crowdfunding contact: Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 20099: Try exact search for facets

Description Daphne Hoolahan 2018-01-30 10:37:52 UTC
I have 3 libraries; AB; AB_C and AB_D
If I Refine Search for Holding Library AB_C I get the correct results, all biblios which have at least one item in AB_C; similarly for Holding Library AB_D but if I Refine Search for Holding Library AB I get all biblios which have at least one item in AB, or AB_C or AB_D.
The system is treating AB_C and AB_D as subsets of AB but AB_C is a completely different value to AB.
The problem is the same in the staff interface.
Comment 1 Jonathan Druart 2018-01-30 20:42:37 UTC
I have just tested quickly, I have a branchcode "CPL", I search for "d" and use the CPL facet. I get 240 results and the url is
http://pro.kohadev.org/cgi-bin/koha/catalogue/search.pl?idx=kw&q=d&sort_by=relevance_dsc&limit=holdingbranch:CPL

If I replace CPL with CP, I get the "no result" page

Do you recreate this issue on a sandbox?
Comment 2 Katrin Fischer 2018-01-30 20:50:17 UTC
I think the issue is the underscore. My guess is that Zebra treats it as a space, so you end up with Zebra treating AB_D and AB_C as 2 words. When doing a keyword search or limit on AB it will then naturally return the records from all branches with the 'word' AB.

My normal advice is: never use spaces or underscores or - in your codes (library, itemtype, locatio, collection, ...) in Koha, because of how Zebra will treat them. Sometimes you might want that behaviour, but other times it's really not helpful.
Comment 3 Jonathan Druart 2019-12-11 10:21:16 UTC
This is Zebra only (works ok with elastic)
Comment 4 Jonathan Druart 2019-12-11 10:49:30 UTC
Created attachment 96185 [details] [review]
Bug 20099: Try exact search for facets
Comment 5 Jonathan Druart 2019-12-11 10:50:26 UTC
So this patch does not work as "ext" is not supported if ICU is enabled.

The only thing is then to either use elastic, or modify the branchcodes :)