From 0fcc4c5841239fdb80c8c036b1631144e3db0ed9 Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Mon, 9 Feb 2026 00:17:08 +0000 Subject: [PATCH] Bug 41795: Include the completeness attribute when matching on authtype UNIMARC instances include the following two authority types by default (among others): Corporate Body Name (code: 'CO') and Collective Title (code: 'CO_UNI_TI'). The problem is that when searching for Corporate Body Name authorities (in the OPAC or in the Staff interface), the results will include Collective Title authorities as well. It has to do with Corporate Body Name authorities using an authtypecode (CO) that happens to be the prefix of the authtypecode (CO_UNI_TI) used by Collective Titles. NOTE: Elasticsearch is not affected by this. The fix is to additionally pass the completeness attribute to the RPN query sent to Zebra so that it will try to match on what is literally found in the entire field's phrase index (i.e. the value of UNIMARC 152$b), instead of performing a partial match. More information can be found at the official documentation: https://software.indexdata.com/zebra/doc/querymodel-rpn.html#querymodel-bib1-completeness Test plan (tailored for KTD): 0) Launch a UNIMARC Koha instance using Zebra: ktd --marcflavour unimarc --search-engine zebra up 1) Import the Sample MARC record attached to this Bug, containing a single Collective Title authority (adding one manually would take a long time due to the many mandatory subfields). 2) Perform a generic authority search (without entering anything in the search box) for all 'Corporate Body Name' authorities. Note the number of results returned (83), and also notice that in page 4 of the results you get a stray 'Collective Title' authority ("Selected works", the one you imported in Step 1). 3) Apply this patch (and `restart_all`). 4) Repeat the same search as in Step 2. This time, the number of results returned should be one less than before (82), and you should only see 'Corporate Body Name' authorities in the results. --- C4/AuthoritiesMarc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index c2070f4560..5a46089f29 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -134,7 +134,7 @@ sub SearchAuthorities { my @authtypecode; my @auths = split / /, $authtypecode; foreach my $auth (@auths) { - $query .= " \@attr 1=authtype \@attr 5=100 " . $auth; ##No truncation on authtype + $query .= " \@attr 1=authtype \@attr 5=100 \@attr 6=3 " . $auth; ##No truncation on authtype push @authtypecode, $auth; $n++; } -- 2.39.5