Bug 26608

Summary: Authorities: linked biblios is inconsistent using elasticsearch and QueryAutoTruncate
Product: Koha Reporter: Alex Arnaud <alex.arnaud>
Component: Searching - ElasticsearchAssignee: Alex Arnaud <alex.arnaud>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P5 - low CC: david, f.demians, fribeiro, fridolin.somers
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24143
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29048
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 26608: Elasticsearch - add exact (ext) field type and use it for linked biblios

Description Alex Arnaud 2020-10-05 08:53:05 UTC
Using ES and QueryAutoTruncate systempreference enabled, the count and list of linked biblios is wrong. This is because auto-truncate feature change the query "an:1" to "an:1*". So all biblio linked to an authid like 15, 1042, 11234 match the query.
Comment 1 Alex Arnaud 2020-10-05 09:04:07 UTC
Created attachment 111212 [details] [review]
Bug 26608: Elasticsearch - add exact (ext) field type and use it for linked biblios

Test plan:
 - Enable Elasticsearch engine,
 - Enable QueryAutoTruncate systempreference,
 - Show the detail od authority #1
   (cgi-bin/koha/authorities/detail.pl?authid=1)
 - note the inconsistent count of linked biblio (and so the list),
 - Apply this patch,
 - Restart all,
 - repeat previous step,
 - Count and list of linked biblios should be ok.
Comment 2 Fridolin Somers 2021-12-18 07:23:04 UTC
*** Bug 29724 has been marked as a duplicate of this bug. ***
Comment 3 Filipe Ribeiro 2021-12-20 14:56:24 UTC
Just realized that the problem also occurs at linked_biblionumbers. 
https://github.com/Koha-Community/Koha/blob/master/Koha/Authorities.pm#L81

Basically, when simple_search_compat is used, instead of id "1" , its searched "1*". This returns all biblios with authorities that starts with the number 1.
Comment 4 David Nind 2022-09-14 21:32:16 UTC
I've changed the status to "Needs Signoff"
Comment 5 David Nind 2022-09-14 21:48:36 UTC
Patch no longer applies 8-(...

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 26608: Elasticsearch - add exact (ext) field type and use it for linked biblios
Using index info to reconstruct a base tree...
M	Koha/Authorities.pm
M	Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
M	koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt
Auto-merging Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
CONFLICT (content): Merge conflict in Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
Auto-merging Koha/Authorities.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 26608: Elasticsearch - add exact (ext) field type and use it for linked biblios
Comment 6 Frédéric Demians 2023-05-23 08:23:21 UTC
For me this bug doesn't exist anymore in master, and so, could be closed. In PRO, authorities-home.pl page display valid authorities usage count. On the other hand, a similar issue persists in OPAC: see bug 33802.